无法从Facebook Android Sdk导入请求和会话类

时间:2018-01-22 17:06:13

标签: facebook android-studio facebook-android-sdk facebook-friends

我正在尝试导入com.facebook.Request和com.facebook.Session类,目标是将Facebook friendlist从Facebook转移到我的应用程序中。

import com.facebook.Request;
import com.facebook.Session;

但是,由于Android工作室无法识别它,因此请求和会话一直保持红色。谁知道如何解决这个问题?我很感激任何见解!

这是我的清单文件:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.example.demouser.bond">

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

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity
            android:name=".SplashActivity"
            android:theme="@style/SplashTheme">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".MainContactScreen"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".IndividualContactActivity"
            android:windowSoftInputMode="adjustPan" />
        <activity
            android:name=".CalendarMainActivity"
            android:parentActivityName=".MainContactScreen"
            android:windowSoftInputMode="adjustPan" />
        <activity
            android:name=".IndividualContactPage"
            android:parentActivityName=".MainContactScreen"
            android:windowSoftInputMode="adjustPan" />
        <activity android:name=".TemplateMainActivity" />

        <receiver
            android:name=".AlarmBroadcastReceiver"
            android:enabled="true">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
            </intent-filter>
        </receiver>

        <meta-data
            android:name="com.facebook.accountkit.ApplicationName"
            android:value="@string/app_name" />
        <meta-data
            android:name="com.facebook.sdk.ApplicationId"
            android:value="@string/FACEBOOK_APP_ID" />
        <meta-data
            android:name="com.facebook.accountkit.ClientToken"
            android:value="@string/ACCOUNT_KIT_CLIENT_TOKEN" />
        <meta-data
            android:name="com.facebook.accountkit.FacebookAppEventsEnabled"
            android:value="true" />

        <activity
            android:name="com.facebook.accountkit.ui.AccountKitActivity"
            android:theme="@style/Theme.AccountKit"
            tools:replace="android:theme" />
        <activity android:name=".FacebookLoginActivity" />
    </application>

</manifest>

App Gradle文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.example.demouser.bond"
        minSdkVersion 21
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:design:26.1.0'
    implementation 'com.android.support:support-v4:26.1.0'
    implementation 'com.android.support:recyclerview-v7:26.1.0'
    implementation 'com.facebook.android:account-kit-sdk:4.+'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'

    // Facebook Android SDK (everything)
    compile 'com.facebook.android:facebook-android-sdk:4.28.0'
}

Project Gradle文件:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        google()
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'


        // 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
}

如果有用,这是我的res / values / string.xml文件:

<resources>
    <string name="app_name">Bond</string>
    <string name="calendar_name">Android Custom Calendar</string>
    <string name="current_date">January, 2018</string>
    <string name="add_event">ADD CALENDAR EVENT</string>
    <string name="sun">SUN</string>
    <string name="mon">MON</string>
    <string name="tue">TUE</string>
    <string name="wed">WED</string>
    <string name="thu">THU</string>
    <string name="fri">FRI</string>
    <string name="sat">SAT</string>
    <string name="last_date">30</string>
    <string name="action_settings">Settings</string>
    <string name="title_item_list">Items</string>
    <string name="title_item_detail">Item Detail</string>
    <string name="facebook_app_id">137757443587015</string>
    <string name="fb_login_protocol_scheme">fb137757443587015</string>
    <string name="FACEBOOK_APP_ID">137757443587015</string>
    <string name="ACCOUNT_KIT_CLIENT_TOKEN">[ACCOUNT_KIT_CLIENT_TOKEN]</string>

</resources>

0 个答案:

没有答案