Search code examples
androidandroid-libraryaarandroid-studio-2.1

Android Studio Create AAR using another AAR file and jar inside


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
}

Solution

  • Use android-fat-aar gradle plugin, it is super usefull!