4

I am facing problem to use external library project's in android studio version 1.2.2 .

steps i did to add external library projects are:-

  1. I created a new project exPagerSliding.

  2. I Add a new directory(libs) in root directory of the app. and paste the library there.

  3. I open my apps setting.gradle. and add following lines of code

    include ':app' ':PagerSlidingTabStrip'
    project(':PagerSlidingTabStrip').projectDir=new File('libs/PagerSlidingTabStrip')
    
  4. then I open my build.gradle file add following lines of code

    dependencies {
    classpath 'com.android.tools.build:gradle:1.2.3'
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.3'
    compile project(":PagerSlidingTabStrip")
    }
    

5.Next i go to gradle.properties and write following lines of code.

    ANDROID_BUILD_MIN_SDK_VERSION=14
    ANDROID_BUILD_TARGET_SDK_VERSION=21
    ANDROID_BUILD_TOOLS_VERSION=21.1.3
    ANDROID_BUILD_SDK_VERSION=21
  1. and last in build.gradle i add

    android {

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

    }

I am getting a message "Error:Cannot get property ':PagerSlidingTabStrip' on null object"

When i open my build.gradle file from library . their i am getting this message

you must use a newer version of android gradle plugin.current version is 1.0 and recomended version is 1.2.3


well now problem is solved,

so i am writing for those who was still facing this mess.

step's to use external library project in android studio are:-

  1. go to file-new -import module.

  2. select your library project folder.

  3. after importing module.

  4. go to file->project structure->select app ->select dependency-> click on + sign in right side->module dependencies-> select your module name and press ok.

  5. 4th step was the final step , but you can get two type of error. Ex. no such property GROUP... for handle this go to select build.gradle of your library , and remove line like this apply from: 'https://raw.github.com/twotoasters/gradle-mvn-push/master/gradle-mvn-push.gradle'

2 Answers 2

2

This is my way for adding external libraries to Android studio project.

  1. Open your project where you want to add external library.
  2. Then in File> New> choose Import new Module, navigate to library project which you want to add to your project, select to add 'library' module in your project. You will get in your project settings.gradle beside app, included library, something like this:

    include ':app', ':library'

  3. Add in build.gradle(module :app) in dependencies section:

    compile project(':library')

  4. Rebuild project and that's it.

*You can add as many libraries (modules) as you want. In that case in settings.gradle you will have:

 include ':app', ':lib1', ':lib2', ... 

And in build.gradle:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
//some your dependencies...

     compile project(':lib1')
    compile project(':lib2')
    ...
}
Sign up to request clarification or add additional context in comments.

Comments

1

You just need to create a module and add the external library project to this module. Then add module dependency in project structure. That's all. Android Studio will automatically add everything to Gradle file. You don't need to do these manually.

6 Comments

add the external library project mean's , simply copy paste the library to modules libs folder , or their any other way
Copy and paste. I did this when building Zxing source code.
Dear , I am getting a error after adding module dependency in project structure , the problem is Could not find property 'ANDROID_BUILD_SDK_VERSION' on project ':library'.
I recommend this way as @yushulx said File -> New -> Import module then select your external library/project then go to project structure and add module dependency and it'll shows your imported module. you don't need to change those files manually
I did the same, but getting problem
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.