Android Studio does not recognize Facebook import

I am starting and I am trying to create an application with integration with Facebook.

I followed all the steps (importing the Facebook SDK into the module structure, adding missing parameters in the gradle files, adding the dependency module for my application project in the "Structure again" section). Everything seemed fine, I added a simple LoginButton to main_activity.xml) and no errors appeared.

Since I tried to make all the import books in MainActivity.java, they all turned red. These were such imported goods as:

import com.facebook.Session; import com.facebook.SessionState; import com.facebook.UiLifecycleHelper; import com.facebook.widget.LoginButton; import com.facebook.widget.LoginButton.UserInfoChangedCallback; 

and messages such as "symbol session cannot be resolved". I looked for it as much as I could, could not find a solution that worked for me. On the contrary, this showed no problem:

  import com.facebook.login.widget.LoginButton; 

Here is my Android manifest XML file:

  <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.user.moviere" > <uses-permission android:name="android.permission.INTERNET"/> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/> <activity android:name=".MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name="com.facebook.LoginActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar" android:label="@string/app_name" /> <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/> <activity android:name="com.facebook.FacebookActivity" android:configChanges= "keyboard|keyboardHidden|screenLayout|screenSize|orientation" android:theme="@android:style/Theme.Translucent.NoTitleBar" android:label="@string/app_name" /> </application> </manifest> 

And here is my build.gradle

  apply plugin: 'com.android.application' android { compileSdkVersion 21 buildToolsVersion '21.1.2' defaultConfig { applicationId "com.user.moviere" minSdkVersion 9 targetSdkVersion 22 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } repositories { mavenCentral() } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) // compile project(':facebook') compile 'com.android.support:appcompat-v7:22.0.0' compile 'com.facebook.android:facebook-android-sdk:4.0.0' compile 'com.android.support:support-v4:22.0.0' } 
+8
android import android-studio facebook sdk
source share
3 answers

Well, I created the project from the very beginning, imported the FB SDK again. But the real import problem was that the Facebook SDK 4 changed some functions, one of which is the UiLifecycleHelper, for example, it no longer exists.

Details of all changes are given here:

https://developers.facebook.com/docs/android/upgrading-4.x

+7
source share

Yes, in the current facebook sdk update, they deleted Session, now the AccessToken, LoginManager and CallbackManager classes override and replace functionality in the Session class.

For more information, go to - https://developers.facebook.com/docs/android/upgrading-4.x

+2
source share

Update Facebook Addiction

compile 'com.facebook.android:facebook-android-sdkrige.8.0'

Permission required in manifest file

 <uses-permission android:name="android.permission.INTERNET"/> 

  <meta-data android:name="com.facebook.sdk.ApplicationName" android:value="@string/app_name" /> <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id" /> <provider android:name="com.facebook.FacebookContentProvider" android:authorities="com.facebook.app.FacebookContentProvider1854328631556764" android:exported="true" /> 

Working

Details: -

https://developers.facebook.com/docs/android/upgrading-4.x

+1
source share

All Articles