proguard - 找不到引用的类

发布于 2024-11-28 17:46:24 字数 941 浏览 1 评论 0原文

所以,我正在尝试发布一些软件,但 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

破晓 2024-12-05 17:46:25

出现此错误的原因是您使用的库依赖于其他未真正使用的库,但 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.

enter image description here

You can find which dependencies you need to add to your proguard-rules.pro in the stacktrace of your error.

怼怹恏 2024-12-05 17:46:25

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

-dontskipnonpubliclibraryclasses

You should include this in your Proguard config:

-dontskipnonpubliclibraryclasses
久光 2024-12-05 17:46:25

我的 Magic key 解决了我数小时的搜索问题:将其添加到 progruard-android.txt

-dontskipnonpubliclibraryclassmembers

My Magic key that solved my hours of searching: Add this to progruard-android.txt

-dontskipnonpubliclibraryclassmembers
染火枫林 2024-12-05 17:46:25

唔。阅读该警告后,您尝试使用的库似乎依赖于 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.

短暂陪伴 2024-12-05 17:46:25

我认为这是一个边缘情况,但就我而言,我必须完全擦除 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.

与风相奔跑 2024-12-05 17:46:25

就我而言,我没有更改任何内容,并且开始出现警告。问题在于 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 :]

挽清梦 2024-12-05 17:46:25

将此行添加到 gradle 脚本目录中的 proguard-rules.pro 文件中:

-dontwarn package.class.name.**

其中 package.class.name 是附加了 jar 文件的类名的包名称。

例如:

-dontwarn com.myexternalclass.utils.**

Add this line to your proguard-rules.pro file in the gradle scripts directory:

-dontwarn package.class.name.**

where package.class.name is the package name with the class name of the jar file appended.

For example:

-dontwarn com.myexternalclass.utils.**
王权女流氓 2024-12-05 17:46:24

代码中的 org.simpleframework.xml.stream.StreamReader 引用 javax.xml.stream.events.XMLEvent。后一个类是 Java 运行时 (rt.jar) 的一部分,但不是 Android 运行时 (android.jar) 的一部分,因此 ProGuard 会警告某些内容可能会被破坏。如果您确定您的应用程序无论如何都能工作,您可以指定

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

org.simpleframework.xml.stream.StreamReader in your code refers to 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. If you're sure that your application works anyway, you can specify

-dontwarn javax.xml.stream.events.**
南薇 2024-12-05 17:46:24

就我而言,根本原因是此处。您可以跳过这些警告:

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

原始答案在这里

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文