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中的类文件.也算是遗留的问题了.


版权声明:

相关文章推荐

关于AFinal的混淆

关于AFinal的混淆的问题解决

解决混淆报错问题-打包签名出现问题的解决方法

这个问题比较烦人,主要是因为使用了激光推送的功能,然后打包文件发布apk的时候出现了问题,导致了以下的一大堆的错误,不过大家勿急,有解决办法。 [2013-11-28 13:17:19 - Sjh_...

网表导入报错解决方法

  • 2014-03-14 00:33
  • 567KB
  • 下载

ajaxFileUpload报错$.ajaxFileUpload is not a function解决方法

报错信息Uncaught TypeError:$.ajaxFileUpload is not a function 大意就是,ajaxFileUpload这个函数未定义错误背景我使用了ajaxFil...

Word重复报错解决方法

  • 2012-12-03 09:02
  • 225B
  • 下载

报错:Maximum execution time of 30 seconds exceeded解决方法

今天遇到报错,由于有个特殊请求的等待时间很难做到在30s内。 就会出现Maximum execution time of 30 seconds exceeded这个错误。 ...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

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