Android ProGuard error with org.xmlpull.v1.XmlPullParser

99封情书 提交于 2019-12-03 05:21:42

add this line to proguard-project.txt

-dontwarn org.xmlpull.v1.**

and this line to project.properties

proguard.config=proguard-project.txt

I solved this using this settings in the proguard file:

-dontwarn org.kobjects.**
-dontwarn org.ksoap2.**
-dontwarn org.kxml2.**
-dontwarn org.xmlpull.v1.**

-keep class org.kobjects.** { *; }
-keep class org.ksoap2.** { *; }
-keep class org.kxml2.** { *; }
-keep class org.xmlpull.** { *; }

-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontoptimize
-dontpreverify

I don't have the solution yet for proguard run via eclipse for android, but if you run proguard manually from the command line, you can put the following in your proguard.cfg:

-basedirectory /home/pjv/workspace/collectionista-repo/collectionista-main

-injars /tmp/android_4500371803543847111.jar
-injars libs/joda-time-1.6.jar(!META-INF/MANIFEST.MF)
-injars libs/FlurryAgent.jar(!META-INF/MANIFEST.MF)
-injars libs/veecheck-2.0.jar(!META-INF/MANIFEST.MF)
-injars libs/commons-lang-2.4.jar(!META-INF/MANIFEST.MF,!META-INF/NOTICE.txt,!META-INF/LICENSE.txt)
-injars libs/OIAbout-lib-temporary.jar(!META-INF/MANIFEST.MF)
-injars libs/libGoogleAnalytics.jar(!META-INF/MANIFEST.MF)
-injars libs/xstream-1.3.1.jar(!META-INF/MANIFEST.MF)
-injars libs/ZQL_custom.jar(!META-INF/MANIFEST.MF)
-injars libs/xpp3_min-1.1.4c.jar(!META-INF/MANIFEST.MF)
-injars libs/GoogleAdMobAdsSdk-4.1.0.jar(!META-INF/MANIFEST.MF)
-injars libs/bugsense-trace.jar(!META-INF/MANIFEST.MF)
-outjars /tmp/android_1348923171424559204.jar

-libraryjars /opt/android-sdk/android-sdk-linux_x86-1.6_r1/platforms/android-12/android.jar(!org/xmlpull/v1/XmlPullParser.class,!org/xmlpull/v1/XmlPullParserException.class)

Note how XmlPullParser.class is filtered from the android API jar.

Don't worry about the warnings related to XmlPullParser just yet. Fix the errors and other warnings first, and if you must, use -ignorewarnings in your proguard.cfg.

LeOnLee

I think your jar package include XmlPullParser class, and android.jar also include this. So you can remove org.xmlpull.* classes in the jar package, and build again.

According to the partial log that you provide, the Android runtime class org.xmlpull.v1.XmlPullParser has ended up in your program code. You should make sure it is not present in bin/classes or in some jar in lib, because it is already present in the library jar android.jar.

Furthermore, you have 4247 duplicate class definitions. This is probably due to specifying "some -libraryjars" as you mention. I'm guessing these library jars are already included automatically by the build script, so you shouldn't specify them again.

The dependency already exist on your folder,

exclude it like below:

dependencies {
  configurations {
      all*.exclude group: 'xmlpull', module: 'xmlpull'

  }
}

Sometimes it happens when you include one of your test libraries as a regular module dependency. For example don't do:

implementation 'com.android.support.test:runner:1.0.2' //wrong!!

do:

androidTestImplementation 'com.android.support.test:runner:1.0.2' //right (:

for me I could solve it by removing my previous modified build.gradle

I removed:

     minifyEnabled true

     shrinkResources true

and returned to the original setting

minifyEnabled false
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!