How to add a project as a library in Android Studio?
android, android-studio, project
Solution
I would suggest to import your library manually rather than using "Import Module" since it 1) will change directory layout for the library; 2) you can catch bugs (as I did) because Android Studio is still in beta.
To accomplish this:
1) Copy your library folder under /libraries
2) Create build.gradle file inside library folder you've just copied, with similar content:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
}
}
apply plugin: 'android-library'
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
}
sourceSets {
main {
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
manifest.srcFile 'AndroidManifest.xml'
}
}
}
3) Add `include ':libraries:RootTools'` to your `settings.gradle`
4) Add dependency to the `build.gradle` under the app module:
dependencies {
compile project(':libraries:RootTools')
...
}
5) Run `./gradlew assembleDebug` to assemble your project, including the library.
Problem
How can I add a project like (RootTools) on another project as library in Android Studio? I am using Android Studio 0.8.1 and I don't know how to add another project (folder) and I found a lot of information about importing jar files, but this is not the case. Thanks for your help.