Cannot Resolve FacebookSdk in Android Studio - firebase

I am stuck in my code while I am implementing Facebook login through firebase.
I followed the documentation precisely, however it is not recognizing facebook SDK despite the fact that I can see all Facebook-related libraries in the project's library section.
Here you can see my build.gralde(:app) ;
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.mycompany.myapp"
minSdkVersion 21
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.4.0-alpha02'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'com.google.firebase:firebase-auth:21.0.1'
implementation 'com.google.firebase:firebase-database:20.0.1'
implementation 'com.facebook.android:facebook-android-sdk:12.2.0'
implementation platform('com.google.firebase:firebase-bom:28.4.0')
implementation 'com.google.firebase:firebase-auth'
implementation 'com.google.android.gms:play-services-auth:19.2.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
here my build.gradle(:module) ;
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:4.1.1"
classpath 'com.google.gms:google-services:4.3.10'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
my Manifest file;
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mycompany.myapp">
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_myapp_logo"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.MYAPP">
<activity android:name=".main_activities.LoginTrialActivity"></activity>
<activity android:name=".user_activities.ForgotPasswordActivity" />
<activity android:name=".user_activities.UserDetails" />
<activity android:name=".SplashScreenActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".user_activities.SigninActivity" />
<activity android:name=".user_activities.SignupActivity" />
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="#string/facebook_app_id"/>
<meta-data android:name="com.facebook.sdk.ClientToken" android:value="#string/facebook_client_token"/>
</application>
</manifest>
I also downloaded facebook-android-sdk-4.42.0 which I inserted to nowhere and never used... I did not understand how to use it.
finally, please see attached image to see I actually have facebook libraries.
Would you please kindly help?

Ok I solved the problem, I changed implementation 'com.facebook.android:facebook-android-sdk:12.2.0' to 'implementation 'com.facebook.android:facebook-android-sdk:4.42.0' and problem is gone. This SDK version is the one that I downloaded to my computer from "developers.facebook". Does anybody knows why?

Related

Firebase Cloud Messaging fails authentication for SDK 31+ on Android 12+

I set up FCM for my app. And it works perfectly for devices run under Android 11 and less. But for devices under Android 12 and greater I can't receive token by using
FirebaseMessaging.getInstance().token.addOnCompleteListener {
...
}
I receive an error: java.io.IOException: java.util.concurrent.ExecutionException: java.io.IOException: AUTHENTICATION_FAILED instead of token
Manifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.boltic28.learnmultiplying">
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<application
android:allowBackup="true"
android:dataExtractionRules="#xml/data_extraction_rules"
android:fullBackupContent="#xml/backup_rules"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.LearnMultiplying"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service
android:name=".services.firebase.AppFirebaseMessagingService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<meta-data
android:name="com.google.firebase.messaging.default_notification_channel_id"
android:value="#string/default_notification_channel_id" />
</application>
</manifest>
app:
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'com.google.gms.google-services'
}
android {
compileSdk 33
defaultConfig {
applicationId "com.boltic28.learnmultiplying"
minSdk 26
targetSdk 33
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
...
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = '11'
}
...
}
dependencies {
...
implementation 'com.google.firebase:firebase-messaging:23.0.4'
...
}
service:
class AppFirebaseMessagingService : FirebaseMessagingService() {
override fun onNewToken(token: String) {
super.onNewToken(token)
println("->> new token: $token")
}
override fun onMessageReceived(message: RemoteMessage) {
super.onMessageReceived(message)
println("->> new message: ${message.notification?.title} - ${message.notification?.body}")
}
}
Does anybody have some suggestions?
Data:
App targeted: SDK33
Run under : SDK31
FCM version : 23.0.6
The issue was with an emulator, FCM doesn't provide a token for devices under SDK31+ without Google play services. To solve the issue and get a token you have to use an emulator or device with installed Google play services, Google APIs are not enough.

Task :app:processDebugMainManifest FAILED when I add dependency implementation 'com.mesibo.api:mesibo:1.5.2'

I started a new project in Android Studio. Empty project compiles without problem.
As soon as I add implementation 'com.mesibo.api:mesibo:1.5.2' to dependencies, I get the following error:
[com.android.support:animated-vector-drawable:28.0.0] C:\Users\nenad\.gradle\caches\transforms-2\files-2.1\2321a6ddb441101d2687f6656a3ad88a\animated-vector-drawable-28.0.0\AndroidManifest.xml Warning:
Package name 'android.support.graphics.drawable' used in: com.android.support:animated-vector-drawable:28.0.0, com.android.support:support-vector-drawable:28.0.0.
[androidx.versionedparcelable:versionedparcelable:1.1.1] C:\Users\nenad\.gradle\caches\transforms-2\files-2.1\7db5a34e07a8e6159e7e1ab900eaa2f0\versionedparcelable-1.1.1\AndroidManifest.xml Warning:
Package name 'androidx.versionedparcelable' used in: androidx.versionedparcelable:versionedparcelable:1.1.1, com.android.support:versionedparcelable:28.0.0.
D:\AndroidStudioProjects\LiburnijaVoIP\app\src\main\AndroidManifest.xml:24:18-86 Error:
Attribute application#appComponentFactory value=(androidx.core.app.CoreComponentFactory) from [androidx.core:core:1.5.0] AndroidManifest.xml:24:18-86
is also present at [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91 value=(android.support.v4.app.CoreComponentFactory).
Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:5:5-22:19 to override.
My build.gradle is as follows:
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "hr.grafiknet.liburnijavoip"
minSdkVersion 21
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation platform('com.google.firebase:firebase-bom:28.2.1')
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.mesibo.api:mesibo:1.5.2'
}
Those errors are dure to mixing AndroidX/Support. Enable jetifier to resolve. Add following lines to your gradle.properties:
android.useAndroidX=true
android.enableJetifier=true

Oppo,xiaomi,vivo devices don't show fcm flutter backround notification

I am trying to send notifications from my app at certain times using Flutter Firebase Messaging. Notifications; The application does not appear when deleted from the background on OPPO, XIAOMI, VIVO .. devices.
As far as I research my application is on the device because it is on the black list;
User should activate autostart
User should allow the app to run in the background
User should add it as a priority application,
User need to make settings like that..
I don't think this is a good way. These features can change on every phone or all users may not be able to do them.
So , is there any way to solve solution that problem or in what other ways I can send notifications to these devices,
I am stuck on this issue for a few days, I would be very happy if you help.
Thank you very much for your time in advance.
I wish everyone a good work ...
manifest.xml code;
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="************">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="oppo.permission.OPPO_COMPONENT_SAFE"/>
<uses-permission android:name="com.huawei.permission.external_app_settings.USE_COMPONENT"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application
android:name="com.*****.Application"
android:label="daisy_period_app"
android:icon="#mipmap/ic_launcher">
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-3940256099942544~3347511713"/>
<activity
android:name="*************.MainActivity"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:excludeFromRecents="true"
>
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="#style/NormalTheme"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="#drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="FLUTTER_NOTIFICATION_CLICK" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
<receiver android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"></action>
</intent-filter>
</receiver>
<receiver android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationReceiver" />
</application>
</manifest>
build gradle;
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 29
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
checkReleaseBuilds false
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.smnway.daisy_period_app"
minSdkVersion 16
targetSdkVersion 29
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
shrinkResources false
minifyEnabled false
}
}
}
flutter {
source '../..'
}
apply plugin: 'com.google.gms.google-services'
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation platform('com.google.firebase:firebase-bom:26.5.0')
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.android.support:multidex:1.0.3'
implementation "com.google.firebase:firebase-messaging:20.1.0"
}

FCM notifications not receiving in app downloaded from playstore but debug version works normally?

I recently published by app in play store. It was not receiving fcm push notification (provided I'm using default channel in fcm console) but receiving fcm test notification to the same device.
The debug version of the app was receiving fcm notifications normally and also receiving fcm test notifications normally.
Please correct any changes in code !
Thanks in Advance !
Manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.github.chillmonk2.mycollege"
android:versionCode="1"
android:versionName="Release">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="#mipmap/icon_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/icon_launcher_round"
android:supportsRtl="true"
android:usesCleartextTraffic="true"
android:theme="#style/AppTheme">
<activity android:name=".HomeActivity"
android:theme="#style/AppTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:theme="#style/AppTheme">
</activity>
<activity
android:name=".EditProfile"
android:theme="#style/AppTheme"></activity>
<activity
android:name=".ShowProfileActivity"
android:theme="#style/AppTheme"></activity>
<activity
android:name=".SettingsActivity"
android:theme="#style/AppTheme"></activity>
<service
android:name=".MyFirebaseMessagingService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="#drawable/rvr" />
<!-- Set color used with incoming notification messages. This is used when no color is set for the incoming
notification message. for more. -->
<meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="#color/colorAccent" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_channel_id"
android:value="#string/default_notification_channel_id"/>
<meta-data
android:name="preloaded_fonts"
android:resource="#array/preloaded_fonts" />
</application>
</manifest>
MyFirebaseMessagingService.java
public class MyFirebaseMessagingService extends FirebaseMessagingService {
#Override
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
showNotification(remoteMessage.getNotification().getBody());
}
private void showNotification(String body) {
Uri uri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
PendingIntent pi = PendingIntent.getActivity(this, 0, new Intent(this, MainActivity.class), 0);
Notification notification = new NotificationCompat.Builder(this,getString(R.string.default_notification_channel_id))
.setSmallIcon(R.drawable.rvr)
.setContentTitle("RVRJC")
.setSound(uri)
.setContentText(body)
.setContentIntent(pi)
.setAutoCancel(true)
.build();
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(0, notification);
}
#Override
public void onNewToken(String s) {
super.onNewToken(s);
Log.d("FCM Token", "Refreshed token: " + s);
// If you want to send messages to this application instance or
// manage this apps subscriptions on the server side, send the
// Instance ID token to your app server.
}
}
build.gradle app
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
defaultConfig {
applicationId "com.github.chillmonk2.mycollege"
minSdkVersion 16
targetSdkVersion 29
versionCode 3
versionName "1.5.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
resConfigs "en"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
shrinkResources false
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.multidex:multidex:2.0.0'
implementation 'com.google.firebase:firebase-core:16.0.9'
implementation 'com.google.firebase:firebase-auth:17.0.0'
implementation 'com.google.firebase:firebase-database:17.0.0'
implementation 'com.google.firebase:firebase-firestore:19.0.0'
implementation 'com.google.firebase:firebase-messaging:19.0.1'
implementation 'com.firebaseui:firebase-ui-auth:5.0.0'
implementation 'com.firebaseui:firebase-ui-database:5.0.0'
implementation 'com.google.android.gms:play-services-auth:16.0.1'
implementation 'org.jsoup:jsoup:1.10.3'
implementation 'androidx.vectordrawable:vectordrawable:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
}
apply plugin: 'com.google.gms.google-services'
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true
Build.gradle project File
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.google.gms:google-services:4.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
//crashlytics Plugin
classpath 'io.fabric.tools:gradle:1.29.0'
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

Please help me CloudFirestorePlugin.java uses or overrides a deprecated API.( unchecked or unsafe operations.)

I've tried everything i see on the net to solve this problem for a day.Downgrade versions add something in gradle or rebuild etc. in short i am tring to use firebase.
For every solution i try, the error changes, but it doesn't end. Here is my mysterious gradles and pubspec. in android/app/gradle:
apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.app"
minSdkVersion 16
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
signingConfig signingConfigs.debug
}
}
}
dependencies {
implementation 'com.google.firebase:firebase-analytics:17.0.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
in android/gradle
...
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.2.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
...
in pubspech.yaml:
path_provider: ^1.2.0
sembast: ^2.0.1+2
flutter_bloc: ^0.21.0
equatable: ^0.5.1
cloud_firestore: ^0.12.9+3
I would be grateful if someone help i also tried app plugin google service or change google services to 3.2.1 or minsdkversions..
i found the answer for my case tried all of them, but it fixed when targetsdk and min sdk used same time
Flutter: FlutterFirebaseInstanceIDService.java uses or overrides a deprecated API

Resources