mnagy
mnagy

Reputation: 1085

How to import library to Android studio 0.4.3

I want to import library project to my project in Android studio I don't know why this is such a big deal in android stuido !! ... please someone help me

Upvotes: 0

Views: 1191

Answers (1)

mnagy
mnagy

Reputation: 1085

To import a library .. lets say actionbarsherlcok

  1. copy to the library folder to your project folder .. or to "libs" folder inside your project folder .. manually .. not in the IDE

  2. make sure your minSdkVersion, targetSdkVersion, compileSdkVersion, buildToolsVersion are the same in build.gradle in your project directory and in your library directory.

    android {
    compileSdkVersion 19
    buildToolsVersion "19.0.1"
    
    defaultConfig {
    minSdkVersion 8
    targetSdkVersion 19
    }
    
  3. make sure that in your AndroidManifest.xml in your project and library directory has the same minSdkVersion and targetSdkVersion like above

    <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="19" />
    
  4. in your main project directory open "settings.gradle" then type your library directory name

    include ':actionbarsherlock'
    

if you put it in libs folder then it will be

    include ':libs\actionbarsherlock'
  1. build > clean project
  2. build > make project then run your project

** if you imported a library project with a sample project and it doesn't work do the same steps and also

open gradle > wrapper > gradle-wrapper.properties and change distributionUrl to the latest gradle version .. in my case

distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-bin.zip

then in the main directory of the project open "build.gradle" and change the dependencies to

dependencies {
    classpath 'com.android.tools.build:gradle:0.8.+'
}

then clean project and rebuild

that's it .. that worked with me in Android Studio 0.4.3

Upvotes: 1

Related Questions