Hi
I am using Gradle with android studio.
I have a project structure like below.
Base - this is library project. App - this is application project.
I want refer Base library as a jar or aar dependency, means I want to add the generated files of Base library as a dependency to the App project.
Please help me how to achieve this using gradle and android studio.
You’ll want to add a project dependency on your library project.
dependencies {
compile project(’:Base’)
}
Take a look at the Android plugin documentation for more information.
Thanks for you reply.
My situation is like below,
Library -1 (Base) Library -2 (Home) Library -3 (Data) Application - App.
App
|
|…Base
|…Data
|…Home
|
Data
|
|…Base (This need to be provided files dependancy or jar dependancy).
|
Home
|
|…Base (This need to be provided files dependancy or jar dependancy).
|
Library -1 (Base) is a common library which is refered in Home, Data and App.
If I use the below code to refer the Base library
dependencies {
compile project(':Base')
}
I am getting dex error limit exeed number of methods.
So I have to refer the Base library as a jar by giving the dependency as below for Home and Data library to resolve compile time errors.
dependencies{
provided files('../Base/libs/base.jar')
}
and will include Base as a library for the App like below as you mentioned.
dependencies {
compile project(':Base')
}
But my problem here is Gradle in android studio will generate .aar files and that files cannot refer as provided files dependency.
I wanted the solution like below
dependencies {
compile files("$buildDir/classes") {
builtBy 'compile'
}
}
task compile << {
println 'compiling classes'
}
but this is not supporting in gradle with android studio.
Any reason why you can’t just use the multidex support to get around the method limit?
Alternatively, if the library you are creating doesn’t need to be packaged as an AAR, why not just make it a regular Java library project?
Enable multidex is one option but I am worried about performance. Is there any trade off between multidex enebaled apk and multidex disabled apk?
I don’t think there are any runtime performance impacts. You may however end up with a larger APK and longer install times. You may want to look here for considerations when using multidex.