简体   繁体   English

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

[英]com.google.android.gms.internal.zzhu: can't find referenced class android.security.NetworkSecurityPolicy

I tried to generate an apk using proguard, but I've got this error while trying to build: 我尝试使用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.

Recently, I upgraded my Android SDK Tools. 最近,我升级了我的Android SDK工具。 Before it, this project presented no problems with proguard. 在此之前,这个项目没有提出proguard的问题。 I found this post ( https://plus.google.com/+PaulBurke/posts/T3vmAnRP3q6 ) where Oliver Renner wrote: 我找到了这篇帖子( https://plus.google.com/+PaulBurke/posts/T3vmAnRP3q6 ),其中Oliver Renner写道:

"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)"* “所以基本上下一个谷歌库可能无法升级到最新版本。它似乎还需要compileSdk 23才能在不修改的情况下使用ProGuard(警告:com.google.android.gms.internal.zzhu:can找不到引用类android.security.NetworkSecurityPolicy)“*

I updated my project to compile using SDK 23, but the problem wasn't solved. 我更新了我的项目以使用SDK 23进行编译,但问题没有解决。

Bellow, I included some parts of my build.gradle file: 贝娄,我包含了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;
    }
}

I had this same problem. 我有同样的问题。 The warning message says: 警告信息说:

If your code works fine without the missing classes, you can suppress the warnings with '-dontwarn' options. 如果您的代码在没有缺少类的情况下正常工作,则可以使用“-dontwarn”选项来禁止警告。

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.** { *; }

Note that you'll need the -dontwarn line either way. 请注意,无论哪种方式,您都需要-dontwarn行。 Good luck! 祝好运!

For me, it looks like this was actually caused by Google accidentally including AdMob in the dependencies of Play Services Analytics 8.1: https://plus.google.com/+GoogleDevelopers/posts/HsSNWEQ6H4e 对我来说,看起来这实际上是由谷歌在Play Services Analytics 8.1的依赖项中意外包含AdMob引起的: https//plus.google.com/+GoogleDevelopers/posts/HsSNWEQ6H4e

If I exclude the play-services-ads module in build.gradle I don't get the Proguard error with android.security.NetworkSecurityPolicy , and my release build installs and runs without any problems (it was previously crashing on startup with java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity , while debug build was working fine): 如果我在build.gradle排除play-services-ads模块,我没有得到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'
}

In Proguard rules you also need: 在Proguard规则中,您还需要:

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

Thanks to this post for details (although it doesn't reference builds crashing at all, just APK size): https://medium.com/google-developer-experts/warning-for-google-analytics-users-44b0096084e2#.4b3egtbxh 感谢这篇文章的详细信息(虽然它没有引用构建崩溃,只有APK大小): https//medium.com/google-developer-experts/warning-for-google-analytics-users-44b0096084e2#。 4b3egtbxh

Here's the issue for the project I was working on, which includes the commit that resolved the issue: https://github.com/OneBusAway/onebusaway-android/issues/342 这是我正在处理的项目的问题,其中包括解决问题的提交: https//github.com/OneBusAway/onebusaway-android/issues/342

EDIT 编辑

Users are reporting that this is resolved in 8.3, which means you could fix this by setting your build.gradle to: 用户报告在8.3中已解决此问题,这意味着您可以通过将build.gradle设置为:

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

I have yet to confirm myself. 我还没有证实自己。

I had such a similar error when i was recently upgrading my play service dependency. 当我最近升级我的播放服务依赖时,我遇到了类似的错误。 It seems to occur when you leave out updating the firebase dependencies that correspond to the version of play services you use. 当您省略更新与您使用的播放服务版本相对应的firebase依赖项时,似乎会发生这种情况。

Here is what the two versions of my dependencies were: 以下是我的依赖项的两个版本:

Error version of dependencies 依赖项的错误版本

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'

Working version of dependencies `` 依赖项的工作版本``

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'

`` Google seems to move play service updates along with firebase updates these days. ``Google最近似乎将播放服务更新与firebase更新一起移动。 Hopes this saves a few souls out there. 希望这能节省一些灵魂。

The problem comes when I update the version, I try all the solutions but don't work for me.Then I see this isuue # 24109609 and the rule into pro-guard is works for me. 问题出现在我更新版本时,我尝试所有的解决方案,但不适合我。然后我看到这个问题# 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.** { *; }

For me I just synched all my project's modules to use a recent play services library and I was able to use the package. 对我来说,我只是将项目的所有模块同步到最近的游戏服务库,然后我才能使用该软件包。

what I use in my build.gradle (for all modules) : 我在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'

Before I was using compile 'com.google.android.gms:play-services:7.5.0' 在我使用compile 'com.google.android.gms:play-services:7.5.0'

Hope this helps someone. 希望这有助于某人。

For me it work by replacing 对我来说,它取代了

compile 'com.google.android.gms:play-services-appindexing:9.8.0' 编译'com.google.android.gms:play-services-appindexing:9.8.0'

with: 有:

 compile 'com.google.android.gms:play-services:10.0.0' 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ProGuard:找不到引用的类com.google.android.gms.R - ProGuard: can't find referenced class com.google.android.gms.R 保护Google Play服务7. +会导致com.google.android.gms.internal.zzig:找不到引用的方法'boolean isAttachedToWindow()' - Proguarding Google Play Services 7.+ results in com.google.android.gms.internal.zzig: can't find referenced method 'boolean isAttachedToWindow()' 找不到类'com.google.android.gms.location.internal.ParcelableGeofence',从方法glt.a引用 - Could not find class 'com.google.android.gms.location.internal.ParcelableGeofence', referenced from method glt.a 找不到[com / google / android / gms / internal / zzol]的普通超类 - Can't find common super class of [com/google/android/gms/internal/zzol] 找不到方法gls.a引用的类“ com.google.android.gms.location.internal.ParcelableGeofence” - Could not find class 'com.google.android.gms.location.internal.ParcelableGeofence', referenced from method gls.a 找不到方法glt.a引用的类'com.google.android.gms.location.internal.ParcelableGeofence - Could not find class 'com.google.android.gms.location.internal.ParcelableGeofence referenced from method glt.a Android:找不到方法glt.a所引用的类'com.google.android.gms.location.internal.ParcelableGeofence - Android: Could not find class 'com.google.android.gms.location.internal.ParcelableGeofence referenced from method glt.a ClassNotFoundException找不到类“ com.google.android.gms.common.internal.zzbq - ClassNotFoundException Didn't find class "com.google.android.gms.common.internal.zzbq 放置自动完成未找到类“ com.google.android.gms.common.internal.safeparcel.AbstractSafeParcelable” - Places AutoComplete Didn't find class “com.google.android.gms.common.internal.safeparcel.AbstractSafeParcelable” 某些设备出错 - 无法找到“com.google.android.gms.measurement.internal.zzz”类 - Error on some devices - couldn't find class 'com.google.android.gms.measurement.internal.zzz'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM