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.
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.
If you want to do it manual, you can follow the steps below.
include ':libraries:RootTools'
dependencies { compile 'com.android.support:support-v4:19.1.+' compile project(':libraries:RootTools') }
then run
or ./gradlew assemble
app
- build.gradle // add dependency
libraries
- RootTools
settings.gradle // add project
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With