簡體   English   中英

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,但是在嘗試構建時我遇到了這個錯誤:

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寫道:

“所以基本上下一個谷歌庫可能無法升級到最新版本。它似乎還需要compileSdk 23才能在不修改的情況下使用ProGuard(警告:com.google.android.gms.internal.zzhu:can找不到引用類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;
    }
}

我有同樣的問題。 警告信息說:

如果您的代碼在沒有缺少類的情況下正常工作,則可以使用“-dontwarn”選項來禁止警告。

那么我們來看看它的建議:

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

對我來說,這解決了這個問題。 但是,如果由於某種原因你的代碼在沒有類的情況下不能正常工作,你可以另外做這樣的事情(未經測試):

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

請注意,無論哪種方式,您都需要-dontwarn行。 祝好運!

對我來說,看起來這實際上是由谷歌在Play Services Analytics 8.1的依賴項中意外包含AdMob引起的: https//plus.google.com/+GoogleDevelopers/posts/HsSNWEQ6H4e

如果我在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'
}

在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'

我還沒有證實自己。

當我最近升級我的播放服務依賴時,我遇到了類似的錯誤。 當您省略更新與您使用的播放服務版本相對應的firebase依賴項時,似乎會發生這種情況。

以下是我的依賴項的兩個版本:

依賴項的錯誤版本

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'

``Google最近似乎將播放服務更新與firebase更新一起移動。 希望這能節省一些靈魂。

問題出現在我更新版本時,我嘗試所有的解決方案,但不適合我。然后我看到這個問題# 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.** { *; }

對我來說,我只是將項目的所有模塊同步到最近的游戲服務庫,然后我才能使用該軟件包。

我在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'

希望這有助於某人。

對我來說,它取代了

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

有:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM