Proguard error when exporting signed app using android.support.v4.app honeycomb compatibility package

試著忘記壹切 提交于 2019-11-27 01:03:32

问题


I am using v4 compatibility package in my project, but when I try to export a signed app, I get the following message from Proguard. I've Googled the whole evening, but I didn't find the answer to solve this.

[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)

回答1:


This is what I'm using in my proguard.cfg:

-dontwarn **CompatHoneycomb
-keep public class * extends android.support.v4.app.Fragment

More general is:

-dontwarn **CompatHoneycomb
-keep class android.support.v4.** { *; }

But it'll cause a larger APK size so only use if the first one isn't working.




回答2:


It looks like some clases in android.support.v4 are not quite compatible with some classes in android. If you're sure this is not a problem, you can specify

-dontwarn android.support.v4.**

ProGuard will then ignore these problems and continue processing the code.

See the ProGuard manual > Troubleshooting > Warning: can't find referenced field/method




回答3:


You should set the android:targetSdkVersion to an SDK >= honeycomb.

For information I am using this one

<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="13"/>


来源:https://stackoverflow.com/questions/6560244/proguard-error-when-exporting-signed-app-using-android-support-v4-app-honeycomb

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