My goal is to distribute an .aar file that can be used by other developers in their projects. The problem I am running into is that when a developer wants to integrate my .aar into their application, they need to specify all of the dependencies in their build.gradle file that I have already included in my .aar build.gradle. My goal is to let the developer only include my library as a dependency and somehow the libraries that my library depends on will magically get included in that developer’s project.
For example, my library defines the following dependencies in its build.gradle file:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile ('com.android.support:support-v4:21.0.+')
compile ('com.readystatesoftware.sqliteasset:sqliteassethelper:2.0.1')
compile ('org.apache.commons:commons-math3:3.3')
compile ('com.google.code.gson:gson:2.3')
}
I wrote a test app that uses my library. My understanding is that I if I include my library as a dependency, then by proxy, I will also get the rest of the dependencies that the library depends on so what I want to be able to do is the following:
dependencies {
compile fileTree(dir: 'libs', include: ['*.aar'])
compile name:'app-offline-debug', ext:'aar'
}
However, this does not work. I get java.lang.VerifyErrors at runtime. What ends up working is to include this in the app’s build.gradle file:
dependencies {
compile fileTree(dir: 'libs', include: ['*.aar'])
compile name:'app-offline-debug', ext:'aar'
compile 'com.android.support:support-v4:21.0.+'
compile 'com.readystatesoftware.sqliteasset:sqliteassethelper:2.0.1'
compile 'org.apache.commons:commons-math3:3.3'
compile 'com.google.code.gson:gson:2.3'
}
Why do I need to include dependencies in both the .aar and the final application? What am I not understanding about how dependencies work? Why isn’t the final application able to grab the .aar’s dependencies from maven at build time?