简体   繁体   English

proguard 地狱 - 找不到引用的类

[英]proguard hell - can't find referenced class

So, I'm TRYING to release some software but Proguard is giving me a headache.所以,我发布一些软件,但Proguard的是让我头疼。

When I try to export using proguard I'm getting lots of warning ie "can't find referenced class"当我尝试使用 proguard 导出时,我收到很多警告,即“找不到引用的类”

For example:例如:

[2011-08-07 17:44:37 - GAME] Warning: org.simpleframework.xml.stream.StreamReader: can't find referenced class javax.xml.stream.events.XMLEvent
[2011-08-07 17:44:37 - GAME] Warning: there were 52 unresolved references to classes or interfaces.
[2011-08-07 17:44:37 - GAME]          You may need to specify additional library jars (using '-libraryjars'),
[2011-08-07 17:44:37 - GAME]          or perhaps the '-dontskipnonpubliclibraryclasses' option.
[2011-08-07 17:44:37 - GAME] java.io.IOException: Please correct the above warnings first.
[ 

The warnings seem to related to simpleframework, so in my proguard config file I've added the following:这些警告似乎与 simpleframework 相关,因此在我的 proguard 配置文件中,我添加了以下内容:

-libraryjars pathtoprojecttolibs\simple-xml-2.4.jar

Where pathtoprojecttolibs is the path to jars which are referenced by my project.其中pathtoprojecttolibs是我的项目引用的 jar 的路径。

This makes NO difference.这没什么区别。

If simpleframework references javax can I tell proguard to ignore this too??如果 simpleframework 引用 javax,我可以告诉 proguard 也忽略它吗??

Any ideas?有任何想法吗?

org.simpleframework.xml.stream.StreamReader in your code refers to javax.xml.stream.events.XMLEvent .代码中的org.simpleframework.xml.stream.StreamReader指的是javax.xml.stream.events.XMLEvent The latter class is part of the Java runtime ( rt.jar ) but not part of the Android runtime ( android.jar ), so ProGuard warns that something might be broken.后一个类是 Java 运行时 ( rt.jar ) 的一部分,但不是 Android 运行时 ( android.jar ) 的一部分,因此 ProGuard 会警告某些内容可能已损坏。 If you're sure that your application works anyway, you can specify如果您确定您的应用程序无论如何都可以工作,则可以指定

-dontwarn javax.xml.stream.events.**

ProGuard hell? ProGuard 地狱?

In my case the root cause was here .就我而言,根本原因就在这里 Those warnings you can just skip with :您可以跳过这些警告:

-dontwarn org.simpleframework.xml.stream.**

The original answer is here原答案在这里

This error occurs because the libs you use depend on other libs which are not realy used, but Proguard is looking for them.出现此错误是因为您使用的库依赖于其他未真正使用的库,但 Proguard 正在寻找它们。
Add your -dontwarn lines to your proguard-rules.pro file in your Android project to disable this warnings.-dontwarn行添加到 Android 项目中的proguard-rules.pro文件以禁用此警告。

在此处输入图片说明

You can find which dependencies you need to add to your proguard-rules.pro in the stacktrace of your error.您可以在错误的堆栈跟踪中找到需要添加到 proguard-rules.pro 中的依赖项。

我的魔法钥匙解决了我的搜索时间:将此添加到 progruard-android.txt

-dontskipnonpubliclibraryclassmembers

您应该将其包含在您的 Proguard 配置中:

-dontskipnonpubliclibraryclasses

我认为这是一个边缘情况,但在我的情况下,我必须完全擦除我的 Jenkins proguard 上的构建文件夹,尝试使用不再存在的旧代码 - 以防万一有人遇到同样的问题。

In my case I haven't changed anything and warning started to show.在我的情况下,我没有改变任何东西,警告开始显示。 The problem was with broken gradle caches.问题在于损坏的 gradle 缓存。 Check my other answer .检查我的另一个答案 I share with this because it took my 2 hours to find the problem :]我与此分享,因为我花了 2 个小时才找到问题:]

Add this line to your proguard-rules.pro file in the gradle scripts directory:将此行添加到 gradle 脚本目录中的proguard-rules.pro文件中:

-dontwarn package.class.name.**

where package.class.name is the package name with the class name of the jar file appended.其中package.class.name是附加了 jar 文件的类名的包名。

For example:例如:

-dontwarn com.myexternalclass.utils.**

Hmm.唔。 Reading that warning it would seem the library you are trying to use has a dependancy on javax.xml.stream.events.阅读该警告似乎您尝试使用的库依赖于 javax.xml.stream.events。 I don't think that namespace is actually included in android at all.我认为命名空间实际上根本没有包含在 android 中。 (See Package Index ). (见包裹索引)。

Try deploying it to the emulator without using proguard and see if it works.尝试在不使用 proguard 的情况下将其部署到模拟器,看看它是否有效。 My guess would be no if that warning is accurate.如果那个警告是准确的,我的猜测是不会的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM