I am creating AAR file using another aar and jar file dependency. I have successfully created the .aar release file.
Then, I have imported my new AAR file into the sample Project. the project is running fine. when going to access that aar and jar classes mean, It's showing NoClassDefFound error.
Note: First I want to know, as of now AAR inside another AAR is possible or not. can anyone help me to come out from this new things issue?
I referred to this link also Create an AAR with multiple AARs/JARs. It's saying transitive= true. But, not understand, where to use that flag. In third party using Application or while creating AAR inside AAR project dependencies.
Thanks Advance.
My Mini Project Gradle File:
Mini Project, which is only converting into .AAR file. then, this file only going to use another NewProject
Mini Project Build.gradle file
/*
This would be enabled for development purpose and to debug and check the same
*/
apply plugin: 'com.android.application'
/*
This would be enabled for exporting as aar file
apply plugin: 'com.android.library'
*/
//apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
dexOptions {
javaMaxHeapSize "4g"
preDexLibraries = false
}
defaultConfig {
/*
This application id would be used for development purpose and to debug and check the same.
This would be commented when exporting as library
*/
applicationId 'com.pss.pssplayer'
minSdkVersion 18
targetSdkVersion 23
multiDexEnabled true
versionCode 1
versionName "1.0"
}
aaptOptions {
cruncherEnabled = false
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile files('libs/ksoap2-android-assembly-3.2.0-jar-with-dependencies.jar')
compile files('libs/secure.jar')
compile(project(':getSubProject')) {
transitive = true
}// this getSubProject also contains one classes jar
}
Unlike JAR files, AAR files offer the following functionality for Android applications: AAR files can contain Android resources and a manifest file, which allows you to bundle in shared resources like layouts and drawables in addition to Java classes and methods.
In android studio, open the Project Files view. Find the . aar file and double click, choose "arhcive" from the 'open with' list that pops up. This will open a window in android studio with all the files, including the classes, manifest, etc.
When you refer to your aar and jar in your dependencies, then you can compile your new aar with references to the first.
But they are not embedded in your aar. Instead, the application using the "big aar" also need a dependency over the two first.
For that, you can deploy all your aar in a repository like maven in telling maven that the "big aar" depends on the two first. (-> pom.xml)
In you application build.gradle file, you can add the dependency only on the "big aar" with transitive=true
to tell the system to look at the dependencies of the dependency.
Edit :
You can at least merge jars. look at these answers :
gradle - how do I build a jar with a lib dir with other jars in it?
Can Gradle jar multiple projects into one jar?
Merging aar is more difficult because you have to merge all resources, manifests and so on...
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