Android-Studio-1.2.RC 关于 Square 的 Okio 库参考的 Proguard 警告
Android-Studio-1.2.RC Proguard warnings on Square's Okio library reference
与 Android 工作室:1.2.RC
我在 .gradle 中启用了混淆器:
```
minifyEnabled=true
and added these rules to my proguard-rules.pro:
-dontwarn com.squareup.**
-dontwarn okio.**
and added these lint rules to my .gradle file:
warningsAsErrors false
abortOnError false
disable 'InvalidPackage'
```
但是当我尝试在调试模式下 运行 应用程序时,我仍然收到这些警告:
```
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
```
这太奇怪了,因为我也将这些 rules/options 添加到我所有依赖 OkHttp/Picasso 的库模块中,我不知道哪里出了问题,也许这是一个 Android工作室错误?有人知道这个问题的线索吗?
我在 github 上开了一个 issue。
您已禁用
的警告
-dontwarn com.squareup.**
-dontwarn okio.**
但是包裹呢(如您发布的日志中所示)
-dontwarn org.codehaus
-dontwarn java.nio
无论哪种方式,忽略警告都不是一个好方法。
尽量避免这些 类 像这样被缩小:
-keep public class org.codehaus.**
-keep public class java.nio.**
天哪,我忘了为我的调试版本指定混淆文件,添加 'proguardFiles' 规则可以解决问题:
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
debuggable false
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
applicationIdSuffix ".debug"
}
}
其中一个时刻,您苦苦寻找钥匙,结果它就在您的口袋里。
与 Android 工作室:1.2.RC
我在 .gradle 中启用了混淆器: ```
minifyEnabled=true
and added these rules to my proguard-rules.pro:
-dontwarn com.squareup.**
-dontwarn okio.**
and added these lint rules to my .gradle file:
warningsAsErrors false
abortOnError false
disable 'InvalidPackage'
```
但是当我尝试在调试模式下 运行 应用程序时,我仍然收到这些警告:
```
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
```
这太奇怪了,因为我也将这些 rules/options 添加到我所有依赖 OkHttp/Picasso 的库模块中,我不知道哪里出了问题,也许这是一个 Android工作室错误?有人知道这个问题的线索吗?
我在 github 上开了一个 issue。
您已禁用
的警告-dontwarn com.squareup.**
-dontwarn okio.**
但是包裹呢(如您发布的日志中所示)
-dontwarn org.codehaus
-dontwarn java.nio
无论哪种方式,忽略警告都不是一个好方法。
尽量避免这些 类 像这样被缩小:
-keep public class org.codehaus.**
-keep public class java.nio.**
天哪,我忘了为我的调试版本指定混淆文件,添加 'proguardFiles' 规则可以解决问题:
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
debuggable false
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
applicationIdSuffix ".debug"
}
}
其中一个时刻,您苦苦寻找钥匙,结果它就在您的口袋里。