Square 的 Okio 库引用中的 Android-Studio-1.2.RC Proguard 警告

标签 android android-studio proguard square okio

使用 Android Studio:1.2.RC

我在 .gradle 中启用了混淆器: ```

minifyEnabled=true

并将这些规则添加到我的 proguard-rules.pro 中:

-dontwarn com.squareup.**
-dontwarn okio.**

并将这些 lint 规则添加到我的 .gradle 文件中:

warningsAsErrors false
abortOnError false
disable 'InvalidPackage'

```

但是当我尝试在 Debug模式下运行应用程序时,我仍然收到这些警告:

```
Warning: okio.DeflaterSink: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
Warning: okio.Okio: can't find referenced class java.nio.file.Files
Warning: okio.Okio: can't find referenced class java.nio.file.Files
Warning: okio.Okio: can't find referenced class java.nio.file.Files
Warning: okio.Okio: can't find referenced class java.nio.file.Path
Warning: okio.Okio: can't find referenced class java.nio.file.OpenOption
Warning: okio.Okio: can't find referenced class java.nio.file.Path
Warning: okio.Okio: can't find referenced class java.nio.file.OpenOption
Warning: okio.Okio: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
Warning: okio.Okio: can't find referenced class java.nio.file.Path
Warning: okio.Okio: can't find referenced class java.nio.file.OpenOption
Warning: okio.Okio: can't find referenced class java.nio.file.Path
Warning: okio.Okio: can't find referenced class java.nio.file.OpenOption
Warning: okio.Okio: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
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)
:app:proguardDebug FAILED

```

这太奇怪了,因为我还将这些规则/选项添加到我所有依赖于 OkHttp/Picasso 的库模块中,我不知道哪里出了问题,也许这是一个 Android Studio 错误?有没有人知道这个问题的线索?

我打开了一个issue在 github 上。

最佳答案

您已为

禁用警告
-dontwarn com.squareup.**
-dontwarn okio.**

但是包呢(如您发布的日志中所示)

-dontwarn org.codehaus
-dontwarn java.nio

无论哪种方式,忽略警告都不是一个好方法。

尽量避免像这样缩小这些类:

-keep public class org.codehaus.**
-keep public class java.nio.**

关于Square 的 Okio 库引用中的 Android-Studio-1.2.RC Proguard 警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29886882/

相关文章:

java - 从手机运行时应用程序崩溃,但从计算机启动时运行正常

android - 代码混淆后数据绑定(bind)无法正常工作

android - Proguard 没有删除日志调用

android - ProGuard 破坏了我的 Androidplot 布局

android - Google Chromecast接收器无法同时播放音频

android从当前位置查找特定方向的点的纬度经度

android - Ant 使用ADT的 "build performance improvements"

android - 是否可以在Android上控制png编码的图像质量?

android - 在 Android Studio 中失败 [INSTALL_FAILED_OLDER_SDK]?

android - Android java.lang.IllegalArgumentException : Unable to read class file