No release bundle folder after upgrading Android S

2019-03-16 08:23发布

问题:

I recently upgraded my Android Studio to version 2.3 with the corresponding gradle version.

I have two modules inside my project, which i exported as a jar using gradle functions like this:

task createJar(type: Copy) {
from('build/intermediates/bundles/release/')
into('libs/')
include('classes.jar')
rename('classes.jar', 'myExample.jar')
}
createJar.dependsOn(deleteJar, build)
  • However after the upgrade, this does not work anymore. In Android Studio i set the Build Variant to "Release", but after running my tasks there will be no JAR in my lib folder. I checked the build/intermediates/bundles/ folder and theres no release folder generated. There will be just a default and a debug folder.

  • Any way to get an external JAR from a release build again?

回答1:

Not sure if this is the proper solution but I added this to my gradle file within the android section and the release folder has returned.

publishNonDefault true


回答2:

On Android studio 3.1+ the build path got changed. So change the path to "build/intermediates/packaged-classes/release/".

task exportJar(type: Copy)
{
    from('build/intermediates/packaged-classes/release/')
    into('build/outputs/')
    include('classes.jar')
    rename ('classes.jar', 'NAME.jar')
}