Android Studio Create AAR using a different AAR file and jar inside

I am creating an AAR file using a different aar and jar dependency. I have successfully created the .aar release file.

Then I imported my new AAR file into the Project sample. the project is working fine. when accessing these classes, aar and jar means that it shows a NoClassDefFound error.

Note. First, I want to know that at the moment, AAR is possible inside another AAR or not. can someone help me out of this new problem?

I referenced this link also Created AAR with several AAR / JARs . It says transitive = true. But I don’t understand where to use this flag. In a third-party application using the application or when creating an AAR inside AAR project dependencies.

Thanks. Advance

My mini-project Gradle File:

Mini Project, which only converts to an .AAR file. then this file will 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 } 
+6
source share
2 answers

Use the android-fat-aar gradle plugin, it is very useful!

+1
source

When you refer to your aran and the jar in your dependencies, you can compile your new aar with links to the first.

But they are not built into your aaron. Instead, an application that uses "big aar" also needs to depend on the first two.

To do this, you can deploy all your aars in the repository, for example, maven, telling maven that the "big aar" depends on the first two. (-> pom.xml)

In your application’s build.gradle file, you can add the dependency only to the "big aar" using transitive=true to tell the system about the dependency dependency.

Edit :

You can at least combine banks. look at these answers:

gradle - how do I create a jar with a lib distribution with other banks in it?

Can Gradle combine several projects into one jar?

Merging aar is harder because you have to combine all resources, manifests, etc.

+2
source

Source: https://habr.com/ru/post/1011990/


All Articles