护卫和错误

2022-09-02 22:55:18

我使用这个proguard文件:

 -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你有什么建议来优化我的文件吗?提前致谢。


答案 1

我遇到了同样的问题。

我在这里找到了答案,它对我有用:如何将Apache HTTP API(legacy)作为编译时依赖项添加到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一起工作。我遇到了和你一模一样的问题。


答案 2

看起来警告来自谷歌图书馆,你有没有试过这样的东西:

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

我也会在没有原因的情况下尝试,我会假设你想被警告,如果有事情要被警告!dontwarn


推荐