com.google.android.gms.internal.zzhu:找不到引用的类android.security.NetworkSecurityPolicy [英] com.google.android.gms.internal.zzhu: can't find referenced class android.security.NetworkSecurityPolicy
问题描述
我尝试使用proguard生成apk,但是在尝试构建时遇到此错误:
I tried to generate an apk using proguard, but I've got this error while trying to build:
Warning: com.google.android.gms.internal.zzhu: can't find referenced class android.security.NetworkSecurityPolicy
Warning: there were 3 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:proguardRelease FAILED
Error:Execution failed for task ':app:proguardRelease'.
java.io.IOException: Please correct the above warnings first.
最近,我升级了Android SDK工具.在此之前,该项目对proguard而言没有任何问题.我发现了这篇文章( https://plus.google.com/+PaulBurke/posts/T3vmAnRP3q6 ),其中奥利弗·雷纳(Oliver Renner)写道:
Recently, I upgraded my Android SDK Tools. Before it, this project presented no problems with proguard. I found this post (https://plus.google.com/+PaulBurke/posts/T3vmAnRP3q6) where Oliver Renner wrote:
"因此,基本上是下一个可能不会升级到最新版本的Google库.它似乎还需要compileSdk 23才能不经修改即可使用ProGuard(警告:com.google.android.gms.internal. zzhu:找不到引用的类android.security.NetworkSecurityPolicy)"*
"So basically the next Google library that may not be upgraded to the latest version. It also seems to require compileSdk 23 in order to be able to use ProGuard without modifications (Warning: com.google.android.gms.internal.zzhu: can't find referenced class android.security.NetworkSecurityPolicy)"*
我更新了项目以使用SDK 23进行编译,但问题仍未解决.
I updated my project to compile using SDK 23, but the problem wasn't solved.
同胞,我包括了build.gradle文件的某些部分:
Bellow, I included some parts of my build.gradle file:
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "com.sample.sample"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0.0"
}
.
.
.
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.google.android.gms:play-services:+'
compile 'com.android.support:design:23.0.0'
compile('com.crashlytics.sdk.android:crashlytics:2.5.0@aar') {
transitive = true;
}
}
推荐答案
我遇到了同样的问题.警告消息显示:
I had this same problem. The warning message says:
如果您的代码在没有缺少类的情况下运行良好,则可以取消 带有"-dontwarn"选项的警告.
If your code works fine without the missing classes, you can suppress the warnings with '-dontwarn' options.
因此,让我们接受它的建议:
So let's take its suggestion:
-dontwarn com.google.android.gms.internal.zzhu
对我来说,这解决了这个问题.但是,如果由于某种原因您的代码在没有该类的情况下无法正常工作,那么您可以另外做类似的事情(未经测试):
For me, this fixed the issue. However, if for some reason your code does NOT work fine without the class, you can do something like this in addition (not tested):
-keep class com.google.android.gms.internal.** { *; }
请注意,您都需要-dontwarn
行.祝你好运!
Note that you'll need the -dontwarn
line either way. Good luck!
这篇关于com.google.android.gms.internal.zzhu:找不到引用的类android.security.NetworkSecurityPolicy的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!