Importing Facebook library in Android Studio: Could not find property 'ANDROID_BUILD_SDK_VERSION'
Asked Answered
E

5

55

I want to import a library project into my app but whenever I try to do so , Android Studio doesn't recognise it

It also gives me errors in build.gradle ..

The Library is : PagerSlidingTabStrip ....

Here are some pictures :

enter image description here

enter image description here

I have been trying to make it work for 3 days so far !! Please Help Me :)

EDIT:

apply plugin: 'android-library'

dependencies {
compile 'com.android.support:support-v4:19.0.0'
}

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

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

sourceSets {
    main {
        manifest.srcFile 'AndroidManifest.xml'
        java.srcDirs = ['src']
        res.srcDirs = ['res']
    }
}
}

 apply from: 'https://raw.github.com/chrisbanes/gradle-mvn-push/master/gradle-mvn-push.gradle'

EDIT2 :

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':Sahertoday'.
> Could not resolve all dependencies for configuration ':Sahertoday:_debugCompile'.
> Could not find com.astuetz:pagerslidingtabstrip:1.0.1.
 Required by:
     Saher-3:Sahertoday:unspecified

* Try:
 Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get         more log output.

 BUILD FAILED
Erratum answered 31/1, 2014 at 10:35 Comment(2)
Please post your build.gradle file. How did you declare that library ?Autonomous
This is build.gradle for the library ..Erratum
U
54

First of all, you can add this dependency to your project, without compiling the lib locally.

dependencies {
    compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
}

Otherwise if you would like to compile this lib locally, you have to define these keys in gradle.properties in the root.

ANDROID_BUILD_TARGET_SDK_VERSION=19
ANDROID_BUILD_TOOLS_VERSION=19
ANDROID_BUILD_SDK_VERSION=19
Ultimo answered 31/1, 2014 at 21:47 Comment(8)
When I use the first step, error shows up (I post the error above) .. second step did not work as well !Erratum
With first solution, you should add repositories { mavenCentral() } in your proj/build.gradle.Ultimo
Execution failed for task ':Sahertoday:processDebugManifest'. > Manifest merging failed. See console for more info. Now this showed up :( I really appreciate your help..Erratum
Thank you very much ,, I found the problem with the manifest .. Thanks Thanks :) Best Luck :)Erratum
This does not work for me. It still says it can't find the properties.Bonner
This is missing one other property. You also need to set: ANDROID_BUILD_MIN_SDK_VERSION=19Bellbella
How come the file "gradle.properties" doesn't exist for me by default?Gallfly
@androiddeveloper I don't know. But you can create it.Ultimo
K
38

EDIT

There is also a GUI way for doing this. It is accessed by selecting the module facebook in the project tree and pressing f4.
Also you can just right-click the facebook and go to Open Module Settings near the bottom.

It is shown in the pictures. The numbers in the picture are top sdk version at the time of writing.

first block - The numbers in the pictures don't match the above ones, but that's because I updated them later on.

second block - same update

There is a simpler solution. The constants like ANDROID_BUILD_SDK_VERSION can be replaced with normal version "numbers". So instead of

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

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

..file can look like this:

android {
    compileSdkVersion 19
    buildToolsVersion '19.1.0'

    defaultConfig {
         minSdkVersion 15
         targetSdkVersion 19
    }
Kloof answered 4/7, 2014 at 7:45 Comment(2)
In new version of Android Studio > 4.3 there is no module import optionSletten
@Xjet I am using version 0.8.9 and there is still option for module import. I find it under File->Import Module, right at the top. It seems yout have your versions mixed up.Kloof
B
3

Go the facebook folder which you have imported in your project. Copy the gradle.properties file and paste in into your facebook module.It will remove the errors.

Bakke answered 17/4, 2015 at 11:3 Comment(0)
A
1

For those who ran into same problems while adding libraries and still can't get it work. The following local include of the .aar file worked for me:

  • Just download the .aar file from the maven repo manually.
  • In Android Studio go to File -> new Module -> import .JAR or .AAR package and select your downloaded .aar file.

Android Studio does the rest (in the build.gradle) for you. Maybe clean and rebuild your project.

Aikido answered 21/1, 2015 at 11:15 Comment(0)
U
1
apply plugin: 'com.android.library'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 4
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile 'com.android.support:appcompat-v7:22.2.1'
}
Unpeople answered 12/2, 2016 at 5:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.