混淆代码打包时报错:library classes depending on program classes

导入了2个第三方jar包:httpmime-4.3.5.jar、httpcore-4.3.2.jar包,打包时这2个包不混淆(-libraryjars libs/httpcore-4.3.2.jar, -libraryjars libs/httpmime-4.3.5.jar),包里面涉及到android系统org.apache.http包下面的相关类,所以混淆代码的时候报错如下:

[2015-01-20 17:18:38 - 56ol] Proguard returned with error code 1. See console
[2015-01-20 17:18:38 - 56ol] Note: there were 1059 duplicate class definitions.
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.auth.AuthenticationException extends or implements program class org.apache.http.ProtocolException
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.auth.MalformedChallengeException extends or implements program class org.apache.http.ProtocolException
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.auth.params.AuthParamBean extends or implements program class org.apache.http.params.HttpAbstractParamBean
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.client.NonRepeatableRequestException extends or implements program class org.apache.http.ProtocolException
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.client.RedirectException extends or implements program class org.apache.http.ProtocolException
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.client.entity.UrlEncodedFormEntity extends or implements program class org.apache.http.entity.StringEntity
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.client.methods.HttpEntityEnclosingRequestBase extends or implements program class org.apache.http.HttpEntityEnclosingRequest
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.client.methods.HttpRequestBase extends or implements program class org.apache.http.message.AbstractHttpMessage
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.client.methods.HttpUriRequest extends or implements program class org.apache.http.HttpRequest
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.client.params.AllClientPNames extends or implements program class org.apache.http.params.CoreConnectionPNames
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.client.params.AllClientPNames extends or implements program class org.apache.http.params.CoreProtocolPNames
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.client.params.ClientParamBean extends or implements program class org.apache.http.params.HttpAbstractParamBean
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.client.protocol.RequestAddCookies extends or implements program class org.apache.http.HttpRequestInterceptor
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.client.protocol.RequestDefaultHeaders extends or implements program class org.apache.http.HttpRequestInterceptor
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.client.protocol.RequestProxyAuthentication extends or implements program class org.apache.http.HttpRequestInterceptor
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.client.protocol.RequestTargetAuthentication extends or implements program class org.apache.http.HttpRequestInterceptor
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.client.protocol.ResponseProcessCookies extends or implements program class org.apache.http.HttpResponseInterceptor
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.conn.BasicManagedEntity extends or implements program class org.apache.http.entity.HttpEntityWrapper
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.conn.ManagedClientConnection extends or implements program class org.apache.http.HttpClientConnection
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.conn.ManagedClientConnection extends or implements program class org.apache.http.HttpInetConnection
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.conn.OperatedClientConnection extends or implements program class org.apache.http.HttpClientConnection
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.conn.OperatedClientConnection extends or implements program class org.apache.http.HttpInetConnection
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.conn.params.ConnConnectionParamBean extends or implements program class org.apache.http.params.HttpAbstractParamBean
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.conn.params.ConnManagerParamBean extends or implements program class org.apache.http.params.HttpAbstractParamBean
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.conn.params.ConnRouteParamBean extends or implements program class org.apache.http.params.HttpAbstractParamBean
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.cookie.MalformedCookieException extends or implements program class org.apache.http.ProtocolException
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.cookie.params.CookieSpecParamBean extends or implements program class org.apache.http.params.HttpAbstractParamBean
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.client.ClientParamsStack extends or implements program class org.apache.http.params.AbstractHttpParams
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.client.EntityEnclosingRequestWrapper extends or implements program class org.apache.http.HttpEntityEnclosingRequest
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.client.RequestWrapper extends or implements program class org.apache.http.message.AbstractHttpMessage
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.client.TunnelRefusedException extends or implements program class org.apache.http.HttpException
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.conn.DefaultClientConnection extends or implements program class org.apache.http.impl.SocketHttpClientConnection
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.conn.DefaultResponseParser extends or implements program class org.apache.http.impl.io.AbstractMessageParser
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.conn.LoggingSessionInputBuffer extends or implements program class org.apache.http.io.SessionInputBuffer
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.conn.LoggingSessionOutputBuffer extends or implements program class org.apache.http.io.SessionOutputBuffer
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.client.HttpClient depends on program class org.apache.http.params.HttpParams
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.client.HttpClient depends on program class org.apache.http.HttpResponse
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.client.HttpClient depends on program class org.apache.http.protocol.HttpContext
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.client.HttpClient depends on program class org.apache.http.HttpResponse
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.client.HttpClient depends on program class org.apache.http.HttpHost
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.client.HttpClient depends on program class org.apache.http.HttpRequest
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.client.HttpClient depends on program class org.apache.http.HttpResponse
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.client.HttpClient depends on program class org.apache.http.HttpHost
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.client.HttpClient depends on program class org.apache.http.HttpRequest
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.client.HttpClient depends on program class org.apache.http.protocol.HttpContext
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.client.HttpClient depends on program class org.apache.http.HttpResponse
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.client.HttpClient depends on program class org.apache.http.protocol.HttpContext
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.client.HttpClient depends on program class org.apache.http.HttpHost
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.client.HttpClient depends on program class org.apache.http.HttpRequest
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.client.HttpClient depends on program class org.apache.http.HttpHost
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.client.HttpClient depends on program class org.apache.http.HttpRequest
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.client.HttpClient depends on program class org.apache.http.protocol.HttpContext
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.client.methods.HttpEntityEnclosingRequestBase depends on program class org.apache.http.HttpEntity
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.client.methods.HttpEntityEnclosingRequestBase depends on program class org.apache.http.HttpEntity
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.client.methods.HttpRequestBase depends on program class org.apache.http.ProtocolVersion
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.client.methods.HttpRequestBase depends on program class org.apache.http.RequestLine
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.conn.scheme.PlainSocketFactory depends on program class org.apache.http.params.HttpParams
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.conn.scheme.SchemeRegistry depends on program class org.apache.http.HttpHost
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.conn.scheme.SocketFactory depends on program class org.apache.http.params.HttpParams
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.client.AbstractHttpClient depends on program class org.apache.http.params.HttpParams
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.client.AbstractHttpClient depends on program class org.apache.http.params.HttpParams
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.client.AbstractHttpClient depends on program class org.apache.http.protocol.HttpContext
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.client.AbstractHttpClient depends on program class org.apache.http.protocol.HttpRequestExecutor
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.client.AbstractHttpClient depends on program class org.apache.http.ConnectionReuseStrategy
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.client.AbstractHttpClient depends on program class org.apache.http.protocol.BasicHttpProcessor
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.client.AbstractHttpClient depends on program class org.apache.http.params.HttpParams
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.client.AbstractHttpClient depends on program class org.apache.http.params.HttpParams
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.client.AbstractHttpClient depends on program class org.apache.http.protocol.HttpRequestExecutor
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.client.AbstractHttpClient depends on program class org.apache.http.ConnectionReuseStrategy
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.client.AbstractHttpClient depends on program class org.apache.http.ConnectionReuseStrategy
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.client.AbstractHttpClient depends on program class org.apache.http.protocol.BasicHttpProcessor
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.client.AbstractHttpClient depends on program class org.apache.http.HttpResponseInterceptor
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.client.AbstractHttpClient depends on program class org.apache.http.HttpResponseInterceptor
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.client.AbstractHttpClient depends on program class org.apache.http.HttpResponseInterceptor
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.client.AbstractHttpClient depends on program class org.apache.http.HttpRequestInterceptor
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.client.AbstractHttpClient depends on program class org.apache.http.HttpRequestInterceptor
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.client.AbstractHttpClient depends on program class org.apache.http.HttpRequestInterceptor
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.client.AbstractHttpClient depends on program class org.apache.http.HttpResponse
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.client.AbstractHttpClient depends on program class org.apache.http.protocol.HttpContext
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.client.AbstractHttpClient depends on program class org.apache.http.HttpResponse
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.client.AbstractHttpClient depends on program class org.apache.http.HttpHost
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.client.AbstractHttpClient depends on program class org.apache.http.HttpRequest
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.client.AbstractHttpClient depends on program class org.apache.http.HttpResponse
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.client.AbstractHttpClient depends on program class org.apache.http.HttpHost
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.client.AbstractHttpClient depends on program class org.apache.http.HttpRequest
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.client.AbstractHttpClient depends on program class org.apache.http.protocol.HttpContext
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.client.AbstractHttpClient depends on program class org.apache.http.HttpResponse
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.client.AbstractHttpClient depends on program class org.apache.http.protocol.HttpRequestExecutor
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.client.AbstractHttpClient depends on program class org.apache.http.ConnectionReuseStrategy
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.client.AbstractHttpClient depends on program class org.apache.http.protocol.HttpProcessor
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.client.AbstractHttpClient depends on program class org.apache.http.params.HttpParams
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.client.AbstractHttpClient depends on program class org.apache.http.HttpRequest
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.client.AbstractHttpClient depends on program class org.apache.http.params.HttpParams
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.client.AbstractHttpClient depends on program class org.apache.http.protocol.HttpContext
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.client.AbstractHttpClient depends on program class org.apache.http.HttpHost
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.client.AbstractHttpClient depends on program class org.apache.http.HttpRequest
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.client.AbstractHttpClient depends on program class org.apache.http.HttpHost
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.client.AbstractHttpClient depends on program class org.apache.http.HttpRequest
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.client.AbstractHttpClient depends on program class org.apache.http.protocol.HttpContext
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.client.DefaultHttpClient depends on program class org.apache.http.params.HttpParams
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.client.DefaultHttpClient depends on program class org.apache.http.params.HttpParams
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.client.DefaultHttpClient depends on program class org.apache.http.params.HttpParams
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.client.DefaultHttpClient depends on program class org.apache.http.protocol.HttpRequestExecutor
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.client.DefaultHttpClient depends on program class org.apache.http.protocol.HttpContext
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.client.DefaultHttpClient depends on program class org.apache.http.ConnectionReuseStrategy
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.client.DefaultHttpClient depends on program class org.apache.http.protocol.BasicHttpProcessor
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager depends on program class org.apache.http.params.HttpParams
[2015-01-20 17:18:38 - 56ol] Warning: library class org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager depends on program class org.apache.http.params.HttpParams
[2015-01-20 17:18:38 - 56ol]       You should check if you need to specify additional program jars.
[2015-01-20 17:18:38 - 56ol] Warning: there were 108 instances of library classes depending on program classes.
[2015-01-20 17:18:38 - 56ol]          You must avoid such dependencies, since the program classes will
[2015-01-20 17:18:38 - 56ol]          be processed, while the library classes will remain unchanged.
[2015-01-20 17:18:38 - 56ol] java.io.IOException: Please correct the above warnings first.
[2015-01-20 17:18:38 - 56ol] 	at proguard.Initializer.execute(Initializer.java:321)
[2015-01-20 17:18:38 - 56ol] 	at proguard.ProGuard.initialize(ProGuard.java:211)
[2015-01-20 17:18:38 - 56ol] 	at proguard.ProGuard.execute(ProGuard.java:86)
[2015-01-20 17:18:38 - 56ol] 	at proguard.ProGuard.main(ProGuard.java:492)
最上面了个Note: there were 1059 duplicate class definitions,这个可以忽略。主要是下面的Warning,打包的时候可以直接在proguard-project.txt中加入

-ingorewarnings
这样确实是可以正常打包,但实际治标不治本,打包的apk不一定能正常工作。我自己在项目中,添加-ingorewarnings打包后,所有http请求都失败了。

正确的解决方法其实最下面几段提示已经写出来了:You must avoid such dependencies, since the program classes will be processed, while the library calsses will remain unchanged。意思是说:程序中的类被混淆后,jar包中的类还没有改变,导致了不一致。所以解决方法是,程序中的这些类也不混淆,添加如下代码:

-dontwarn org.apache.http.**
-keep class org.apache.http.** { *;}
需要说明的是,报错直接添加-ignorewarning其实是很不好的方式,注意查看console的提示信息。

你可能感兴趣的:(android实例)