微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

org.xmlpull.v1.XmlPullParser导致Android ProGuard错误

如何解决org.xmlpull.v1.XmlPullParser导致Android ProGuard错误

| 使用ProGuard构建我的应用程序时,它失败并显示以下消息。 我将Android SDK生成认proguard.cfg与-libraryjars一起使用。 我该怎么办?
[2011-03-17 09:27:04 - MyProject] Proguard returned with error code 1. See console
[2011-03-17 09:27:04 - MyProject] Note: there were 4247 duplicate class deFinitions.
[2011-03-17 09:27:04 - MyProject] Warning: library class android.content.res.XmlResourceParser extends or implements program class org.xmlpull.v1.XmlPullParser
[2011-03-17 09:27:04 - MyProject] Warning: library class android.content.Intent depends on program class org.xmlpull.v1.XmlPullParser
[2011-03-17 09:27:04 - MyProject] Warning: library class android.graphics.drawable.AnimationDrawable depends on program class org.xmlpull.v1.XmlPullParser
[2011-03-17 09:27:04 - MyProject] Warning: library class android.graphics.drawable.BitmapDrawable depends on program class org.xmlpull.v1.XmlPullParser
[2011-03-17 09:27:04 - MyProject] Warning: library class android.graphics.drawable.Drawable depends on program class org.xmlpull.v1.XmlPullParser
[2011-03-17 09:27:04 - MyProject] Warning: library class android.graphics.drawable.Drawable depends on program class org.xmlpull.v1.XmlPullParser
[2011-03-17 09:27:04 - MyProject] Warning: library class android.graphics.drawable.Drawable depends on program class org.xmlpull.v1.XmlPullParser
[2011-03-17 09:27:04 - MyProject] Warning: library class android.view.LayoutInflater depends on program class org.xmlpull.v1.XmlPullParser
[2011-03-17 09:27:04 - MyProject] Warning: library class android.view.LayoutInflater depends on program class org.xmlpull.v1.XmlPullParser
[2011-03-17 09:27:04 - MyProject]       You should check if you need to specify additional program jars.
[2011-03-17 09:27:04 - MyProject] Warning: there were 9 instances of library classes depending on program classes.
[2011-03-17 09:27:04 - MyProject]          You must avoid such dependencies,since the program classes will
[2011-03-17 09:27:04 - MyProject]          be processed,while the library classes will remain unchanged.
[2011-03-17 09:27:04 - MyProject] java.io.IOException: Please correct the above warnings first.
[2011-03-17 09:27:04 - MyProject]   at proguard.Initializer.execute(Initializer.java:321)
[2011-03-17 09:27:04 - MyProject]   at proguard.ProGuard.initialize(ProGuard.java:211)
[2011-03-17 09:27:04 - MyProject]   at proguard.ProGuard.execute(ProGuard.java:86)
[2011-03-17 09:27:04 - MyProject]   at proguard.ProGuard.main(ProGuard.java:492)
显然,org.xmlpull.v1.XmlPullParser不是程序类。 我已经将ProGuard更新到最新版本(4.6),但是有相同的警告。     

解决方法

        将此行添加到proguard-project.txt
-dontwarn org.xmlpull.v1.**
这行到project.properties
proguard.config=proguard-project.txt
    ,        我在proguard文件中使用以下设置解决了此问题:
-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
    ,        我还没有通过eclipse在android上运行proguard的解决方案,但是如果您从命令行手动运行proguard,则可以在
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)
请注意如何从Android API jar中过滤“ 6”。 不必担心与ѭ7有关的警告。首先更正错误和其他警告,如果必须,请在
proguard.cfg
中使用
-ignorewarnings
。     ,        我认为您的jar包中包含
XmlPullParser
类,而android.jar也包含此类。 因此,您可以删除jar包中的
org.xmlpull.*
类,然后重新进行构建。     ,        根据您提供的部分日志,Android运行时类org.xmlpull.v1.XmlPullParser已经出现在您的程序代码中。您应确保它不存在于bin / classs或lib中的某个jar中,因为它已经存在于库jar android.jar中。 此外,您有4247个重复的类定义。正如您提到的,这可能是由于指定了\“ some -libraryjars \”。我猜这些库jar已经被构建脚本自动包含了,所以您不应该再次指定它们。     ,        依赖关系已存在于您的文件夹中, 排除它,如下所示:
dependencies {
  configurations {
      all*.exclude group: \'xmlpull\',module: \'xmlpull\'

  }
}
    ,        有时,当您将一个测试库作为常规模块依赖项包含在内时,就会发生这种情况。例如,不要执行以下操作:
implementation \'com.android.support.test:runner:1.0.2\' //wrong!!
做:
androidTestImplementation \'com.android.support.test:runner:1.0.2\' //right (:
    ,        对我来说,我可以通过删除以前修改过的build.gradle来解决 我删除了:
     minifyEnabled true

     shrinkResources true
并返回到原始设置
minifyEnabled false
    

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。