dimanche 29 mars 2015

Android Studio doesn't recognize Facebook imports

I'm a begginer and I am trying to create an app with Facebook Integration.


I have done all the steps(Importing Facebook SDK in Module Structure,adding missing depedencies in gradle files,adding the dependencies module for my app project in Structure again). Everything seemed to be fine,I added A simple LoginButton in main_activity.xml) and no error showed up.


Since I tried to do all the facebook imports needed in MainActivity.java, they all turned red. Those were imports like:



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 like "symbol session cannot be resolved". I googled it as much as I could,couldn't find a solution that worked for me. At the opposite, this didn't seem to have a problem:



import com.facebook.login.widget.LoginButton;


Here is my Android Manifest File XML:



<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://ift.tt/nIICcg"
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'
}

Aucun commentaire:

Enregistrer un commentaire