问题描述:
1、如果不使用混淆,那么可以正常打包,并且运行也正常
2、如果使用混淆,则打包报错
3、在proguard中忽略所有的警告,则打包成功,但运行即报错(至于报什么错没看,因为这样根本不是解决之道)
问题补充:
1、之前混淆的代码
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-dontskipnonpubliclibraryclassmembers
-libraryjars E:\Program Files\adt-bundle-windows-x86_64-20140321\sdk\platforms\android-17\android.jar
-libraryjars libs/android-support-v4.jar
-libraryjars libs/baidumapapi_v2_4_2.jar
-libraryjars libs/locSDK_3.1.jar
-libraryjars libs/mframework.jar
-libraryjars libs/my-image-loader.jar
-libraryjars libs/ShareSDK-Core-2.3.11.jar
-libraryjars libs/ShareSDK-QZone-2.3.11.jar
-libraryjars libs/ShareSDK-SinaWeibo-2.3.11.jar
-libraryjars libs/ShareSDK-TencentWeibo-2.3.11.jar
-libraryjars libs/ShareSDK-Wechat-Core-2.3.11.jar
-libraryjars libs/ShareSDK-Wechat-Moments-2.3.11.jar
-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 com.android.vending.licensing.ILicensingService
-keep class org.jsoup.** {*;}
-keep class com.baidu.mapapi.** {*;}
-keep class vi.com.gdi.bgl.android.**{*;}
-keep class com.nostra13.** {*;}
-keep class android.support.v4.** {*;}
-keep class m.framework.** {*;}
-keep class cn.sharesdk.** {*;}
-keepclassmembers class **.R$* {
public static <fields>;
}
-keepclasseswithmembernames class * {
native <methods>;
}
-keepclasseswithmembernames class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembernames class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
2、如果在第一句加上-ignorewarnings,则能打包成功,但运行报错
3、报的错误Log
[2014-07-30 16:56:38 - AutoDrive] Proguard returned with error code 1. See console
[2014-07-30 16:56:38 - AutoDrive] Note: there were 3259 duplicate class definitions.
[2014-07-30 16:56:38 - AutoDrive] Warning: com.baidu.mapapi.utils.f: can't find referenced method 'java.io.File[] getExternalFilesDirs(java.lang.String)' in class android.content.Context
[2014-07-30 16:56:38 - AutoDrive] You should check if you need to specify additional program jars.
[2014-07-30 16:56:38 - AutoDrive] Warning: there were 1 unresolved references to program class members.
[2014-07-30 16:56:38 - AutoDrive] Your input classes appear to be inconsistent.
[2014-07-30 16:56:38 - AutoDrive] You may need to recompile them and try again.
[2014-07-30 16:56:38 - AutoDrive] Alternatively, you may have to specify the option
[2014-07-30 16:56:38 - AutoDrive] '-dontskipnonpubliclibraryclassmembers'.
[2014-07-30 16:56:38 - AutoDrive] java.io.IOException: Please correct the above warnings first.
[2014-07-30 16:56:38 - AutoDrive] at proguard.Initializer.execute(Initializer.java:321)
[2014-07-30 16:56:38 - AutoDrive] at proguard.ProGuard.initialize(ProGuard.java:211)
[2014-07-30 16:56:38 - AutoDrive] at proguard.ProGuard.execute(ProGuard.java:86)
[2014-07-30 16:56:38 - AutoDrive] at proguard.ProGuard.main(ProGuard.java:492)
最后,求大神解答啊
------解决方案--------------------
对于使用第三方库的话,全部不要混淆就可以了
------解决方案--------------------
-keep public class * extends android.app.Activity
-libraryjars libs/alipay.jar
-dontwarn com.alipay.android.app.**
最基础的三句。如果爆了其他什么的一般能看出是哪个包的问题,针对这个包上百度搜索。基本都能解决
------解决方案--------------------
我是这么写的,你可以试试
-keep class com.baidu.**