I have an Android Library module that I need to ship as a JAR. The library has no resources, so I think it's valid to extract the classes.jar
from the generated aar file. However, the classes in my library have remote dependencies, so when I try to import classes.jar
and instantiate a class defined there, I get a NoClassDefFound problem.
I have read about using the transitive keyword (How do I ship an Android Library (aar) with remote dependencies (gradle)?), but I want to allow users to just drop in JARs to accommodate those not using gradle, so my problem is slightly different.
I can browse to my local gradle cache and find all my library's dependencies (as JARs), so I could pull all these and have users drop them in, but it seems inelegant. Is there a way I can either a) have the jars of the remote dependencies output to a folder in my build directory at library compile time or b) have gradle export all transitive dependencies into my aar?
My gradle.build:
apply plugin: 'android-library'
apply plugin: 'maven'
android {
compileSdkVersion 19
buildToolsVersion "20.0.0"
defaultConfig {
minSdkVersion 16
targetSdkVersion 16
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
compile 'com.android.support:support-v4:19.0.0'
compile 'com.android.support:appcompat-v7:20.0.0'
// my two cloud endpoints libraries
compile ([group: 'com.appspot.super_endpoint_999', name: 'hello', version: 'v1-1.18.0-rc-SNAPSHOT'])
compile files('libs/advancedhello-v1-1.19.0-SNAPSHOT.jar')
compile 'com.google.android.gms:play-services:4.2.+'
compile('com.google.api-client:google-api-client:1.17.0-rc') {
exclude(group: 'xpp3', module: 'xpp3')
exclude(group: 'org.apache.httpcomponents', module: 'httpclient')
exclude(group: 'junit', module: 'junit')
exclude(group: 'com.google.android', module: 'android')
}
compile('com.google.api-client:google-api-client-android:1.17.0-rc') {
exclude(group: 'com.google.android.google-play-services', module: 'google-play-services')
}
compile('com.google.http-client:google-http-client-android:1.17.0-rc') {
exclude(group: 'com.google.android', module: 'android')
}
compile 'com.google.guava:guava:14.0.+'
compile fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
}