自从我将 ADT 从 16 更新到 18(这要求 Proguard 从 4.6 更新到 4.8)以来,Proguard 的行为一直很奇怪(并且不一致?)。
最新的此类问题是当我尝试导出已签名(发布)的 APK 时,我收到以下错误:
Proguard returned with error code 1. See console
Warning: com.bta.LibProj2: can't find referenced class com.bta.R$string
Warning: com.bta.MyDlg1: can't find referenced class com.bta.R$string
Warning: com.bta.MyMenu: can't find referenced class com.bta.R$menu
Warning: com.bta.R: can't find referenced class com.bta.R$attr
Warning: com.bta.R: can't find referenced class com.bta.R$drawable
Warning: com.bta.R: can't find referenced class com.bta.R$menu
Warning: com.bta.R: can't find referenced class com.bta.R$string
Warning: com.bta.myapp.MyAppActivity$1: can't find referenced class com.bta.myapp.MyAppActivity
Warning: com.bta.myapp.MyAppActivity$ELicenseResponse: can't find referenced class com.bta.myapp.MyAppActivity
Warning: com.bta.myapp.MyAppActivity$MyLicenseCheckerCallback$1: can't find referenced class com.bta.myapp.MyAppActivity$MyLicenseCheckerCallback
Warning: com.bta.myapp.MyAppActivity$MyLicenseCheckerCallback$1: can't find referenced class com.bta.myapp.MyAppActivity
Warning: com.bta.myapp.R$array: can't find referenced class com.bta.myapp.R
Warning: com.bta.myapp.R$layout: can't find referenced class com.bta.myapp.R
Warning: com.bta.myapp.R$xml: can't find referenced class com.bta.myapp.R
Warning: there were 49 unresolved references to classes or interfaces.
You may need to specify additional library jars (using '-libraryjars').
java.io.IOException: Please correct the above warnings first.
at proguard.Initializer.execute(Initializer.java:321)
at proguard.ProGuard.initialize(ProGuard.java:212)
at proguard.ProGuard.execute(ProGuard.java:87)
at proguard.ProGuard.main(ProGuard.java:493)
我确实注意到了添加-libraryjars
proguard.cfg 的建议,但我以前从未需要这样做(而且我没有更改代码中的任何内容,我所做的只是将 Proguard 从 4.6 更新到 4.8)。这是否表明我的开发环境配置有问题?
此外,我检查了 Proguard 的疑难解答部分中的Can't find referenced class:它指的是忘记或忽略指定一个库-libraryjars
(我承认),但我从未指定任何库,它以前一直有效!发生了什么变化?
我的 proguard.cfg 文件顺便说一句以:
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
知道发生了什么吗?为什么 Proguard 开始让我这么难受?(我已经用它顺利滑行了一年多)我的系统配置中是否缺少一些基本的东西?
顺便说一句,我确实尝试通过在行中指定所有库来添加我一直在使用的库-libraryjars
,但 Proguard 的行为只会变得更糟:它会失败而不会给出我上面引用的任何错误日志。