我使用一些外部库来获取proguard的这些错误。
现在为这些jar添加 - dontwarn 后,它成功完成了构建过程,但在运行时,我的应用程序无法正常运行。我通过我的应用程序登录时收到 javax.net.ssl.SSLPeerUnverifiedException 。这种方法完美无缺,无需进行混淆。
这是我的proguard.cfg代码
-injars bin/classes
-outjars bin/classes-processed.jar
-libraryjars usr/local/android-15/android.jar
-libraryjars /libs/bugsense-1.9.jar
-libraryjars /libs/Facebook.jar
-libraryjars /libs/FlurryAgent.jar
-libraryjars /libs/GoogleAdMobAdsSdk-5.0.0.jar
-libraryjars /libs/httpclient-4.0.1.jar
-libraryjars /libs/httpmime-4.0.1.jar
-libraryjars /libs/jackson-core-asl-1.7.4.jar
-libraryjars /libs/jackson-mapper-asl-1.7.4.jar
-libraryjars /libs/signpost-commonshttp4-1.2.1.1.jar
-libraryjars /libs/twitter4j-core-2.1.11.jar
-libraryjars /libs/asmack-android-5.jar
-libraryjars /libs/signpost-core-1.2.1.1.jar
-dontpreverify
-allowaccessmodification
-dontwarn android.support.**
-dontskipnonpubliclibraryclassmembers
-useuniqueclassmembernames
-repackageclasses ''
-dontwarn com.inmobi.androidsdk.**
-dontwarn com.mobclix.android.sdk.**
-dontwarn com.millennialmedia.android.**
-dontwarn com.jumptap.adtag.**
-dontwarn org.apache.**
-dontwarn com.mobclix.android.sdk.**
-dontwarn org.w3c.dom.**
-dontwarn org.joda.**
-dontwarn org.slf4j.**
-dontwarn com.google.ads.**
-dontshrink
-dontoptimize
-keepattributes *Annotation*
-keep public class * extends android.app.Activity
-keep public class * extends android.os.AsyncTask
-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.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public interface com.android.vending.licensing.ILicensingService
-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.content.Context {
public void *(android.view.View);
public void *(android.view.MenuItem);
}
-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>;
}
去混淆Logcat报告
11-10 00:51:39.893: W/System.err(1631): javax.net.ssl.SSLPeerUnverifiedException: No peer certificate
11-10 00:51:39.893: W/System.err(1631): at 11-14 21:18:44.491: W/System.err(13184): javax.net.ssl.SSLPeerUnverifiedException: No peer certificate
11-14 21:18:44.501: W/System.err(13184): at org.apache.harmony.xnet.provider.jsse.SSLSessionImpl.getPeerCertificates(SSLSessionImpl.java:258)
11-14 21:18:44.501: W/System.err(13184): at org.apache.http.conn.ssl.AbstractVerifier.void verify(java.lang.String,javax.net.ssl.SSLSocket)(Unknown Source)
void verify(java.lang.String,java.security.cert.X509Certificate)
void verify(java.lang.String,java.lang.String[],java.lang.String[],boolean)
boolean acceptableCountryWildcard(java.lang.String)
java.lang.String[] getCNs(java.security.cert.X509Certificate)
java.lang.String[] getSubjectAlts(java.security.cert.X509Certificate,java.lang.String)
11-14 21:18:44.501: W/System.err(13184): at org.apache.http.conn.ssl.SSLSocketFactory.javax.net.ssl.KeyManager[] createKeyManagers(java.security.KeyStore,java.lang.String)(Unknown Source)
javax.net.ssl.TrustManager[] createTrustManagers(java.security.KeyStore)
java.net.Socket createSocket()
java.net.Socket connectSocket(java.net.Socket,java.lang.String,int,java.net.InetAddress,int,org.apache.http.params.HttpParams)
boolean isSecure(java.net.Socket)
java.net.Socket createSocket(java.net.Socket,java.lang.String,int,boolean)
void setHostnameVerifier(org.apache.http.conn.ssl.X509HostnameVerifier)
11-14 21:18:44.501: W/System.err(13184): at org.apache.http.impl.conn.DefaultClientConnectionOperator.org.apache.http.conn.OperatedClientConnection createConnection()(Unknown Source)
void openConnection(org.apache.http.conn.OperatedClientConnection,org.apache.http.HttpHost,java.net.InetAddress,org.apache.http.protocol.HttpContext,org.apache.http.params.HttpParams)
void updateSecureConnection(org.apache.http.conn.OperatedClientConnection,org.apache.http.HttpHost,org.apache.http.protocol.HttpContext,org.apache.http.params.HttpParams)
void prepareSocket(java.net.Socket,org.apache.http.protocol.HttpContext,org.apache.http.params.HttpParams)
11-14 21:18:44.501: W/System.err(13184): at org.apache.http.impl.conn.AbstractPoolEntry.java.lang.Object getState()(Unknown Source)
void setState(java.lang.Object)
void open(org.apache.http.conn.routing.HttpRoute,org.apache.http.protocol.HttpContext,org.apache.http.params.HttpParams)
void tunnelTarget(boolean,org.apache.http.params.HttpParams)
void tunnelProxy(org.apache.http.HttpHost,boolean,org.apache.http.params.HttpParams)
void layerProtocol(org.apache.http.protocol.HttpContext,org.apache.http.params.HttpParams)
11-14 21:18:44.501: W/System.err(13184): at org.apache.http.impl.conn.AbstractPooledConnAdapter.void open(org.apache.http.conn.routing.HttpRoute,org.apache.http.protocol.HttpContext,org.apache.http.params.HttpParams)(Unknown Source)
void tunnelTarget(boolean,org.apache.http.params.HttpParams)
void tunnelProxy(org.apache.http.HttpHost,boolean,org.apache.http.params.HttpParams)
void layerProtocol(org.apache.http.protocol.HttpContext,org.apache.http.params.HttpParams)
void setState(java.lang.Object)
11-14 21:18:44.501: W/System.err(13184): at org.apache.http.impl.client.DefaultRequestDirector.org.apache.http.impl.client.RequestWrapper wrapRequest(org.apache.http.HttpRequest)(Unknown Source)
void rewriteRequestURI(org.apache.http.impl.client.RequestWrapper,org.apache.http.conn.routing.HttpRoute)
org.apache.http.HttpResponse execute(org.apache.http.HttpHost,org.apache.http.HttpRequest,org.apache.http.protocol.HttpContext)
void releaseConnection()
void establishRoute(org.apache.http.conn.routing.HttpRoute,org.apache.http.protocol.HttpContext)
boolean createTunnelToProxy(org.apache.http.conn.routing.HttpRoute,int,org.apache.http.protocol.HttpContext)
org.apache.http.impl.client.RoutedRequest handleResponse(org.apache.http.impl.client.RoutedRequest,org.apache.http.HttpResponse,org.apache.http.protocol.HttpContext)
void processChallenges(java.util.Map,org.apache.http.auth.AuthState,org.apache.http.client.AuthenticationHandler,org.apache.http.HttpResponse,org.apache.http.protocol.HttpContext)
void updateAuthState(org.apache.http.auth.AuthState,org.apache.http.HttpHost,org.apache.http.client.CredentialsProvider)
11-14 21:18:44.501: W/System.err(13184): at org.apache.http.impl.client.AbstractHttpClient.org.apache.http.HttpResponse execute(org.apache.http.client.methods.HttpUriRequest)(Unknown Source)
org.apache.http.HttpResponse execute(org.apache.http.client.methods.HttpUriRequest,org.apache.http.protocol.HttpContext)
org.apache.http.HttpResponse execute(org.apache.http.HttpHost,org.apache.http.HttpRequest)
org.apache.http.HttpResponse execute(org.apache.http.HttpHost,org.apache.http.HttpRequest,org.apache.http.protocol.HttpContext)
java.lang.Object execute(org.apache.http.client.methods.HttpUriRequest,org.apache.http.client.ResponseHandler)
java.lang.Object execute(org.apache.http.client.methods.HttpUriRequest,org.apache.http.client.ResponseHandler,org.apache.http.protocol.HttpContext)
java.lang.Object execute(org.apache.http.HttpHost,org.apache.http.HttpRequest,org.apache.http.client.ResponseHandler)
java.lang.Object execute(org.apache.http.HttpHost,org.apache.http.HttpRequest,org.apache.http.client.ResponseHandler,org.apache.http.protocol.HttpContext)
11-14 21:18:44.501: W/System.err(13184): at org.apache.http.impl.client.AbstractHttpClient.org.apache.http.HttpResponse execute(org.apache.http.client.methods.HttpUriRequest)(Unknown Source)
org.apache.http.HttpResponse execute(org.apache.http.client.methods.HttpUriRequest,org.apache.http.protocol.HttpContext)
org.apache.http.HttpResponse execute(org.apache.http.HttpHost,org.apache.http.HttpRequest)
org.apache.http.HttpResponse execute(org.apache.http.HttpHost,org.apache.http.HttpRequest,org.apache.http.protocol.HttpContext)
java.lang.Object execute(org.apache.http.client.methods.HttpUriRequest,org.apache.http.client.ResponseHandler)
java.lang.Object execute(org.apache.http.client.methods.HttpUriRequest,org.apache.http.client.ResponseHandler,org.apache.http.protocol.HttpContext)
java.lang.Object execute(org.apache.http.HttpHost,org.apache.http.HttpRequest,org.apache.http.client.ResponseHandler)
java.lang.Object execute(org.apache.http.HttpHost,org.apache.http.HttpRequest,org.apache.http.client.ResponseHandler,org.apache.http.protocol.HttpContext)
11-14 21:18:44.501: W/System.err(13184): at org.apache.http.impl.client.AbstractHttpClient.org.apache.http.HttpResponse execute(org.apache.http.client.methods.HttpUriRequest)(Unknown Source)
org.apache.http.HttpResponse execute(org.apache.http.client.methods.HttpUriRequest,org.apache.http.protocol.HttpContext)
org.apache.http.HttpResponse execute(org.apache.http.HttpHost,org.apache.http.HttpRequest)
org.apache.http.HttpResponse execute(org.apache.http.HttpHost,org.apache.http.HttpRequest,org.apache.http.protocol.HttpContext)
java.lang.Object execute(org.apache.http.client.methods.HttpUriRequest,org.apache.http.client.ResponseHandler)
java.lang.Object execute(org.apache.http.client.methods.HttpUriRequest,org.apache.http.client.ResponseHandler,org.apache.http.protocol.HttpContext)
java.lang.Object execute(org.apache.http.HttpHost,org.apache.http.HttpRequest,org.apache.http.client.ResponseHandler)
java.lang.Object execute(org.apache.http.HttpHost,org.apache.http.HttpRequest,org.apache.http.client.ResponseHandler,org.apache.http.protocol.HttpContext)
11-14 21:18:44.501: W/System.err(13184): at org.apache.http.impl.client.AbstractHttpClient.org.apache.http.HttpResponse execute(org.apache.http.client.methods.HttpUriRequest)(Unknown Source)
org.apache.http.HttpResponse execute(org.apache.http.client.methods.HttpUriRequest,org.apache.http.protocol.HttpContext)
org.apache.http.HttpResponse execute(org.apache.http.HttpHost,org.apache.http.HttpRequest)
org.apache.http.HttpResponse execute(org.apache.http.HttpHost,org.apache.http.HttpRequest,org.apache.http.protocol.HttpContext)
java.lang.Object execute(org.apache.http.client.methods.HttpUriRequest,org.apache.http.client.ResponseHandler)
java.lang.Object execute(org.apache.http.client.methods.HttpUriRequest,org.apache.http.client.ResponseHandler,org.apache.http.protocol.HttpContext)
java.lang.Object execute(org.apache.http.HttpHost,org.apache.http.HttpRequest,org.apache.http.client.ResponseHandler)
java.lang.Object execute(org.apache.http.HttpHost,org.apache.http.HttpRequest,org.apache.http.client.ResponseHandler,org.apache.http.protocol.HttpContext)
11-14 21:18:44.501: W/System.err(13184): at com.mypackage.android.services.secure.HttpsWebServiceHelper.java.lang.String doPost(org.apache.http.client.methods.HttpPost)(Unknown Source)
java.lang.String doPost(java.lang.String,java.util.Map)
java.lang.String doPost(java.lang.String,java.lang.String)
java.lang.String doPost(java.lang.String,java.util.Map,java.lang.String)
11-14 21:18:44.501: W/System.err(13184): at com.mypackage.android.services.secure.HttpsWebServiceHelper.java.lang.String doPost(org.apache.http.client.methods.HttpPost)(Unknown Source)
java.lang.String doPost(java.lang.String,java.util.Map)
java.lang.String doPost(java.lang.String,java.lang.String)
java.lang.String doPost(java.lang.String,java.util.Map,java.lang.String)
11-14 21:18:44.501: W/System.err(13184): at com.mypackage.android.activity.LoginActivity$LoginAsyncTask.java.lang.String doInBackground(java.lang.Void[])(Unknown Source)
void onPostExecute(java.lang.String)
11-14 21:18:44.501: W/System.err(13184): at com.mypackage.android.activity.LoginActivity$LoginAsyncTask.java.lang.Object doInBackground(java.lang.Object[])(Unknown Source)
11-14 21:18:44.501: W/System.err(13184): at android.os.AsyncTask$2.call(AsyncTask.java:185)
11-14 21:18:44.501: W/System.err(13184): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
11-14 21:18:44.501: W/System.err(13184): at java.util.concurrent.FutureTask.run(FutureTask.java:138)
11-14 21:18:44.511: W/System.err(13184): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
11-14 21:18:44.511: W/System.err(13184): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
11-14 21:18:44.511: W/System.err(13184): at java.lang.Thread.run(Thread.java:1027)
11-14 21:18:44.511: W/System.err(13184): java.io.IOException
11-14 21:18:44.511: W/System.err(13184): at com.mypackage.android.services.secure.HttpsWebServiceHelper.java.lang.String doPost(org.apache.http.client.methods.HttpPost)(Unknown Source)
java.lang.String doPost(java.lang.String,java.util.Map)
java.lang.String doPost(java.lang.String,java.lang.String)
java.lang.String doPost(java.lang.String,java.util.Map,java.lang.String)
11-14 21:18:44.511: W/System.err(13184): at com.mypackage.android.services.secure.HttpsWebServiceHelper.java.lang.String doPost(org.apache.http.client.methods.HttpPost)(Unknown Source)
java.lang.String doPost(java.lang.String,java.util.Map)
java.lang.String doPost(java.lang.String,java.lang.String)
java.lang.String doPost(java.lang.String,java.util.Map,java.lang.String)
11-14 21:18:44.511: W/System.err(13184): at com.mypackage.android.activity.LoginActivity$LoginAsyncTask.java.lang.String doInBackground(java.lang.Void[])(Unknown Source)
void onPostExecute(java.lang.String)
11-14 21:18:44.511: W/System.err(13184): at com.mypackage.android.activity.LoginActivity$LoginAsyncTask.java.lang.Object doInBackground(java.lang.Object[])(Unknown Source)
11-14 21:18:44.511: W/System.err(13184): at android.os.AsyncTask$2.call(AsyncTask.java:185)
11-14 21:18:44.511: W/System.err(13184): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
11-14 21:18:44.511: W/System.err(13184): at java.util.concurrent.FutureTask.run(FutureTask.java:138)
11-14 21:18:44.511: W/System.err(13184): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
11-14 21:18:44.521: W/System.err(13184): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
11-14 21:18:44.521: W/System.err(13184): at java.lang.Thread.run(Thread.java:1027)