Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
393 views
in Technique[技术] by (71.8m points)

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

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. Before it, this project presented no problems with proguard. I found this post (https://plus.google.com/+PaulBurke/posts/T3vmAnRP3q6) where Oliver Renner wrote:

"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)"*

I updated my project to compile using SDK 23, but the problem wasn't solved.

Bellow, I included some parts of my build.gradle file:

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;
    }
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...