Java ProGuard 警告:有 7 个未解析的程序类成员引用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27935058/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 05:19:48  来源:igfitidea点击:

ProGuard warnings: there were 7 unresolved references to program class members

javajarproguard

提问by Michael SM

ProGuard stops with a lot of warnings:

ProGuard 停止并发出大量警告:

Warning: there were 1221 unresolved references to classes or interfaces. You may need to add missing library jars or update their versions. If your code works fine without the missing classes, you can suppress the warnings with '-dontwarn' options. (http://proguard.sourceforge.net/manual/troubleshooting. html#unresolvedclass)

Warning: there were 37 instances of library classes depending on program classes. You must avoid such dependencies, since the program classes will be processed, while the library classes will remain unchanged. (http://proguard.sourceforge.net/manual/troubleshooting. html#dependency) Warning: there were 7 unresolved references to program class members. Your input classes appear to be inconsistent. You may need to recompile the code. (http://proguard.sourceforge.net/manual/troubleshooting. html#unresolvedprogramclassmember)

Error: Please correct the above warnings first.

警告:有 1221 个未解析的类或接口引用。您可能需要添加缺少的库 jar 或更新它们的版本。如果您的代码在没有丢失类的情况下运行良好,您可以使用“-dontwarn”选项抑制警告。(http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass

警告:根据程序类,有 37 个库类实例。您必须避免这种依赖性,因为程序类将被处理,而库类将保持不变。( http://proguard.sourceforge.net/manual/troubleshooting.html#dependency) 警告:有 7 个未解析的程序类成员引用。您的输入类似乎不一致。您可能需要重新编译代码。(http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedprogramclassmember)

错误:请先更正上述警告。

But my jar runs correctly. I am not quite familiar with proguard setting. Any suggestion?

但是我的 jar 运行正常。我对 proguard 设置不太熟悉。有什么建议吗?

回答by Elliott Frisch

I'm going to quote a very relevant part of your question (namely the answer).

我将引用您问题中非常相关的部分(即答案)。

Ifyour code works finewithout the missing classes, you can suppress the warningswith '-dontwarn' options

如果您的代码在没有丢失类的情况下运行良好,您可以使用“-dontwarn”选项抑制警告

So, run it with -dontwarnsince my jar runs correctly.

所以,运行它,-dontwarn因为我的 jar 运行正常。

Documented (per your question) herethere is also the option -libraryjarswhich you can use if you have external libraries you want to add.

此处记录(根据您的问题)还有一个选项-libraryjars,如果您有要添加的外部库,则可以使用该选项。

回答by Iamsomeone

The best thing to do here is adding the libraries in progyard configuration file. At the top of it, just after the input and output jar paths, put lines like this one, one for each library jar you use:

最好的办法是在 progyard 配置文件中添加库。在它的顶部,就在输入和输出 jar 路径之后,放置这样的行,为您使用的每个库 jar 放一个:

-libraryjars 'path/to/jar/file.jar'

This tells proguard to load the missing classes from the specified jars.

这告诉 proguard 从指定的 jars 加载缺少的类。

回答by EpicPandaForce

There are warnings above like

上面有警告,比如

Warning: class A: can't find referenced class B

For which you can either use -keep class com.package.** { *; }to prevent it from being obfuscated, or if you're sure that this is not a problem, you can use -dontwarn com.package.**.

您可以使用-keep class com.package.** { *; }它来防止它被混淆,或者如果您确定这不是问题,您可以使用-dontwarn com.package.**.