0

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

mnagy
  • 1,085
  • 1
  • 17
  • 36

1 Answers1

1

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

mnagy
  • 1,085
  • 1
  • 17
  • 36
  • If you want you can remove the sdk declarations from manifest completely.They are no longer useful, it will help you to get rid of conflicts. If your intention is to use only actionbarsherlock adding this this line in module's dependencies section of build.gradle file is enough `compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'` everything else you can skip. – Piyush Agarwal Feb 02 '14 at 02:43