【第22期】观点:IT 行业加班,到底有没有价值?

Afinal 混淆打包报错的解决方法

原创 2015年11月19日 14:27:12
纠结了好几天的问题.项目中导入了Afinal的jar包,在混淆打包的时候,一直报错.
org.eclipse.core.runtime.CoreException: Proguard returned with error code 1. See console
	at com.android.ide.eclipse.adt.internal.project.ExportHelper.exportReleaseApk(ExportHelper.java:301)
	at com.android.ide.eclipse.adt.internal.wizards.export.ExportWizard.doExport(ExportWizard.java:305)
	at com.android.ide.eclipse.adt.internal.wizards.export.ExportWizard.access$0(ExportWizard.java:234)
	at com.android.ide.eclipse.adt.internal.wizards.export.ExportWizard$1.run(ExportWizard.java:219)
	at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
Caused by: Proguard Error 1

      You should check if you need to specify additional program jars. 
Warning: there were 81 unresolved references to classes or interfaces. 
         You may need to specify additional library jars (using '-libraryjars'). 
Error: Please correct the above warnings first.
	at com.android.ide.eclipse.adt.internal.build.BuildHelper.runProguard(BuildHelper.java:590)
	at com.android.ide.eclipse.adt.internal.project.ExportHelper.exportReleaseApk(ExportHelper.java:265)
	... 4 more

为了找到根本原因,就把Afinal相关的资源删掉了, 打包,没有出现问题了.但是,把Afinal的资源添加上之后,打包又报错了.好吧,那就从混淆代码开始吧.

1.Afinal 的混淆操作.

-libraryjars libs/Afinal-0.3.4.jar 
-dontwarn net.tsz.afinal.** 
-keep class net.tsz.afinal.** { *; } 
-keep public class * extends net.tsz.afinal.**  
-keep public interface net.tsz.afinal.** {*;}
-keepattributes Signature
-keepattributes *Annotation* 

在proguard.cfg 添加上上面的内容,打包时,不混淆Afinal 的jar包.执行打包操作,结果仍然报错.


2.报错信息

org.eclipse.core.runtime.CoreException: Proguard returned with error code 1. See console
	at com.android.ide.eclipse.adt.internal.project.ExportHelper.exportReleaseApk(ExportHelper.java:301)
	at com.android.ide.eclipse.adt.internal.wizards.export.ExportWizard.doExport(ExportWizard.java:305)
	at com.android.ide.eclipse.adt.internal.wizards.export.ExportWizard.access$0(ExportWizard.java:234)
	at com.android.ide.eclipse.adt.internal.wizards.export.ExportWizard$1.run(ExportWizard.java:219)
	at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
Caused by: Proguard Error 1

      You should check if you need to specify additional program jars. 
Warning: there were 81 unresolved references to classes or interfaces. 
         You may need to specify additional library jars (using '-libraryjars'). 
Error: Please correct the above warnings first.
	at com.android.ide.eclipse.adt.internal.build.BuildHelper.runProguard(BuildHelper.java:590)
	at com.android.ide.eclipse.adt.internal.project.ExportHelper.exportReleaseApk(ExportHelper.java:265)
	... 4 more

3.找到问题

查看libs下面的jar包,比对proguard.cfg ,把没有添加的包,同样添加上Afinal的代码,打包时不混淆.

执行打包操作,结果仍然报错.


4.查看报错信息

Warning: com.android.util.CustomChartUtil: can't find referenced class org.achartengine.renderer.SimpleSeriesRenderer 
Warning: com.android.util.HttpClientHander: can't find referenced class org.apache.http.client.entity.GzipDecompressingEntity 
Warning: com.android.util.HttpClientHander: can't find referenced class org.apache.http.client.entity.GzipDecompressingEntity 
Warning: com.android.util.HttpClientTaskHander: can't find referenced class org.apache.http.client.entity.GzipDecompressingEntity 
Warning: com.android.util.HttpClientTaskHander: can't find referenced class org.apache.http.client.entity.GzipDecompressingEntity 


Warning: com.android.util.CustomChartUtil: can't find referenced class org.achartengine.renderer.XYMultipleSeriesRenderer 
Warning: com.android.util.CustomChartUtil: can't find referenced class org.achartengine.renderer.XYMultipleSeriesRenderer 
Warning: com.android.util.CustomChartUtil: can't find referenced class org.achartengine.renderer.XYMultipleSeriesRenderer 
Warning: com.android.util.CustomChartUtil: can't find referenced class org.achartengine.renderer.XYMultipleSeriesRenderer 
Warning: com.android.util.CustomChartUtil: can't find referenced class org.achartengine.renderer.XYMultipleSeriesRenderer 
Warning: com.android.util.CustomChartUtil: can't find referenced class org.achartengine.renderer.XYMultipleSeriesRenderer 

根据上面的信息,发现是找不到org.achartengine.renderer.** 文件和org.apache.http.** 文件,这样就简单了,查询可以知道,这两个类对应的是achartengine.jar和httpmime.jar.  拷贝这两个类,到项目中的libs下面.同样在proguard.cfg 中添加不混淆操作.


4.执行打包操作.

完美的打包出来了.反编译看一下,的的确确是被混淆了.


5.不解的地方


虽然是混淆成功,并打包成功了,但是,在项目中并没有用到achartengine.jar中的类文件.也算是遗留的问题了.


版权声明: 举报

相关文章推荐

dotfuscator 在混淆.Net Framework 4.0以上版本的时候报错的解决方法

在混淆的时候报错了,错误描述大致如下: Could not find a compatible version of ildasm to run on assembly C:\xxx.dll This...

Java @override报错的解决方法

       有时候Java的MyEclipse工程换一台电脑后编译总是@override报错,把@override去掉就好了,但不能从根本上解决问题,因为有时候有@override的地方超级多。 <p style="color: #333333; font-fa

使用正式签名打包APK,打开debug模式报错的问题解决方法

SDK Tools Revision 8以后,如果在AndroidManifest.xml中直接设置打开debug模式: 1 android:debuggable="tru...

Java @override报错的解决方法

有时候Java的Eclipse工程换一台电脑后编译总是@override报错,把@override去掉就好了,但不能从根本上解决问题,因为有时候有@override的地方超级多。 这是jdk的问题,@Override是JDK5就已经有了,但是不支持对接口的实现,认为这不是Override而报错。JDK6修正了这个Bug,无论是对父类的方法覆盖还是对接口的实现都可以加上@Override。 要解决该问题,首先要确保机器上安装了j

使用Mac版Eclipse开发Android程序混淆签名打包的一个报错解决方法

使用Mac版Eclipse开发Android程序混淆签名打包的时候在控制台报了个错
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)