Reg*_*kie 14 android proguard adt
自从我将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)
Run Code Online (Sandbox Code Playgroud)
我确实注意到了-libraryjars在proguard.cfg中添加的建议,但我之前从未需要这样做(我的代码中没有更改任何内容,我所做的只是将Proguard从4.6更新到4.8).这是否表明我的开发环境配置有问题?
此外,我检查了Proguard的故障排除部分找不到引用的类:它指的是忘记或忽略指定库-libraryjars(我承认),但我从未指定任何库,它始终有效!改变了什么?
我的proguard.cfg文件BTW以:
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
Run Code Online (Sandbox Code Playgroud)
知道发生了什么事吗?Proguard为什么开始给我这么艰难的时间?(我用它已经用了一年多的时间非常顺利)我的系统配置中是否有一些基本的东西?
顺便说一句,我确实尝试通过在行中指定所有库来添加我一直使用的库-libraryjars,但Proguard的行为只会变得更糟:如果没有给出我上面引用的任何错误日志,它将会失败.
Reg*_*kie 15
问题解决了.在SO搜索线索之后,我终于发现了Proguard开发人员自己的暗示:
-dontwarn scala.**
Run Code Online (Sandbox Code Playgroud)
我没有使用任何包含"scala"的内容,我不知道scala是什么.但这给了我一个-dontwarn放在我自己的应用程序包上的想法:
-dontwarn com.bta.**
Run Code Online (Sandbox Code Playgroud)
这就是诀窍.
为了记录,导致我找到这个提示的搜索短语是:proguard admob"找不到引用的类".
PS Proguard的建议You may need to specify additional library jars (using '-libraryjars')甚至没有朝着正确的方向发展......
更新:虽然-dontwarn com.bta.**允许生成签名的APK,但一旦我尝试使用以下命令启动它就会崩溃:
ClassNotFoundException: com.bta.myapp.MyAppActivity in loader dalvik.system.PathClassLoader[/data/app/com.bta.myapp.myapp-1.apk].
Run Code Online (Sandbox Code Playgroud)
什么样的恶梦.
更新2: -dontwarn com.bta.**结果太包容了.我改成了:
-dontwarn com.bta.myapp.MyAppActivity.R**
Run Code Online (Sandbox Code Playgroud)
现在一切顺利,没有发生任何事故.
什么样的恶梦.
在浪费了太多时间调试那些本来可以节省时间的工具之后,我发现了问题的根源.这是Android SDK工具中的一个错误.据记载已在r17中解决,但我使用的是今天(2012年6月18日)的最新版本,但尚未解决!(见评论24).评论25还描述了允许我现在继续进行实际开发的变通方法.
错误是复杂系统中的事实.但事实上,Proguard和为Proguard提供输入的构建工具都无法提供任何有用的错误信息(实际上它们恰恰相反),这表明Google推荐的Android开发工具的"方法论"中有些内容被打破.
| 归档时间: |
|
| 查看次数: |
5495 次 |
| 最近记录: |