web-dev-qa-db-ja.com

プロガードとエラー

私はこのプロガードファイルを使用します。

 -dontskipnonpubliclibraryclasses
 -dontskipnonpubliclibraryclassmembers

 !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*
 -optimizationpasses 10
 -allowaccessmodification
 -mergeinterfacesaggressively
 -overloadaggressively

 -assumenosideeffects class Android.util.Log {
*;
 }

-keep public class * extends Android.app.Activity
-keep public class * extends Android.app.Application
-keep public class * extends Android.app.Service
-keep public class * extends Android.content.BroadcastReceiver
-keep public class * extends Android.content.ContentProvider
-keep public class * extends Android.app.backup.BackupAgent
-keep public class * extends Android.preference.Preference
-keep public class * extends Android.support.v4.app.Fragment
-keep public class * extends Android.support.v4.app.DialogFragment
-keep public class * extends com.actionbarsherlock.app.SherlockListFragment
-keep public class * extends com.actionbarsherlock.app.SherlockFragment
-keep public class * extends com.actionbarsherlock.app.SherlockFragmentActivity
-keep public class * extends Android.app.Fragment
-keep public class com.Android.vending.licensing.ILicensingService
-keep public class org.jsoup.** {
public *;
}

-keep public class * extends Android.view.View {
 public <init>(Android.content.Context);
 public <init>(Android.content.Context, Android.util.AttributeSet);
 public <init>(Android.content.Context, Android.util.AttributeSet, int);
 public void set*(...);
}

-keepclasseswithmembers class * {
 public <init>(Android.content.Context, Android.util.AttributeSet);
}

-keepclasseswithmembers class * {
 public <init>(Android.content.Context, Android.util.AttributeSet, int);
}

-keepclassmembers class * extends Android.app.Activity {
 public void *(Android.view.View);
}

-keepclassmembers enum * {
 public static **[] values();
 public static ** valueOf(Java.lang.String);
}

-keep class * implements Android.os.Parcelable {
 public static final Android.os.Parcelable$Creator *;
}

-keepclassmembers class **.R$* {
 public static <fields>;
}

-keep class Android.support.v4.app.** { *; }
-keep interface Android.support.v4.app.** { *; }
-keep class com.actionbarsherlock.** { *; }
-keep interface com.actionbarsherlock.** { *; }

-keep class com.google.ads.** {*;}
-keep class com.google.ads.internal.** {*;}
-keep class com.google.ads.mediation.** {*;}
-keep class com.google.ads.mediation.adfonic.** {*;}
-keep class com.google.ads.mediation.admob.** {*;}
-keep class com.google.ads.mediation.adfonic.util.** {*;}
-keep class com.google.ads.mediation.customevent.** {*;}
-keep class com.google.ads.searchads.** {*;}
-keep class com.google.ads.util.** {*;}

-dontwarn Android.support.**
-dontwarn com.google.ads.**

しかし、コードを更新すると、次のエラーが発生します。

Warning:com.google.Android.gms.internal.zzw$zza: can't find superclass or interface org.Apache.http.client.methods.HttpEntityEnclosingRequestBase
Warning:com.google.Android.gms.analytics.internal.zzam: can't find referenced class org.Apache.http.NameValuePair
Warning:com.google.Android.gms.analytics.internal.zzam: can't find referenced class org.Apache.http.client.utils.URLEncodedUtils
Warning:com.google.Android.gms.analytics.internal.zzam: can't find referenced class org.Apache.http.NameValuePair
Warning:com.google.Android.gms.analytics.internal.zzj: can't find referenced class org.Apache.http.NameValuePair
Warning:com.google.Android.gms.analytics.internal.zzj: can't find referenced class org.Apache.http.client.utils.URLEncodedUtils
Warning:com.google.Android.gms.analytics.internal.zzj: can't find referenced class org.Apache.http.NameValuePair
Warning:com.google.Android.gms.internal.zzac: can't find referenced class Android.net.http.AndroidHttpClient
Warning:com.google.Android.gms.internal.zzqt: can't find referenced class org.Apache.http.HttpEntity
Warning:com.google.Android.gms.internal.zzqt: can't find referenced class org.Apache.http.HttpResponse
Warning:com.google.Android.gms.internal.zzqt: can't find referenced class org.Apache.http.StatusLine
Warning:com.google.Android.gms.internal.zzqt: can't find referenced class org.Apache.http.client.HttpClient
Warning:com.google.Android.gms.internal.zzqt: can't find referenced class org.Apache.http.client.methods.HttpGet
Warning:com.google.Android.gms.internal.zzqt: can't find referenced class org.Apache.http.conn.ClientConnectionManager
Warning:com.google.Android.gms.internal.zzqt: can't find referenced class org.Apache.http.impl.client.DefaultHttpClient
Warning:com.google.Android.gms.internal.zzqt: can't find referenced class org.Apache.http.params.BasicHttpParams
Warning:com.google.Android.gms.internal.zzqt: can't find referenced class org.Apache.http.client.methods.HttpGet
Warning:com.google.Android.gms.internal.zzqt: can't find referenced class org.Apache.http.impl.client.DefaultHttpClient
Warning:com.google.Android.gms.internal.zzqt: can't find referenced class org.Apache.http.params.BasicHttpParams
Warning:com.google.Android.gms.internal.zzqt: can't find referenced class org.Apache.http.HttpEntity
Warning:com.google.Android.gms.internal.zzqt: can't find referenced class org.Apache.http.HttpResponse
Warning:com.google.Android.gms.internal.zzqt: can't find referenced class org.Apache.http.StatusLine
Warning:com.google.Android.gms.internal.zzqt: can't find referenced class org.Apache.http.client.HttpClient
Warning:com.google.Android.gms.internal.zzqt: can't find referenced class org.Apache.http.conn.ClientConnectionManager
Warning:com.google.Android.gms.internal.zzqt: can't find referenced class org.Apache.http.client.HttpClient
Warning:com.google.Android.gms.internal.zzqt: can't find referenced class org.Apache.http.HttpResponse
Warning:com.google.Android.gms.internal.zzqt: can't find referenced class org.Apache.http.client.HttpClient
Warning:com.google.Android.gms.internal.zzt: can't find referenced class org.Apache.http.Header
Warning:com.google.Android.gms.internal.zzt: can't find referenced class org.Apache.http.HttpEntity
Warning:com.google.Android.gms.internal.zzt: can't find referenced class org.Apache.http.HttpResponse
Warning:com.google.Android.gms.internal.zzt: can't find referenced class org.Apache.http.StatusLine
Warning:com.google.Android.gms.internal.zzt: can't find referenced class org.Apache.http.impl.cookie.DateUtils
Warning:com.google.Android.gms.internal.zzt: can't find referenced class org.Apache.http.Header
Warning:com.google.Android.gms.internal.zzt: can't find referenced class org.Apache.http.HttpEntity
Warning:com.google.Android.gms.internal.zzt: can't find referenced class org.Apache.http.HttpResponse
Warning:com.google.Android.gms.internal.zzt: can't find referenced class org.Apache.http.StatusLine
Warning:com.google.Android.gms.internal.zzt: can't find referenced class org.Apache.http.HttpEntity
Warning:com.google.Android.gms.internal.zzt: can't find referenced class org.Apache.http.Header
Warning:com.google.Android.gms.internal.zzw: can't find referenced class org.Apache.http.client.HttpClient
Warning:com.google.Android.gms.internal.zzw: can't find referenced class org.Apache.http.client.methods.HttpDelete
Warning:com.google.Android.gms.internal.zzw: can't find referenced class org.Apache.http.client.methods.HttpEntityEnclosingRequestBase
Warning:com.google.Android.gms.internal.zzw: can't find referenced class org.Apache.http.client.methods.HttpGet
Warning:com.google.Android.gms.internal.zzw: can't find referenced class org.Apache.http.client.methods.HttpHead
Warning:com.google.Android.gms.internal.zzw: can't find referenced class org.Apache.http.client.methods.HttpOptions
Warning:com.google.Android.gms.internal.zzw: can't find referenced class org.Apache.http.client.methods.HttpPost
Warning:com.google.Android.gms.internal.zzw: can't find referenced class org.Apache.http.client.methods.HttpPut
Warning:com.google.Android.gms.internal.zzw: can't find referenced class org.Apache.http.client.methods.HttpTrace
Warning:com.google.Android.gms.internal.zzw: can't find referenced class org.Apache.http.client.methods.HttpUriRequest
Warning:com.google.Android.gms.internal.zzw: can't find referenced class org.Apache.http.entity.ByteArrayEntity
Warning:com.google.Android.gms.internal.zzw: can't find referenced method 'void addHeader(Java.lang.String,Java.lang.String)' in program class com.google.Android.gms.internal.zzw$zza
Warning:com.google.Android.gms.internal.zzw: can't find referenced class org.Apache.http.client.methods.HttpDelete
Warning:com.google.Android.gms.internal.zzw: can't find referenced class org.Apache.http.client.methods.HttpEntityEnclosingRequestBase
Warning:com.google.Android.gms.internal.zzw: can't find referenced class org.Apache.http.client.methods.HttpGet
Warning:com.google.Android.gms.internal.zzw: can't find referenced class org.Apache.http.client.methods.HttpHead
Warning:com.google.Android.gms.internal.zzw: can't find referenced class org.Apache.http.client.methods.HttpOptions
Warning:com.google.Android.gms.internal.zzw: can't find referenced class org.Apache.http.client.methods.HttpPost
Warning:com.google.Android.gms.internal.zzw: can't find referenced class org.Apache.http.client.methods.HttpPut
Warning:com.google.Android.gms.internal.zzw: can't find referenced class org.Apache.http.client.methods.HttpTrace
Warning:com.google.Android.gms.internal.zzw: can't find referenced class org.Apache.http.entity.ByteArrayEntity
Warning:com.google.Android.gms.internal.zzw: can't find referenced class org.Apache.http.client.HttpClient
Warning:com.google.Android.gms.internal.zzw: can't find referenced class org.Apache.http.client.methods.HttpUriRequest
Warning:com.google.Android.gms.internal.zzw: can't find referenced class org.Apache.http.client.HttpClient
Warning:com.google.Android.gms.internal.zzw: can't find referenced class org.Apache.http.client.methods.HttpUriRequest
Warning:com.google.Android.gms.internal.zzw: can't find referenced class org.Apache.http.HttpResponse
Warning:com.google.Android.gms.internal.zzw: can't find referenced class org.Apache.http.client.methods.HttpUriRequest
Warning:com.google.Android.gms.internal.zzw: can't find referenced class org.Apache.http.client.methods.HttpEntityEnclosingRequestBase
Warning:com.google.Android.gms.internal.zzw: can't find referenced class org.Apache.http.client.methods.HttpUriRequest
Warning:com.google.Android.gms.internal.zzw$zza: can't find referenced class org.Apache.http.client.methods.HttpEntityEnclosingRequestBase
Warning:com.google.Android.gms.internal.zzw$zza: can't find referenced method 'void setURI(Java.net.URI)' in program class com.google.Android.gms.internal.zzw$zza
Warning:com.google.Android.gms.internal.zzw$zza: can't find referenced class org.Apache.http.client.methods.HttpEntityEnclosingRequestBase
Warning:com.google.Android.gms.internal.zzx: can't find referenced class org.Apache.http.impl.cookie.DateParseException
Warning:com.google.Android.gms.internal.zzx: can't find referenced class org.Apache.http.impl.cookie.DateUtils
Warning:com.google.Android.gms.internal.zzy: can't find referenced class org.Apache.http.HttpResponse
Warning:com.google.Android.gms.internal.zzz: can't find referenced class org.Apache.http.ProtocolVersion
Warning:com.google.Android.gms.internal.zzz: can't find referenced class org.Apache.http.entity.BasicHttpEntity
Warning:com.google.Android.gms.internal.zzz: can't find referenced class org.Apache.http.message.BasicHeader
Warning:com.google.Android.gms.internal.zzz: can't find referenced class org.Apache.http.message.BasicHttpResponse
Warning:com.google.Android.gms.internal.zzz: can't find referenced class org.Apache.http.message.BasicStatusLine
Warning:com.google.Android.gms.internal.zzz: can't find referenced class org.Apache.http.ProtocolVersion
Warning:com.google.Android.gms.internal.zzz: can't find referenced class org.Apache.http.entity.BasicHttpEntity
Warning:com.google.Android.gms.internal.zzz: can't find referenced class org.Apache.http.message.BasicHeader
Warning:com.google.Android.gms.internal.zzz: can't find referenced class org.Apache.http.message.BasicHttpResponse
Warning:com.google.Android.gms.internal.zzz: can't find referenced class org.Apache.http.message.BasicStatusLine
Warning:com.google.Android.gms.internal.zzz: can't find referenced class org.Apache.http.HttpResponse
Warning:com.google.Android.gms.internal.zzz: can't find referenced class org.Apache.http.HttpEntity
Warning:com.google.Android.gms.tagmanager.zzby: can't find referenced class org.Apache.http.impl.client.DefaultHttpClient
Warning:com.google.Android.gms.tagmanager.zzcx: can't find referenced class org.Apache.http.Header
Warning:com.google.Android.gms.tagmanager.zzcx: can't find referenced class org.Apache.http.HttpEntity
Warning:com.google.Android.gms.tagmanager.zzcx: can't find referenced class org.Apache.http.HttpEntityEnclosingRequest
Warning:com.google.Android.gms.tagmanager.zzcx: can't find referenced class org.Apache.http.HttpHost
Warning:com.google.Android.gms.tagmanager.zzcx: can't find referenced class org.Apache.http.HttpResponse
Warning:com.google.Android.gms.tagmanager.zzcx: can't find referenced class org.Apache.http.StatusLine
Warning:com.google.Android.gms.tagmanager.zzcx: can't find referenced class org.Apache.http.client.ClientProtocolException
Warning:com.google.Android.gms.tagmanager.zzcx: can't find referenced class org.Apache.http.client.HttpClient
Warning:com.google.Android.gms.tagmanager.zzcx: can't find referenced class org.Apache.http.message.BasicHttpEntityEnclosingRequest
Warning:com.google.Android.gms.tagmanager.zzcx: can't find referenced class org.Apache.http.HttpHost
Warning:com.google.Android.gms.tagmanager.zzcx: can't find referenced class org.Apache.http.message.BasicHttpEntityEnclosingRequest
Warning:com.google.Android.gms.tagmanager.zzcx: can't find referenced class org.Apache.http.HttpEntity
Warning:com.google.Android.gms.tagmanager.zzcx: can't find referenced class org.Apache.http.HttpEntityEnclosingRequest
Warning:com.google.Android.gms.tagmanager.zzcx: can't find referenced class org.Apache.http.HttpResponse
Warning:com.google.Android.gms.tagmanager.zzcx: can't find referenced class org.Apache.http.StatusLine
Warning:com.google.Android.gms.tagmanager.zzcx: can't find referenced class org.Apache.http.client.HttpClient
Warning:com.google.Android.gms.tagmanager.zzcx: can't find referenced class org.Apache.http.HttpEntityEnclosingRequest

私が試した:

-keep class org.Apache.http.**
-keep interface org.Apache.http.**
-dontwarn org.Apache.**

しかし、それでも動作しません、何が問題なのですか?どうしたらいいかわからない。 PS私のファイルを最適化するための提案はありますか?前もって感謝します。

17
helloimyourmind

私も同じ問題を抱えていました。

私はここで答えを見つけ、それは私のために働きました: Apache HTTP API(レガシー)をbuild.gradeへのコンパイル時の依存関係として追加する方法?

最上位のbuild.gradleファイルに追加:

buildscript {
    ...
    dependencies {
        classpath 'com.Android.tools.build:gradle:1.3.1'
    }
}
...

アプリ固有のbuild.gradleファイルに次を追加します:

Android {
    compileSdkVersion 23
    buildToolsVersion "23.0.0"
    useLibrary 'org.Apache.http.legacy'
    ...
}

それがあなたのために働くことを願っています!現在はProGuardがオンの状態で動作します。私はあなたとまったく同じ問題を抱えていました。

35
gbhall

警告はグーグルライブラリから出ているようです、あなたはそのようなことを試しましたか?

-dontwarn com.google.Android.gms.**
-keep class com.google.Android.gms.**

また、dontwarnを使わずに試してみます。警告が必要な場合は警告を表示したいと思います。

17
Distwo

Eclipseの..sdk/platforms/Android-23/optionalでorg.Apache.http.legacy.jarを見つけます。

外部jarのようにインポートし、注文/エクスポートを確認し、プロガードタイプで指定します。

-keep class org.Apache.http.** { *; }
-keepclassmembers class org.Apache.http.** {*;}
-dontwarn org.Apache.**

-keep class Android.net.http.** { *; }
-keepclassmembers class Android.net.http.** {*;}
-dontwarn Android.net.**
9
Samarakande

Proguardファイルに次の行を追加します。

-keep class org.Apache.http.** { *; }
-keep class org.Apache.** { *; }
-dontwarn org.Apache.**
-dontwarn org.Apache.http.**
-dontwarn org.Apache.commons.**
1
Manoj Tarkar