现在的位置: 首页 > 综合 > 正文

Android 打包几种报错情况和解决办法proguard returned with error code 1.

2018年04月07日 ⁄ 综合 ⁄ 共 3900字 ⁄ 字号 评论关闭

情况1:

Proguard returned with error code 1. See console

Error: C:/Documents (系统找不到指定文件)

这个是因为有空格引起的,proguard进行发编译的时候是不允许有空格的。所以要注意工程所放位置是否有空格。

如果换了正确路径还不好用的话,直接删除proguard就好了

注意:SDK和程序路径最好不要有空格符

情况2:

Proguard returned with error code 1. See console

异常:

java.lang.ArrayIndexOutOfBoundsException

解决办法:将proguard.cfg中的"-dontpreverify"改成“-dontoptimize”

把项目中生成的proguard文件夹(此时文件夹是空的)删掉,然后再重新运行项目,就OK 了。

情况3:

Proguard returned with error code 1. See console
[2014-01-20 09:37:39 - DOYI] Warning: com.amap.api.maps.MapFragment: can't find superclass or interface android.app.Fragment
[2014-01-20 09:37:39 - DOYI] Warning: com.amap.api.maps.MapFragment: can't find referenced class android.app.Fragment
[2014-01-20 09:37:39 - DOYI] Warning: com.amap.api.maps.MapFragment: can't find referenced class android.app.Fragment
[2014-01-20 09:37:39 - DOYI] Warning: com.amap.api.maps.MapFragment: can't find referenced class android.app.Fragment
[2014-01-20 09:37:39 - DOYI] Warning: com.amap.api.maps.MapFragment: can't find referenced class android.app.Fragment
[2014-01-20 09:37:39 - DOYI] Warning: com.amap.api.maps.MapFragment: can't find referenced class android.app.Fragment
[2014-01-20 09:37:39 - DOYI] Warning: com.amap.api.maps.MapFragment: can't find referenced class android.app.Fragment
[2014-01-20 09:37:39 - DOYI] Warning: com.amap.api.maps.MapFragment: can't find referenced class android.app.Fragment
[2014-01-20 09:37:39 - DOYI] Warning: com.amap.api.maps.MapFragment: can't find referenced class android.app.Fragment
[2014-01-20 09:37:39 - DOYI] Warning: com.amap.api.maps.MapFragment: can't find referenced class android.app.Fragment
[2014-01-20 09:37:39 - DOYI] Warning: com.amap.api.maps.MapFragment: can't find referenced class android.app.Fragment
[2014-01-20 09:37:39 - DOYI] Warning: com.amap.api.maps.MapFragment: can't find referenced class android.app.Fragment
[2014-01-20 09:37:39 - DOYI] Warning: com.amap.api.maps.MapFragment: can't find referenced class android.app.Fragment
[2014-01-20 09:37:39 - DOYI] Warning: com.amap.api.maps.MapFragment: can't find referenced method 'android.app.Activity getActivity()' in class com.amap.api.maps.MapFragment
[2014-01-20 09:37:39 - DOYI] Warning: com.amap.api.maps.MapFragment: can't find referenced method 'android.os.Bundle getArguments()' in class com.amap.api.maps.MapFragment
[2014-01-20 09:37:39 - DOYI] Warning: com.autonavi.aps.amapapi.Utils: can't find referenced class android.provider.Settings$Global
[2014-01-20 09:37:39 - DOYI] Warning: com.autonavi.aps.amapapi.Utils: can't find referenced class android.provider.Settings$Global
[2014-01-20 09:37:39 - DOYI] Warning: there were 15 unresolved references to classes or interfaces.
[2014-01-20 09:37:39 - DOYI]          You may need to specify additional library jars (using '-libraryjars').
[2014-01-20 09:37:39 - DOYI] Warning: there were 2 unresolved references to program class members.
[2014-01-20 09:37:39 - DOYI]          Your input classes appear to be inconsistent.
[2014-01-20 09:37:39 - DOYI]          You may need to recompile them and try again.
[2014-01-20 09:37:39 - DOYI]          Alternatively, you may have to specify the option 
[2014-01-20 09:37:39 - DOYI]          '-dontskipnonpubliclibraryclassmembers'.
[2014-01-20 09:37:39 - DOYI] java.io.IOException: Please correct the above warnings first.
[2014-01-20 09:37:39 - DOYI] at proguard.Initializer.execute(Initializer.java:321)
[2014-01-20 09:37:39 - DOYI] at proguard.ProGuard.initialize(ProGuard.java:211)
[2014-01-20 09:37:39 - DOYI] at proguard.ProGuard.execute(ProGuard.java:86)
[2014-01-20 09:37:39 - DOYI] at proguard.ProGuard.main(ProGuard.java:492)

抛出这样的异常的原因是第三方jar的引用路径不对,没有找到这个需要忽略混淆的jar包。

只需在你的proguard-project.txt中添加如下两行即可。

-ignorewarnings
-libraryjars libs/Android_Map_V2.0.4.jar


你可以根据你的项目提示,添加需要的jar。

下面是4.0打包办法!

其实Android 4.0要用ProGuard比2.3更简单:在Eclipse中打开工程目录下的project.properties文件,该文件中有以下两行:

To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):

proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

根据这段说明,只要将proguard.config前面的#去掉,就可以利用ProGuard来混淆代码了!当然,默认的设置是不带优化功能的,可以用以下设置来加上代码优化功能:

proguard.config=${sdk.dir}/tools/proguard/proguard-android-optimize.txt:proguard-project.txt

然后只要经过数字签名之类的编译后,代码就是混淆的了。

抱歉!评论已关闭.