用Android Proguard编译错误:找不到引用?

时间:2012-12-02 14:30:33

标签: android proguard

我尝试使用Proguard将我的代码导出到.apk文件但是收到了很多警告。我尝试了很多解决方案,但无法修复它。有什么想法吗?

[2012-12-02 22:24:05 - com.crossrt.showtime.Main] Warning: android.support.v4.widget.ScrollerCompatIcs: can't find referenced method 'float getCurrVelocity()' in class android.widget.Scroller
[2012-12-02 22:24:05 - com.crossrt.showtime.Main] Warning: android.support.v4.widget.SearchViewCompatHoneycomb$1: can't find referenced class android.widget.SearchView$OnQueryTextListener
[2012-12-02 22:24:05 - com.crossrt.showtime.Main] Warning: android.support.v4.widget.SearchViewCompatHoneycomb$1: can't find referenced class android.widget.SearchView
[2012-12-02 22:24:05 - com.crossrt.showtime.Main] Warning: there were 242 unresolved references to classes or interfaces.
[2012-12-02 22:24:05 - com.crossrt.showtime.Main]          You may need to specify additional library jars (using '-libraryjars').
[2012-12-02 22:24:05 - com.crossrt.showtime.Main] Warning: there were 47 unresolved references to program class members.
[2012-12-02 22:24:05 - com.crossrt.showtime.Main]          Your input classes appear to be inconsistent.
[2012-12-02 22:24:05 - com.crossrt.showtime.Main]          You may need to recompile them and try again.
[2012-12-02 22:24:05 - com.crossrt.showtime.Main]          Alternatively, you may have to specify the option 
[2012-12-02 22:24:05 - com.crossrt.showtime.Main]          '-dontskipnonpubliclibraryclassmembers'.
[2012-12-02 22:24:05 - com.crossrt.showtime.Main] java.io.IOException: Please correct the above warnings first.
[2012-12-02 22:24:05 - com.crossrt.showtime.Main]   at proguard.Initializer.execute(Initializer.java:321)
[2012-12-02 22:24:05 - com.crossrt.showtime.Main]   at proguard.ProGuard.initialize(ProGuard.java:211)
[2012-12-02 22:24:05 - com.crossrt.showtime.Main]   at proguard.ProGuard.execute(ProGuard.java:86)
[2012-12-02 22:24:05 - com.crossrt.showtime.Main]   at proguard.ProGuard.main(ProGuard.java:492)

1 个答案:

答案 0 :(得分:10)

支持类是指所有Android版本中不一定存在的运行时类和方法。他们确实以安全的方式处理这个问题:代码适用于所有Android版本 - 这就是他们的目的。因此,您可以在配置文件proguard-project.txt中告诉ProGuard忽略这些问题:

-dontwarn android.support.**

(CFR)。 ProGuard手册>疑难解答> Warning: can't find referenced class