有谁能帮助我,我在我的Android应用程序中使用ProGuard,我得到以下错误,而我签署它导出。
这是我的控制台显示给我的。
[2011-11-03 16:07:52 - AndroidViewPager] Proguard returned with error code 1. See console
[2011-11-03 16:07:52 - AndroidViewPager] Note: there were 95 duplicate class definitions.
[2011-11-03 16:07:52 - AndroidViewPager] Warning: android.support.v4.os.ParcelableCompatCreatorHoneycombMR2: can't find superclass or interface android.os.Parcelable$ClassLoaderCreator
[2011-11-03 16:07:52 - AndroidViewPager] Warning: android.support.v4.app.ActivityCompatHoneycomb: can't find referenced method 'void invalidateOptionsMenu()' in class android.app.Activity
[2011-11-03 16:07:52 - AndroidViewPager] Warning: android.support.v4.app.ActivityCompatHoneycomb: can't find referenced method 'void dump(java.lang.String,java.io.FileDescriptor,java.io.PrintWriter,java.lang.String[])' in class android.app.Activity
[2011-11-03 16:07:52 - AndroidViewPager] Warning: android.support.v4.os.ParcelableCompatCreatorHoneycombMR2: can't find referenced class android.os.Parcelable$ClassLoaderCreator
[2011-11-03 16:07:52 - AndroidViewPager] Warning: android.support.v4.os.ParcelableCompatCreatorHoneycombMR2: can't find referenced class android.os.Parcelable$ClassLoaderCreator
[2011-11-03 16:07:52 - AndroidViewPager] Warning: android.support.v4.view.MenuCompatHoneycomb: can't find referenced method 'void setShowAsAction(int)' in class android.view.MenuItem
[2011-11-03 16:07:52 - AndroidViewPager] Warning: there were 3 unresolved references to classes or interfaces.
[2011-11-03 16:07:52 - AndroidViewPager] You may need to specify additional library jars (using '-libraryjars'),
[2011-11-03 16:07:52 - AndroidViewPager] or perhaps the '-dontskipnonpubliclibraryclasses' option.
[2011-11-03 16:07:52 - AndroidViewPager] Warning: there were 3 unresolved references to program class members.
[2011-11-03 16:07:52 - AndroidViewPager] Your input classes appear to be inconsistent.
[2011-11-03 16:07:52 - AndroidViewPager] You may need to recompile them and try again.
[2011-11-03 16:07:52 - AndroidViewPager] Alternatively, you may have to specify the options
[2011-11-03 16:07:52 - AndroidViewPager] '-dontskipnonpubliclibraryclasses' and/or
[2011-11-03 16:07:52 - AndroidViewPager] '-dontskipnonpubliclibraryclassmembers'.
[2011-11-03 16:07:52 - AndroidViewPager] java.io.IOException: Please correct the above warnings first.
[2011-11-03 16:07:52 - AndroidViewPager] at proguard.Initializer.execute(Initializer.java:308)
[2011-11-03 16:07:52 - AndroidViewPager] at proguard.ProGuard.initialize(ProGuard.java:210)
[2011-11-03 16:07:52 - AndroidViewPager] at proguard.ProGuard.execute(ProGuard.java:85)
[2011-11-03 16:07:52 - AndroidViewPager] at proguard.ProGuard.main(ProGuard.java:499)
我觉得罐子里可能有些东西不合适。如何指定额外的库jar,我使用以下Proguard.cfg文件
optimizationpasses 5
-dontpreverify
-verbose
-libraryjars 'E:HimanshuAndroidViewPagerlibsandroid-support-v4.jar'
-dontskipnonpubliclibraryclasses
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService
-keepclasseswithmembernames class * {
native <methods>;
}
-keepclasseswithmembernames class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembernames class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
将以下内容添加到proguard.cfg中对我有效。我认为这是因为你没有使用蜂巢,但兼容性库中有一些蜂巢特有的东西。
-dontwarn CompatHoneycomb -keep class android.support.v4. { *; }
-dontwarn **CompatCreatorHoneycombMR2
-dontwarn **ActivityCompatHoneycomb
-dontwarn **MenuCompatHoneycomb
同时,删除
libraryjars 'E:HimanshuAndroidViewPagerlibsandroid-support-v4.jar'
我也有同样的问题。结果,我需要更新项目的构建目标。
看起来android-support-v4.jar的版本需要与项目构建目标版本匹配才能使proguard工作。在我的情况下,android-support-v4.jar revision 10
需要在Package Explorer Project> Properties> Android中设置构建目标Android 4.1.2 (API 16)
。
在AndroidManifest.xml
中,我仍然有android:targetSdkVersion="13"
集。此设置似乎与问题无关。
方法void setShowAsAction(int)
在兼容性库中不可用。尝试使用菜单的xml文件参数
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@[+][package:]id/resource_name"
android:title="string"
android:titleCondensed="string"
android:icon="@[package:]drawable/drawable_resource_name"
android:onClick="method name"
android:showAsAction=["ifRoom" | "never" | "withText" | "always" |
"collapseActionView"]
.../>
</menu>