com.google.android.gms.internal.zzhu: 参照クラス android.security.NetworkSecurityPolicy が見つかりません 質問する

com.google.android.gms.internal.zzhu: 参照クラス 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 Tools をアップグレードしました。それ以前は、このプロジェクトは Proguard で問題はありませんでした。この投稿を見つけました (https://plus.google.com/+PaulBurke/posts/T3vmAnRP3q6)でオリバー・レナーはこう書いています。

「つまり、基本的に最新バージョンにアップグレードされない可能性のある次の Google ライブラリです。また、ProGuard を変更せずに使用できるようにするには、compileSdk 23 が必要なようです (警告: 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;
    }
}

ベストアンサー1

私も同じ問題を抱えていました。警告メッセージには次のように書かれています:

不足しているクラスがなくてもコードが正常に動作する場合は、「-dontwarn」オプションを使用して警告を抑制できます。

それでは、その提案を見てみましょう:

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

私の場合、これで問題は解決しました。ただし、何らかの理由でクラスなしでコードが正常に動作しない場合は、さらに次のような操作を行うことができます (テストされていません)。

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

いずれにしても、このラインが必要になることに注意してください-dontwarn。頑張ってください!

おすすめ記事