0

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?

libs-ss

James Z
  • 12,209
  • 10
  • 24
  • 44
  • Have you done a gradle sync? Are the `facebook_app_id` and `facebook_client_token` strings defined? What error are you seeing? – Jake Lee Jan 03 '22 at 19:01
  • Yes, I sync both inside of the gradle files and from file-> Sync Project with Gradle Files. I added both strings. I simply try to import com.facebook.FacebookSdk; and it says " cannot resolve symbol 'FacebookSdk' – K.Ozan Köse Jan 03 '22 at 19:05
  • And the other 2 questions? – Jake Lee Jan 03 '22 at 19:07
  • I editted my response, by the way it recognizes "com.facebook" part, problem is "FacebookSdk" – K.Ozan Köse Jan 03 '22 at 19:08
  • 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 version is the one that I downloaded to my computer from "developer.facebook". Do you know why? – K.Ozan Köse Jan 03 '22 at 19:31

1 Answers1

1

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?