首页 > 解决方案 > 混淆时如何避免proguard修改包结构

问题描述

我有一个具有以下结构的android库项目:

- com.domain
------------.internal //internal classes of the library
------------.thirdPartyLib //3rd party library package renamed
------------.library.publicclasses //All the public classes of the library

这个想法是将程序配置为:

- Don't remove any unused classes (since it is a library)
- Obfuscate and optimize everything (including class and methods names) except the classes under **publicclasses** that should keep their names and public elements unchanged

目前我的proguard配置是:

-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable
-keep,allowobfuscation class com.domain.** {*;}
-keep class com.domain.library.publicclasses.** {public *;}
-keep class com.domain.library.publicclasses.Foo {public protected *;}

此配置的结果是:

- com.domain.library.publicclasses //All the public classes of the library
- a.a.a  /// all the internal and thirdPartyLib classes

我的问题是这些a.a.a类与其他库混淆的类发生冲突,所以我也希望最终的类结构是

- com.domain.library
--------------------.publicclasses //All the public classes of the library
--------------------.a  /// all the internal and thirdPartyLib classes

将混淆的类保留在我的域下,这样它就不会发生冲突。

我怎样才能做到这一点?

标签: javaandroidproguardobfuscation

解决方案


推荐阅读