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

你离开我真会死。 提交于 2019-11-29 03:01:27

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.

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. 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

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):

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

In Proguard rules you also need:

-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

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

EDIT

Users are reporting that this is resolved in 8.3, which means you could fix this by setting your build.gradle to:

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.

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. 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.

-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) :

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'

Hope this helps someone.

For me it work by replacing

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

with:

compile 'com.google.android.gms:play-services:10.0.0'
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!