Android Studio 0.8.1 - how to use Facebook SDK?

2019-01-04 00:25发布

I tried via import module but I'm always getting

Error:(13, 0) Could not find property 'ANDROID_BUILD_MIN_SDK_VERSION' on project ':facebook'.

I didn't find a tutorial how to use the Facebook SDK with the latest Android Studio...

12条回答
Deceive 欺骗
2楼-- · 2019-01-04 00:40

Now you can use version 3.21.1 from maven

https://developers.facebook.com/docs/android/

dependencies {
       compile 'com.facebook.android:facebook-android-sdk:3.21.1'
}
查看更多
看我几分像从前
3楼-- · 2019-01-04 00:41

EXPLINATION:

The following constants can be defined in your project gradle.properties:

ANDROID_BUILD_MIN_SDK_VERSION=15
ANDROID_BUILD_TARGET_SDK_VERSION=21
ANDROID_BUILD_TOOLS_VERSION=21.1.2
ANDROID_BUILD_SDK_VERSION=21

Those are used in the Facebook sdk as build gradle settings. To specify your use of the sdk. (it's encouraged that those values match your project values!).

"Code Reusability and Dependancy!" you can use those same values as gradle build settings in all build.gradle files for your project and all other modules inside your project. use them they same way they are used in the Facebook build.gradle file.

Example Benefit: Changing the minimum sdk version on gradle.properties will automatically change it for all your modules build.gradle.

查看更多
▲ chillily
4楼-- · 2019-01-04 00:46

Using Facebook SDK 3.23 in Android Studio 1.1 preview 2

Two choices :

*Maven Repository for the Facebook SDK.

dependencies {
    compile 'com.facebook.android:facebook-android-sdk:4.7.0'
}

check for the latest version facebook sdk

OR

*Follow the steps below:

1.Download facebook sdk https://developers.facebook.com/docs/android/

2.Unzip the archive facebook-android-sdk-3.23.0

3.File menu->Import Module

4.Chose “facebook” folder inside the unzipped archive.

5.Go to directory facebook/build.gradle change this part

This:

 compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
    buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION

    defaultConfig {
        minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION)
        targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)
    }

To proper sdk version

example:

 compileSdkVersion 21
        buildToolsVersion '21.1.1'

        defaultConfig {
            minSdkVersion 14
            targetSdkVersion 21
        }

6.Click your project and press F4 ,go to 'dependencies' tab, click '+', 'module dependency' and select your imported facebook module.

7.Resync and rebuild

查看更多
甜甜的少女心
5楼-- · 2019-01-04 00:46

For anybody still wondering, there is finally an official Maven repo for the Facebook SDK:

dependencies {
    compile 'com.facebook.android:facebook-android-sdk:3.20.0'
}
查看更多
劳资没心,怎么记你
6楼-- · 2019-01-04 00:46

Write all those variables values in "gradle.properties" file.

Like

ANDROID_BUILD_TARGET_SDK_VERSION=19
ANDROID_BUILD_TOOLS_VERSION=19.1.0
ANDROID_BUILD_SDK_VERSION=19
ANDROID_BUILD_MIN_SDK_VERSION=14

You can follow this post https://stackoverflow.com/a/20221453/1232520

查看更多
Juvenile、少年°
7楼-- · 2019-01-04 00:47

You can now get Facebook SDK with gradle:

compile 'com.facebook.android:facebook-android-sdk:3.20.0'
查看更多
登录 后发表回答