
我想在我的图书馆上使用proguard,但文件(规则)应在图书馆内设置.这意味着我不想在我的应用程序模块中显式设置规则(属于该库).
我发现有一个类似于ConsumerProguardfiles属性的东西.我的设置:
库gradle:
buildTypes { deBUG { deBUGgable true MinifyEnabled false } release { MinifyEnabled true consumerProguardfiles 'proguard-rules.pro' }}应用程式gradle:
buildTypes { deBUG { applicationIDSuffix ".deBUG" deBUGgable true MinifyEnabled false signingConfig signingConfigs.deBUG } release { deBUGgable false MinifyEnabled true signingConfig signingConfigs.release proguardfiles getDefaultProguardfile('proguard-androID.txt'), 'proguard-rules.pro' }}为什么上面的配置不起作用?我收到无法从库中找到软件包/符号的错误.
编辑:
重要的是,对于库而言,我的proguard-rules.pro和对于主应用程序模块的proguard-rules.pro都为空.
示例性错误:
Error:(3, 60) error: package (my library package here) does not exist(...)Error:(16, 9) error: cannot find symbol class NavigationStructureModel(...)然后处理了一个错误.如我所见,库中的所有类都丢失了.
解决方法:
您需要弄清楚是否要
>在库上运行proguard
>在应用程序上运行proguard(提示:就是这个.)
在库上运行proguard
那是在它到达应用程序之前.您的库保护程序规则负责使所有代码都可以访问和显示,但是您可能会使内部类难以理解.
这是库build.gradle:
androID { defaultConfig { proguardfiles getDefaultProguardfile('proguard-androID.txt'), 'proguard-rules.pro' } buildTypes { release { MinifyEnabled true // Yes, run proguard on the library itself. } }}如果将此库作为开源发布,则不需要此库.如果您不公开发布该库,则不需要此库.
I get errors that packages/symbols from the library cannot be found.
Proguard会在类之间建立依赖关系图.此时,该库是一个独立的单元,因此,如果您不提供任何规则,则不会使用任何类,因此proguard会将其全部删除.
在应用程序上运行proguard
让使用者(应用程序)知道要保留哪些库类.
这是库build.gradle:
androID { defaultConfig { // Here's what proguard on the app should do on the library's behalf. consumerProguardfiles 'proguard-consumer-rules.pro' } buildTypes { release { MinifyEnabled false // No, don't proguard the library itself. } }}守护者如何工作
您需要告诉proguard要保留什么代码和要保留什么名称. Proguard会删除所有未使用的代码,并扰乱您不想保留的名称.
您不告诉proguard要删除什么,而是告诉proguard要保留什么.
总结以上是内存溢出为你收集整理的该库的Android Studio ConsumerProguardFiles不起作用全部内容,希望文章能够帮你解决该库的Android Studio ConsumerProguardFiles不起作用所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)