首页 文章

如何找出ProGuard Android无法解决的课程

提问于
浏览
1

在为我正在使用的所有库添加ProGuard规则后,我仍然收到此警告:

Warning: there were 14 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)

我知道我可以使用 -dontwarn 选项来摆脱这个警告,但因此我需要知道哪些包/类/接口无法解析 . Android不支持全局"-dontwarn" .

在日志文件中,我发现了很多Notes和Warnings,但它们似乎都与上述消息无关 .

1 回答

  • 2

    如果收到 Warning: there were X unresolved references to classes or interfaces ,则在构建日志中查找包含单词 Warning 的行,例如:

    Warning: com.package.Class1: can't find referenced class org.library.Class2
    

    像这样的行将告诉ProGuard正在尝试哪些类以及哪些类在输入jar中找不到 . 在上面的示例中,类 Class1 将引用库的 Class2 ,但在构建路径中找不到 Class2 .

    正如您所提到的,您可以简单地添加 -dontwarn <class regex> 来忽略这些警告,但理想情况下,您应该逐个检查它们以确保您的配置正确并且正确导入所有必需的依赖项 .

相关问题