天天看点

android打包引用第三方jar出现的错误

今天终于完成了近一个月的app开发工作,对程序进行混淆导出签名apk包时,却出现了如下的错误:

proguard returned with error code 1. see console

note: there were 4 duplicate class definitions.

warning: library class android.content.res.xmlresourceparser extends or implements program class org.xmlpull.v1.xmlpullparser

warning: library class android.content.intent depends on program class org.xmlpull.v1.xmlpullparser

。。。

心里想着,真是好事多磨呀!

那就赶紧问度娘呀,终于在一位网友那里找到了答案。

对于android导入了第三方jar包时,proguard混淆脚本会出现错误,而出现上面的错误是因为程序中引入了第三方jar包[ksoap2-android-assembly-2.6.5-jar-with-dependencies.jar],二话不说,立马行动:

在proguard-project.txt中增加了

-ignorewarnings

-libraryjars lib/ksoap2-android-assembly-2.5.4-jar-with-dependencies.jar (jar包路径)

即在文件中增加了如下红色的两行:

-dontusemixedcaseclassnames

-dontskipnonpubliclibraryclasses

-verbose

# optimization is turned off by default. dex does not like code run

# through the proguard optimize and preverify steps (and performs some

# of these optimizations on its own).

-dontoptimize

#-dontoptimize

# note that if you want to enable optimization, you cannot just

# include optimization flags in your own project configuration file;

# instead you will need to point to the

# "proguard-android-optimize.txt" file instead of this one from your

# project.properties file.

-libraryjars libs/ksoap2-android-assembly-2.6.5-jar-with-dependencies.jar 

-keepattributes *annotation*

-keep public class com.google.vending.licensing.ilicensingservice

-keep public class com.android.vending.licensing.ilicensingservice

继续阅读