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' }
android import android-studio facebook sdk
linous
source share