proguard - 找不到引用的类
所以,我正在尝试发布一些软件,但 Proguard 让我头疼。
当我尝试使用 proguard 导出时,我收到很多警告,即“找不到引用的类”
例如:
[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.
[
警告似乎与 simpleframework 相关,因此在我的 proguard 配置文件中我添加了以下内容
-libraryjars pathtoprojecttolibs\simple-xml-2.4.jar
: >pathtoprojecttolibs 是我的项目引用的 jar 的路径。
这没有什么区别。
如果 simpleframework 引用 javax 我可以告诉 proguard 也忽略它吗?
有什么想法吗?
So, I'm trying to release some software but Proguard is giving me a headache.
When I try to export using proguard I'm getting lots of warning ie "can't find referenced class"
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:
-libraryjars pathtoprojecttolibs\simple-xml-2.4.jar
Where pathtoprojecttolibs
is the path to jars which are referenced by my project.
This makes NO difference.
If simpleframework references javax can I tell proguard to ignore this too??
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
出现此错误的原因是您使用的库依赖于其他未真正使用的库,但 Proguard 正在寻找它们。
将 -dontwarn 行添加到 Android 项目中的 proguard-rules.pro 文件中以禁用此警告。
您可以在错误的堆栈跟踪中找到需要添加到 proguard-rules.pro 中的依赖项。
This error occurs because the libs you use depend on other libs which are not realy used, but Proguard is looking for them.
Add your -dontwarn lines to your proguard-rules.pro file in your Android project to disable this warnings.
You can find which dependencies you need to add to your proguard-rules.pro in the stacktrace of your error.
您应该将其包含在您的 Proguard 配置中:
You should include this in your Proguard config:
我的 Magic key 解决了我数小时的搜索问题:将其添加到 progruard-android.txt
My Magic key that solved my hours of searching: Add this to progruard-android.txt
唔。阅读该警告后,您尝试使用的库似乎依赖于 javax.xml.stream.events。我不认为命名空间实际上包含在 android 中。 (请参阅包索引)。
尝试在不使用 proguard 的情况下将其部署到模拟器,看看它是否有效。如果这个警告是准确的,我的猜测是不会。
Hmm. Reading that warning it would seem the library you are trying to use has a dependancy on javax.xml.stream.events. I don't think that namespace is actually included in android at all. (See Package Index).
Try deploying it to the emulator without using proguard and see if it works. My guess would be no if that warning is accurate.
我认为这是一个边缘情况,但就我而言,我必须完全擦除 Jenkins proguard 上的构建文件夹,尝试使用不再存在的旧代码 - 以防万一有人遇到同样的问题。
I think this is an edge case but in my case I had to completely wipe the build folder on my Jenkins proguard tried to work with old code which was not there any more - just in case anybody has the same issue.
就我而言,我没有更改任何内容,并且开始出现警告。问题在于 gradle 缓存损坏。查看我的其他答案。我分享这个是因为我花了 2 个小时才找到问题:]
In my case I haven't changed anything and warning started to show. The problem was with broken gradle caches. Check my other answer. I share with this because it took my 2 hours to find the problem :]
将此行添加到 gradle 脚本目录中的
proguard-rules.pro
文件中:其中
package.class.name
是附加了 jar 文件的类名的包名称。例如:
Add this line to your
proguard-rules.pro
file in the gradle scripts directory:where
package.class.name
is the package name with the class name of the jar file appended.For example:
代码中的
org.simpleframework.xml.stream.StreamReader
引用javax.xml.stream.events.XMLEvent
。后一个类是 Java 运行时 (rt.jar
) 的一部分,但不是 Android 运行时 (android.jar
) 的一部分,因此 ProGuard 会警告某些内容可能会被破坏。如果您确定您的应用程序无论如何都能工作,您可以指定org.simpleframework.xml.stream.StreamReader
in your code refers tojavax.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. If you're sure that your application works anyway, you can specify就我而言,根本原因是此处。您可以跳过这些警告:
原始答案在这里
In my case the root cause was here. Those warnings you can just skip with :
The original answer is here