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
-
Have a look in to this http://stackoverflow.com/questions/21170395/how-to-include-and-compile-a-library-in-the-buid-gradle-of-an-android-project/21170626#21170626 – Piyush Agarwal Jan 31 '14 at 04:32
-
I did exactly what's written there .. my problem is syncing gradle files – mnagy Feb 01 '14 at 14:59
-
what error are you getting while syncing ? – Piyush Agarwal Feb 01 '14 at 17:21
-
I figured it out down below – mnagy Feb 01 '14 at 21:12
1 Answers
To import a library .. lets say actionbarsherlcok
copy to the library folder to your project folder .. or to "libs" folder inside your project folder .. manually .. not in the IDE
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 }
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" />
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'
- build > clean project
- 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

- 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