androidjargradleruntimeexceptionamazon-device-messaging

Remove jar during runtime on Sub-Module in Android Studio


i have three build.gradle files on for the project (project build.gradle) one for the main module (main build.gradle) and one for another sub-module (submodule build.gradle)

My submodule build.gradle uses ADM (Amazon Device Messaging). and therefore has the following dependency attached.

using the provided dependency on the main build.gradle works but it doesnt work if i add it to the submodule. The following works if on

main build.gradle

repositories {
    mavenCentral()
    flatDir {
        dirs 'libs'
    }
}

dependencies {
    compile fileTree(dir: 'libs', exclude: 'amazon-device-messaging-1.0.1.jar', include: '*.jar')
    provided files('libs/amazon-device-messaging-1.0.1.jar')
}

What I have tried

  1. Added the following to submodule build.gradle (still get runtime exception)

    configurations {
        provided
    }
    sourceSets {
    main {
        compileClasspath += configurations.provided
    }
    test {
        compileClasspath += configurations.provided
        }
    }
    
    sourceSets.main.compileClasspath += configurations.provided
    
    dependencies {
    provided files('libs/amazon-device-messaging-1.0.1.jar')
    }
    

NOTE : I have also changed provided to something custom like providedlibs and it still doesn't work

  1. Added the following to the submodule build.gradle file (runtime exception still)

    android.libraryVariants.all { 
    variant -> variant.packageLibrary.exclude( 'ext_libs/amazon-device-messaging-1.0.1.jar' )
    }
    
  2. Added the following to submodule build.gradle file (I cant even compile with this fellah - i guess it removes during build as well)

    android.libraryVariants.all { variant ->
        variant.outputs.each { output ->
            output.packageLibrary.exclude('libs/someLib.jar')
        }
    }
    

Solution

  • What works is adding dependency to a maven repo and including it in the library with the provided dependency