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);

[转载]Android Gradle 引用本地 AAR 的几种方式

  • 1. 把 AAR 放入 libs
  • 2. 在 build.gradle 添加 repositories{flatDir{dirs ‘libs’}}
  • 3. 在 build.gradle 添加 dependencies{compile(name:’nameOfYourAARFile’, ext:’aar’)}

其中当某个本地 aar/jar 需要在多个 module 进行依赖时,按照官方本身做法

Handling transitive dependencies for local artifacts (jars and aar)
If you have a local jar or aar library that you want to use in more than one project, you cannot just reference it directly as a local dependency. This is because the android plugin will complain if it finds the same jar file twice when dexing the project and all its dependencies. (Note that right now you can't actually use a local aar file even if you only reference it once).

One way to fix this is to deploy the artifact in a repository. While it's possible, it might not be convenient due to the overhead of managing such a repository.

Another option is to create a new Gradle sub-project, and to make this project's published artifact be the jar or aar file that you want to reuse. Then you can simply have other Gradle sub-projects depend on this new sub-project.

In this new sub-project, simply create a build.gradle with the following:

artifacts.add("default", file('somelib.jar'))

经过实际测试,创建一个放有依赖库的 Module,里面包含所要的依赖库,和 build.gradele 文件

例如:当前 Module 名称为:ShareLibs
artifacts.add("default", file('libs/somelib.jar'))

然后把此 Module 添加到根目录的 settings.gradle 中 'sharelibs'

其他各个 Module 都可以使用
implementation project(':sharelibs')