当我的应用程序使用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),但有相同的警告。
答案 0 :(得分:22)
将此行添加到proguard-project.txt
-dontwarn org.xmlpull.v1.**
这行到project.properties
proguard.config=proguard-project.txt
答案 1 :(得分:9)
我使用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
答案 2 :(得分:2)
我还没有通过eclipse for 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中过滤XmlPullParser.class
。
不要担心与XmlPullParser
相关的警告。首先修复错误和其他警告,如果必须,请在-ignorewarnings
中使用proguard.cfg
。
答案 3 :(得分:1)
根据您提供的部分日志,Android运行时类org.xmlpull.v1.XmlPullParser已在程序代码中结束。您应该确保它不存在于 bin / classes 或 lib 中的某个jar中,因为它已经存在于库jar.maar.jar中。
此外,您有4247个重复的类定义。这可能是因为您提到了“some -libraryjars”。我猜这些库jar已经由构建脚本自动包含,所以你不应该再次指定它们。
答案 4 :(得分:1)
我认为你的jar包包含XmlPullParser
类,而android.jar也包括这个。
因此,您可以删除jar包中的org.xmlpull.*
类,然后重新构建。
答案 5 :(得分:0)
有时,当您包含一个测试库作为常规模块依赖项时,就会发生这种情况。例如,不要这样做:
androidTestImplementation 'com.android.support.test:runner:1.0.2' //right (:
这样做:
{{1}}
答案 6 :(得分:-1)
该依赖项已存在于您的文件夹中,
按如下所示排除它:
dependencies {
configurations {
all*.exclude group: 'xmlpull', module: 'xmlpull'
}
}
答案 7 :(得分:-7)
对我来说,我可以通过删除以前修改过的build.gradle来解决它。
我删除了:
minifyEnabled true
shrinkResources true
并返回原始设置
minifyEnabled false