我在我的项目中使用v4兼容包,但是当我尝试导出已签名的应用程序时,我从Proguard收到以下消息。我整个晚上都用Google搜索,但我找不到解决这个问题的答案。
[2011-07-03 01:46:29 - worldscopeApp] Proguard returned with error code 1. See console
[2011-07-03 01:46:29 - worldscopeApp] Warning: android.support.v4.app.ActivityCompatHoneycomb: can't find referenced method 'void invalidateOptionsMenu()' in class android.app.Activity
[2011-07-03 01:46:29 - worldscopeApp] 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-07-03 01:46:29 - worldscopeApp] Warning: android.support.v4.view.MenuCompatHoneycomb: can't find referenced method 'void setShowAsAction(int)' in class android.view.MenuItem
[2011-07-03 01:46:29 - worldscopeApp] You should check if you need to specify additional program jars.
[2011-07-03 01:46:29 - worldscopeApp] Warning: there were 3 unresolved references to program class members.
[2011-07-03 01:46:29 - worldscopeApp] Your input classes appear to be inconsistent.
[2011-07-03 01:46:29 - worldscopeApp] You may need to recompile them and try again.
[2011-07-03 01:46:29 - worldscopeApp] Alternatively, you may have to specify the options
[2011-07-03 01:46:29 - worldscopeApp] '-dontskipnonpubliclibraryclasses' and/or
[2011-07-03 01:46:29 - worldscopeApp] '-dontskipnonpubliclibraryclassmembers'.
[2011-07-03 01:46:29 - worldscopeApp] java.io.IOException: Please correct the above warnings first.
[2011-07-03 01:46:29 - worldscopeApp] at proguard.Initializer.execute(Initializer.java:308)
[2011-07-03 01:46:29 - worldscopeApp] at proguard.ProGuard.initialize(ProGuard.java:210)
[2011-07-03 01:46:29 - worldscopeApp] at proguard.ProGuard.execute(ProGuard.java:85)
[2011-07-03 01:46:29 - worldscopeApp] at proguard.ProGuard.main(ProGuard.java:499)
答案 0 :(得分:34)
看起来android.support.v4中的一些clases与android中的某些类不完全兼容。如果您确定这不是问题,可以指定
-dontwarn android.support.v4.**
然后,ProGuard将忽略这些问题并继续处理代码。
请参阅ProGuard手册>疑难解答>警告:找不到引用的字段/方法
答案 1 :(得分:26)
这就是我在proguard.cfg中使用的内容:
-dontwarn **CompatHoneycomb
-keep public class * extends android.support.v4.app.Fragment
更一般的是:
-dontwarn **CompatHoneycomb
-keep class android.support.v4.** { *; }
但是它会导致更大的APK大小,所以只有在第一个不起作用时才会使用。
答案 2 :(得分:0)
您应该将android:targetSdkVersion设置为SDK> =蜂窝。
有关我使用此信息的信息
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="13"/>