为什么开始使用-libraryjars时,我从来没有需要过呢? [英] Why start using -libraryjars when I never needed it before?

查看:2705
本文介绍了为什么开始使用-libraryjars时,我从来没有需要过呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因为我更新了ADT 16日至18(其中授权Proguard的更新,从4.6到4.8),Proguard的已形迹十分古怪(​​和反复无常?)。

Since I updated ADT from 16 to 18 (which mandated Proguard update from 4.6 to 4.8), Proguard has been acting very weirdly (and inconsistently?).

最近这样的问题是,当我尝试导出一个签名(释放)APK,我收到以下错误:

The latest such problem is when I try to export a signed (release) APK, I receive the following errors:

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)

我没注意到的建议,加入proguard.cfg -libraryjars ,但我从来没有需要之前做到这一点(我没有在我的$ C改变什么$ C,我所做的就是更新Proguard的从4.6到4.8)。这是否意味着一些错误的,我开发环境配置?

I did notice the recommendation to add -libraryjars in proguard.cfg, but I never needed to do this before (and I didn't change anything in my code, all I did was updating Proguard from 4.6 to 4.8). Does this suggest something wrong in my development environment configuration?

另外,我检查Proguard的的故障排除部分找不到引用的类:它是指遗忘或忽略指定通过 -libraryjars (这点我承认)图书馆,但我从来没有指定任何库,它的总是的工作过!是什么改变了?

Also, I checked Proguard's Troubleshooting section for Can't find referenced class: It refers to forgetting or ignoring to specify a library via -libraryjars (which I admit), but I never specified any library and it always worked before! What changed?

我的proguard.cfg文件顺便说一句开头:

My proguard.cfg file BTW starts with:

-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*

任何想法是怎么回事?为什么Proguard的开始给我这么辛苦? (我优哉非常顺利与它一年多了)有什么根本性的我很想念我的系统配置?

Any idea what's going on? Why did Proguard start giving me such hard time? (I coasted very smoothly with it for over a year now) Is there something fundamental I am missing in my system configuration?

顺便说一句,我也尝试通过 -libraryjars 行指定所有这些加我一直在使用的库,但Proguard的行为​​只得到了糟糕:它会失败,而不提供任何错误的日志我引用上面。

BTW, I did try to add the libraries I have been using by specifying all of them in -libraryjars lines, but Proguard's behavior only got worse: It would fail without giving any of the error log that I quoted above.

推荐答案

问题解决了。 在这里这么多的寻找线索后,我终于找到这暗示通过没有其他比Proguard的的开发者自己:

Problem solved. After much search for clues here in SO, I finally found this hint by no other than Proguard's developer himself:

-dontwarn scala.**

我没有使用任何包含斯卡拉,我不知道是什么Scala是。但是,这给了我放置的想法 -dontwarn 我自己的应用程序包

-dontwarn com.bta.**

这并获得成功。

有关记录,搜索短语,使我找到这个提示是:<一href="http://stackoverflow.com/search?q=proguard%20admob%20%22can%27t%20find%20referenced%20class%22&submit=search">proguard AdMob的找不到引用的类。

For the record, the search phrase that led me to finding this hint was: proguard admob "can't find referenced class".

P.S。 Proguard的的建议您可能需要指定其他的jar包(用-libraryjars')甚至没有在正确的方向...

P.S. Proguard's suggestion You may need to specify additional library jars (using '-libraryjars') wasn't even in the right direction...

更新: -dontwarn com.bta ** 允许生产签署APK,它一旦崩溃,我试图启动它。有:

UPDATE: While -dontwarn com.bta.** allowed producing a signed APK, it crashed as soon as I tried to launch it with:

ClassNotFoundException: com.bta.myapp.MyAppActivity in loader dalvik.system.PathClassLoader[/data/app/com.bta.myapp.myapp-1.apk]. 

什么是一场噩梦。

What a nightmare.

更新2: -dontwarn com.bta ** 原来是太包容性。我把它改为:

UPDATE 2: -dontwarn com.bta.** turned out to be way too inclusive. I changed it to:

-dontwarn com.bta.myapp.MyAppActivity.R**

和现在一切运行良好,没有发生任何事故。 什么是一场噩梦。

And now everything runs well without incident. What a nightmare.

浪费了太多的时间调试,都应该非常的工具后的保存的我的时候,我发现了问题的根源。 这是在Android SDK工具 。它被记录为已解决了R17,但是我现在用的是最新的今天(2012年6月18日)和一直没有得到解决!(见注释24)。 评论25 还介绍,让我现在就着手解决方法我的实际发展。

After wasting way too much time on debugging the very tools that are supposed to save me time, I discovered the source of the problem. It's a bug in the Android SDK tools. It is documented as have been solved in r17, but I am using the latest of today (June 18 2012) and it hasn't been solved! (see comment 24). Comment 25 also describes the workaround that allows me now to proceed with my actual development.

错误是事实,生活在复杂的系统。但事实上,无论Proguard的,也不是构建工具,饲料投入Proguard的可以提供任何有用的错误消息(实际上他们却反其道而行之),表明事情是在Android开发工具的recommended由谷歌

Bugs are fact of life in complex systems. But the fact that neither Proguard nor the build tools that feed input to Proguard could provide any helpful error message (in fact they did exactly the opposite), suggests something is broken in the "methodology" of the Android development tools recommended by Google.

这篇关于为什么开始使用-libraryjars时,我从来没有需要过呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆