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条回答
我欲成王,谁敢阻挡
2楼-- · 2019-01-04 00:49

You can get rid of the

"Error:(13, 0) Could not find property 'ANDROID_BUILD_MIN_SDK_VERSION'"

by replacing all the values like below see your build.gradle . you can find all the properties and the versions your application is using. replace the values of 'buld.gradle file' from facebook sdk with the same versions.

 android {
    compileSdkVersion 19 
    buildToolsVersion "20.0.0"

    defaultConfig {
         minSdkVersion 8
        targetSdkVersion 19
     }

and for BOLT.JAR Error, there is a dependacy in facebook sdk build.gradle file like compile "files('../libs/bolts.jar')" this is actually for the whole sdk folder which we download, but as we use only facebook folder so we have one less directory path to follow. Hence, you can get rean of one period before /libs so just remove it and keep it as compile files ('./libs/bolts.jar')

you are good to go !!

查看更多
混吃等死
3楼-- · 2019-01-04 00:50

add these line in your gradle.properties it work for me!

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

After do this plese follow step describe in this post https://stackoverflow.com/a/24457464/3296641

查看更多
【Aperson】
4楼-- · 2019-01-04 00:55

For those who do not know where to put gradle.properties, it should go to the root of the project. This is how it looks in one of my projects.

查看更多
看我几分像从前
5楼-- · 2019-01-04 00:57

Simply just go to project structure and select dependency enter image description here

then click + on the right top corner and select library dependency (the first option ) and just type facebook or if you need any other lib and click a search icon (MAKE SURE YOU HAVE INTERNET CONNECTION) and select com.facebook.android:facebook-android-sdk:.... and you are good to go enter image description here

查看更多
We Are One
6楼-- · 2019-01-04 00:57

Add the compile dependency with the latest version of the Facebook SDK in the build.gradle file:

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

For more info https://developers.facebook.com/docs/android/getting-started

查看更多
ゆ 、 Hurt°
7楼-- · 2019-01-04 00:57

I recently came across an error that was not resolved here yet. I tried to use the latest Facebook SDK from maven (by declaring compile 'com.facebook.android:facebook-android-sdk:4.6.0'). After gradle build I got no error and Android studio's static code analysis was also OK when declaring and writing FacebookSdk related code. However when I tried to run the code in the emulator, I got an error that facebook sdk is not included in the project. Then I tried some other hacks and then I finally removed the facebook entry from the gradle build file and tried to import it as a module, but that also did't work.

After a while when I was reading Facebook gradle file I realized that they are compiling the code with "sourceCompatibility JavaVersion.VERSION_1_7" flag. I used VERSION_1_8 flag because I wanted to use lambda's using retrolambda library. After I switched to 1.7 (and also adjusted the settings in File -> Project structure -> Source Compatibility) it started to work and there were no problems.

I quite don't understand why (and if) is this related together, but it probably is so be aware of that.

查看更多
登录 后发表回答