我一直在研究我的应用程序的最新版本,它测试得很好,但是当我做一个发布ProGuard构建时,我得到了很多错误,主要是关于无法找到org.apache.http.*
,我不在我的项目中使用。我已经搜索了我的整个项目的文本,没有找到它。我已经添加了一些依赖关系,但没有一个我认为会使用HTTP。
我如何找出为什么 ProGuard正在抱怨并正确解决它?它说我可以运行"与——stacktrace选项",但我不知道如何做到这一点。
我感谢任何帮助,因为我发现ProGuard经常令人困惑。
构建输出:
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.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.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.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.analytics.internal.zzj: can't find referenced class org.apache.http.NameValuePair
Warning: com.google.android.gms.common.GooglePlayServicesUtil: can't find referenced method 'void setLatestEventInfo(android.content.Context,java.lang.CharSequence,java.lang.CharSequence,android.app.PendingIntent)' in library class android.app.Notification
Warning: com.google.android.gms.internal.zzac: can't find referenced class android.net.http.AndroidHttpClient
Warning: com.google.android.gms.internal.zzac: can't find referenced class android.net.http.AndroidHttpClient
Warning: com.google.android.gms.internal.zzqj: can't find referenced class org.apache.http.HttpEntity
Warning: com.google.android.gms.internal.zzqj: can't find referenced class org.apache.http.HttpResponse
Warning: com.google.android.gms.internal.zzqj: can't find referenced class org.apache.http.StatusLine
Warning: com.google.android.gms.internal.zzqj: can't find referenced class org.apache.http.client.HttpClient
Warning: com.google.android.gms.internal.zzqj: can't find referenced class org.apache.http.client.methods.HttpGet
Warning: com.google.android.gms.internal.zzqj: can't find referenced class org.apache.http.conn.ClientConnectionManager
Warning: com.google.android.gms.internal.zzqj: can't find referenced class org.apache.http.impl.client.DefaultHttpClient
Warning: com.google.android.gms.internal.zzqj: can't find referenced class org.apache.http.params.BasicHttpParams
Warning: com.google.android.gms.internal.zzqj: can't find referenced class org.apache.http.client.methods.HttpGet
Warning: com.google.android.gms.internal.zzqj: can't find referenced class org.apache.http.impl.client.DefaultHttpClient
Warning: com.google.android.gms.internal.zzqj: can't find referenced class org.apache.http.params.BasicHttpParams
Warning: com.google.android.gms.internal.zzqj: can't find referenced class org.apache.http.HttpEntity
Warning: com.google.android.gms.internal.zzqj: can't find referenced class org.apache.http.HttpResponse
Warning: com.google.android.gms.internal.zzqj: can't find referenced class org.apache.http.HttpResponse
Warning: com.google.android.gms.internal.zzqj: can't find referenced class org.apache.http.StatusLine
Warning: com.google.android.gms.internal.zzqj: can't find referenced class org.apache.http.client.HttpClient
Warning: com.google.android.gms.internal.zzqj: can't find referenced class org.apache.http.client.HttpClient
Warning: com.google.android.gms.internal.zzqj: can't find referenced class org.apache.http.conn.ClientConnectionManager
Warning: com.google.android.gms.internal.zzqj: can't find referenced class org.apache.http.client.HttpClient
Warning: com.google.android.gms.internal.zzqj: can't find referenced class org.apache.http.client.HttpClient
Warning: com.google.android.gms.internal.zzqj: can't find referenced class org.apache.http.client.HttpClient
Warning: com.google.android.gms.internal.zzqj: can't find referenced class org.apache.http.HttpResponse
Warning: com.google.android.gms.internal.zzqj: 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.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.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.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.HttpEntity
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.HttpResponse
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.StatusLine
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.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.HttpPost
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.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.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.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.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.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.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.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.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.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.entity.BasicHttpEntity
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.entity.BasicHttpEntity
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.BasicHttpResponse
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.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.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.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.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.HttpEntityEnclosingRequest
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.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.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.client.HttpClient
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
Warning: com.google.android.gms.tagmanager.zzcx: can't find referenced class org.apache.http.HttpEntityEnclosingRequest
Warning: there were 148 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)
Warning: there were 2 unresolved references to program class members.
Your input classes appear to be inconsistent.
You may need to recompile the code.
(http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedprogramclassmember)
Warning: there were 1 unresolved references to library class members.
You probably need to update the library versions.
(http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedlibraryclassmember)
:GradeTrackerPro:proguardRelease FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':MyApp:proguardRelease'.
> java.io.IOException: Please correct the above warnings first.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
从我的Gradle文件:
android {
compileSdkVersion 23
buildToolsVersion "23"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
// to ignore warnings and strings not converted to all languages
android {
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
}
我的proguard-rules.pro
文件:
-keep class !android.support.v7.internal.view.menu.MenuBuilder, !android.support.v7.internal.view.menu.SubMenuBuilder, android.support.v7.** { *; }
-keep interface android.support.v7.** { *; }
-dontwarn com.opencsv.bean.**
-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable # these last two lines keep info for debugging
# added these because proguard was complaining. Not sure where they could be referenced!
# For Flurry
-keep class com.flurry.** { *; }
-dontwarn com.flurry.**
-keepattributes *Annotation*, EnclosingMethod
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int) ;
}
# Google Play Services library
-keep class * extends java.util.ListResourceBundle {
protected Object[][] getContents() ;
}
-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
public static final *** NULL;
}
-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * {
@com.google.android.gms.common.annotation.KeepName *;
}
-keepnames class * implements android.os.Parcelable {
public static final ** CREATOR;
}
在将buildTool更新到23.0之前,我从未遇到过这个问题。唯一的解决办法,我可以看到这个新版本的构建工具为我的应用程序是,你需要把它添加到你的proguard .txt文件。
-dontwarn android.support.v4.**
-keep public class com.google.android.gms.* { public *; }
-dontwarn com.google.android.gms.**
如果你在你的项目中使用Apache的Http,你还需要包括以下几行:
-keepnames class org.apache.** {*;}
-keep public class org.apache.** {*;}
-dontwarn org.apache.commons.logging.LogFactory
-dontwarn org.apache.http.annotation.ThreadSafe
-dontwarn org.apache.http.annotation.Immutable
-dontwarn org.apache.http.annotation.NotThreadSafe
如果这也有助于解决你的问题,请告诉我。
您必须添加到构建中。如果你的应用程序使用旧的apache HttpClient,在gradle文件中添加以下内容:
useLibrary org.apache.http.legacy"
如下所示:https://www.youtube.com/watch?v=yYU4DHLwoRk