com.google.android.gms.internal.zzhu:找不到引用的类android.security.NetworkSecurityPolicy

问题描述 投票:21回答:6

我试图使用ProGuard生成APK,但我得到这个错误而试图建立:

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),其中奥利弗·伦纳写道:

“所以基本上下一个谷歌库可能无法升级到最新版本,它也似乎需要compileSdk 23,以便能够使用的ProGuard无需修改(警告:com.google.android.gms.internal.zzhu:可以“找不到引用的类android.security.NetworkSecurityPolicy)“*

我更新了我的项目中使用SDK 23来编译,但没有解决问题。

贝娄,我包括我的build.gradle文件的某些部分:

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;
    }
}
android proguard
6个回答
25
投票

我有同样的问题。警告消息说:

如果你的代码工作正常,没有丢失的类,可以抑制与“-dontwarn”选项的警告。

因此,让我们采取了建议:

-dontwarn com.google.android.gms.internal.zzhu

对我来说,这个固定的问题。但是,如果由于某种原因,您的代码不无级工作正常,你可以做除了(未测试)是这样的:

-keep class com.google.android.gms.internal.** { *; }

请注意,您所需要的-dontwarn线两种方式。祝好运!


7
投票

对我来说,它看起来像这样实际上是由谷歌无意包括AdMob在播放服务Analytics(分析)8.1的依赖造成的:https://plus.google.com/+GoogleDevelopers/posts/HsSNWEQ6H4e

如果我排除play-services-ads模块build.gradle我没有得到与android.security.NetworkSecurityPolicy Proguard的错误,我的发布版本安装和运行没有任何问题(这是以前崩溃与java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity启动,而调试版本工作正常):

compile ('com.google.android.gms:play-services-analytics:8.1.0') {
    exclude module: 'play-services-ads'
}

在Proguard的规则,你还需要:

-dontwarn com.google.android.gms.ads.**

由于这个职位的详细信息(虽然它不引用建立崩溃可言,只是APK大小):https://medium.com/google-developer-experts/warning-for-google-analytics-users-44b0096084e2#.4b3egtbxh

下面是该项目我工作,其中包括承诺是解决这一问题的问题:https://github.com/OneBusAway/onebusaway-android/issues/342

编辑

用户报告说,这是在8.3解决了,这意味着你可以通过你的build.gradle的设置来解决此:

compile 'com.google.android.gms:play-services-analytics:8.3.0'

我还没有证实自己。


1
投票

我有这样一个类似的错误,当我最近升级我的戏服务的依赖性。看来,当你离开了更新对应的使用播放服务版本的火力依赖性发生。

这里是我的依赖关系的两个版本分别为:

依赖的错误版本

compile 'com.google.firebase:firebase-appindexing:10.0.1'
compile 'com.google.android.gms:play-services-maps:10.0.1'
compile 'com.google.android.gms:play-services-places:10.0.1'
compile 'com.google.android.gms:play-services-location:10.0.1'
compile 'com.google.firebase:firebase-auth:9.8.0'
compile 'com.google.firebase:firebase-database:9.8.0'
compile 'com.firebaseui:firebase-ui-database:1.0.1'
compile 'com.google.firebase:firebase-storage:9.8.0'

的依赖``工作版本

compile 'com.google.firebase:firebase-appindexing:10.0.1'
compile 'com.google.android.gms:play-services-maps:10.0.1'
compile 'com.google.android.gms:play-services-places:10.0.1'
compile 'com.google.android.gms:play-services-location:10.0.1'
compile 'com.google.firebase:firebase-auth:10.0.0'
compile 'com.google.firebase:firebase-database:10.0.0'
compile 'com.firebaseui:firebase-ui-database:1.0.1'
compile 'com.google.firebase:firebase-storage:10.0.0'

``谷歌似乎与火力的更新,这些天一起移动游戏服务更新。希望这样可以节省一些灵魂在那里。


1
投票

问题是当我更新的版本,我尝试所有的解决方案,但没有为me.Then我看到这个isuue #24109609和规则为亲卫队是对我的作品的工作。

-keepattributes Signature -keep class com.firebase.** { *; }
-keep class org.apache.** { *; }
-keepnames class com.fasterxml.jackson.** { *; }
-keepnames class javax.servlet.** { *; }
-keepnames class org.ietf.jgss.** { *; }
-dontwarn org.apache.** -dontwarn org.w3c.dom.**
-dontwarn android.support.v4.**
-dontwarn com.google.android.gms.**
-dontwarn com.google.firebase.**
-keep class * extends com.myCompany.package.flavor.Flavor { *; }
-keep class com.myCompany.** { *; }

0
投票

对我来说,我只是同步的所有我的项目的模块使用最近播放服务的图书馆,我能够使用包。

我在我的build.gradle使用(所有模块):

compile 'com.android.support:support-v4:23.0.1'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.google.android.gms:play-services:7.8.0'

我用compile 'com.google.android.gms:play-services:7.5.0'

希望这可以帮助别人。


-3
投票

对于我来说,通过更换工作

编译“com.google.android.gms:播放服务,appindexing:9.8.0”

有:

compile 'com.google.android.gms:play-services:10.0.0'
© www.soinside.com 2019 - 2024. All rights reserved.