[转载]How to set name of AAR output from Gradle

As mentioned in comments below and another answer, the original answer here doesn’t work with Gradle 3+. Per the docs, something like the following should work:

Using the Variant API to manipulate variant outputs is broken with the new plugin. It still works for simple tasks, such as changing the APK name during build time, as shown below:

// If you use each() to iterate through the variant objects,
// you need to start using all(). That's because each() iterates
// through only the objects that already exist during configuration time—
// but those object don't exist at configuration time with the new model.
// However, all() adapts to the new model by picking up object as they are
// added during execution.
android.applicationVariants.all { variant ->
    variant.outputs.all {
          outputFileName = "${variant.name}-${variant.versionName}.apk"
    }
}

OLD ANSWER:

I am unable to get archivesBaseName & version to work for me w/ Android Studio 0.8.13 / Gradle 2.1. While I can set archivesBaseName and version in my defaultConfig, it doesn’t seem to affect the output name. In the end, adding the following libraryVariants block to my android {} scope finally worked for me:

libraryVariants.all { variant ->
    variant.outputs.all { output ->
        if (outputFile != null && outputFileName.endsWith('.aar')) {
            outputFileName = "${archivesBaseName}-v${versionName}.aar"
        }
    }
}

https://stackoverflow.com/questions/24728591/how-to-set-name-of-aar-output-from-gradle

Android ProGuard Learning

  • if all public methods may be callback methods
-keep class mypackage.MyCallbackClass {
    public <methods>;
}
-keepclasseswithmembernames class * {
    native <methods>;
}
-keep class mypackage.MyCallbackClass {
    void myCallbackMethod(java.lang.String);
}

https://stackoverflow.com/questions/7880107/in-proguard-how-to-preserve-a-set-of-classes-method-names
https://www.guardsquare.com/en/products/proguard/manual/