0

我在我的项目中使用 ActionBarSherlock 和 HoloEverywhere。一切正常,除了当我尝试导出我签名的应用程序时,ProGuard 让我很伤心:

[2013-05-19 00:13:53 - ] Proguard returned with error code 1. See console
[2013-05-19 00:13:53 - ] Warning: com.actionbarsherlock.widget.SuggestionsAdapter: can't find referenced field 'android.content.Context mContext' in class com.actionbarsherlock.widget.SuggestionsAdapter
[2013-05-19 00:13:53 - ] Warning: com.actionbarsherlock.widget.SuggestionsAdapter: can't find referenced method 'android.database.Cursor getCursor()' in class com.actionbarsherlock.widget.SuggestionsAdapter
[2013-05-19 00:13:53 - ] Warning: com.actionbarsherlock.widget.SuggestionsAdapter: can't find referenced field 'android.database.Cursor mCursor' in class com.actionbarsherlock.widget.SuggestionsAdapter
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.ChooserActivity: can't find referenced method 'android.content.Intent getIntent()' in class org.holoeverywhere.ChooserActivity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.ChooserActivity: can't find referenced method 'void finish()' in class org.holoeverywhere.ChooserActivity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.ChooserActivity: can't find referenced method 'android.content.res.Resources getResources()' in class org.holoeverywhere.ChooserActivity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.ThemeManager: can't find referenced method 'android.content.Intent getIntent()' in class org.holoeverywhere.app.Activity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.ThemeManager: can't find referenced method 'boolean isRestricted()' in class org.holoeverywhere.app.Activity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.ThemeManager: can't find referenced method 'boolean isFinishing()' in class org.holoeverywhere.app.Activity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.ThemeManager: can't find referenced method 'void finish()' in class org.holoeverywhere.app.Activity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.ThemeManager: can't find referenced method 'void overridePendingTransition(int,int)' in class org.holoeverywhere.app.Activity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.Activity: can't find referenced method 'android.content.Intent getIntent()' in class org.holoeverywhere.app.Activity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.Activity: can't find referenced method 'android.content.res.Resources getResources()' in class org.holoeverywhere.app.Activity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.Activity: can't find referenced method 'android.view.Window getWindow()' in class org.holoeverywhere.app.Activity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.Activity: can't find referenced method 'java.lang.ClassLoader getClassLoader()' in class org.holoeverywhere.app.Activity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.Activity$24: can't find referenced method 'boolean requestWindowFeature(int)' in class org.holoeverywhere.app.Activity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.AlertActivity: can't find referenced method 'void finish()' in class org.holoeverywhere.app.AlertActivity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.AlertActivity: can't find referenced method 'boolean isFinishing()' in class org.holoeverywhere.app.AlertActivity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.AlertActivity: can't find referenced method 'android.view.Window getWindow()' in class org.holoeverywhere.app.AlertActivity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.AlertActivity: can't find referenced method 'boolean onKeyDown(int,android.view.KeyEvent)' in class org.holoeverywhere.app.Activity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.AlertActivity: can't find referenced method 'boolean onKeyUp(int,android.view.KeyEvent)' in class org.holoeverywhere.app.Activity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.DialogFragment: can't find referenced method 'android.support.v4.app.FragmentManager getFragmentManager()' in class org.holoeverywhere.app.DialogFragment
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.DialogFragment: can't find referenced method 'android.support.v4.app.FragmentActivity getActivity()' in class org.holoeverywhere.app.DialogFragment
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.DialogFragment: can't find referenced method 'void onActivityCreated(android.os.Bundle)' in class org.holoeverywhere.app.Fragment
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.DialogFragment: can't find referenced method 'android.view.View getView()' in class org.holoeverywhere.app.DialogFragment
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.DialogFragment: can't find referenced method 'void onDetach()' in class org.holoeverywhere.app.Fragment
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.DialogFragment: can't find referenced method 'void onSaveInstanceState(android.os.Bundle)' in class org.holoeverywhere.app.Fragment
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.DialogFragment: can't find referenced method 'void onStart()' in class org.holoeverywhere.app.Fragment
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.DialogFragment: can't find referenced method 'void onStop()' in class org.holoeverywhere.app.Fragment
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.DialogFragment: can't find referenced method 'java.lang.CharSequence getText(int)' in class org.holoeverywhere.app.DialogFragment
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.ExpandableListActivity: can't find referenced method 'void onRestoreInstanceState(android.os.Bundle)' in class org.holoeverywhere.app.Activity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.Fragment: can't find referenced method 'void setArguments(android.os.Bundle)' in class org.holoeverywhere.app.Fragment
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.GridFragment: can't find referenced method 'android.view.View getView()' in class org.holoeverywhere.app.GridFragment
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.GridFragment: can't find referenced method 'android.support.v4.app.FragmentActivity getActivity()' in class org.holoeverywhere.app.GridFragment
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.ListActivity: can't find referenced method 'void onRestoreInstanceState(android.os.Bundle)' in class org.holoeverywhere.app.Activity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.ListFragment: can't find referenced method 'android.view.View getView()' in class org.holoeverywhere.app.ListFragment
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.ListFragment: can't find referenced method 'android.support.v4.app.FragmentActivity getActivity()' in class org.holoeverywhere.app.ListFragment
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.ResolverActivity: can't find referenced method 'android.content.res.Resources getResources()' in class org.holoeverywhere.app.ResolverActivity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.ResolverActivity: can't find referenced method 'android.content.Intent getIntent()' in class org.holoeverywhere.app.ResolverActivity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.ResolverActivity: can't find referenced method 'android.content.pm.PackageManager getPackageManager()' in class org.holoeverywhere.app.ResolverActivity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.ResolverActivity: can't find referenced method 'java.lang.String getPackageName()' in class org.holoeverywhere.app.ResolverActivity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.ResolverActivity: can't find referenced method 'void finish()' in class org.holoeverywhere.app.ResolverActivity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.ResolverActivity: can't find referenced method 'void onRestoreInstanceState(android.os.Bundle)' in class org.holoeverywhere.app.AlertActivity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.ResolverActivity: can't find referenced method 'boolean isChangingConfigurations()' in class org.holoeverywhere.app.ResolverActivity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.ResolverActivity$ResolveListAdapter: can't find referenced method 'void finish()' in class org.holoeverywhere.app.ResolverActivity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.ResolverActivity$ResolveListAdapter: can't find referenced method 'android.content.pm.PackageManager getPackageManager()' in class org.holoeverywhere.app.ResolverActivity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.TabSwipeActivity: can't find referenced method 'boolean isDetached()' in class org.holoeverywhere.app.TabSwipeActivity$InnerFragment
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.TabSwipeFragment: can't find referenced method 'java.lang.CharSequence getText(int)' in class org.holoeverywhere.app.TabSwipeFragment
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.TabSwipeFragment: can't find referenced method 'void notifyDataSetChanged()' in class org.holoeverywhere.app.TabSwipeFragment$TabSwipeAdapter
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.TabSwipeFragment$TabSwipeAdapter: can't find referenced method 'android.support.v4.app.FragmentManager getChildFragmentManager()' in class org.holoeverywhere.app.TabSwipeFragment
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.internal.AlertController$AlertParams$2: can't find referenced method 'android.database.Cursor getCursor()' in class org.holoeverywhere.internal.AlertController$AlertParams$2
[2013-05-19 00:13:53 - ]       You should check if you need to specify additional program jars.
[2013-05-19 00:13:53 - ] Warning: there were 51 unresolved references to program class members.
[2013-05-19 00:13:53 - ]          Your input classes appear to be inconsistent.
[2013-05-19 00:13:53 - ]          You may need to recompile them and try again.
[2013-05-19 00:13:53 - ]          Alternatively, you may have to specify the option 
[2013-05-19 00:13:53 - ]          '-dontskipnonpubliclibraryclassmembers'.
[2013-05-19 00:13:53 - ] java.io.IOException: Please correct the above warnings first.
[2013-05-19 00:13:53 - ]    at proguard.Initializer.execute(Initializer.java:321)
[2013-05-19 00:13:53 - ]    at proguard.ProGuard.initialize(ProGuard.java:211)
[2013-05-19 00:13:53 - ]    at proguard.ProGuard.execute(ProGuard.java:86)
[2013-05-19 00:13:53 - ]    at proguard.ProGuard.main(ProGuard.java:492)

我尝试在我的 proguard-project.txt 中包含以下几行,但它似乎没有做任何事情:

-keep class com.actionbarsherlock.** {*;}
-keep class org.holoeverywhere.** {*;}

这是我的 project.properties:

# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
proguard.config=${sdk.dir}\\tools\\proguard\\proguard-android.txt:proguard-project.txt

# Project target.
target=android-17
android.library.reference.1=../../../Downloads/JakeWharton-ActionBarSherlock-4.3.1-0-gc0d437c/JakeWharton-ActionBarSherlock-071a61c/actionbarsherlock
android.library.reference.2=../../../Downloads/HoloEverywhere-master (1)/HoloEverywhere-master/library

这是我的 proguard-project.txt

# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
#   http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
#   public *;
#}
-keep class com.actionbarsherlock.** 
-keep class org.holoeverywhere.**

有人知道怎么修这个东西吗?

4

2 回答 2

4

我需要添加以下两行:

-libraryjars adt-bundle-windows-x86_64/sdk/platforms/android-17/android.jar
-libraryjars adt-bundle-windows-x86_64/sdk/extras/android/support/v4/android-support-v4.jar
于 2013-05-20T21:23:48.627 回答
0

悲伤是对的。我从未使用过 ProGuard,但我知道它是什么。这里有一些信息,希望对您有所帮助。

根据 ProGuards 网站

NoSuchMethodException

您的代码可能正在调用 myClass.getMethod 之类的东西,试图动态查找某些方法。由于 ProGuard 不能始终自动检测到这一点,因此您必须在使用适当的 -keep 选项时保留缺少的方法,例如“-keepclassmembers class mypackage.MyClass { void myMethod(); }”。

更具体地说,如果报告为缺失的方法是 values 或 valueOf,您可能必须保留一些与枚举相关的方法。

使用 android.support.v4.app 蜂窝兼容包导出签名应用时出现类似的 Overstack 问题 Proguard 错误

都那么看右边的相关话题->>>>>>

希望这有助于或帮助您指出正确的方向。

于 2013-05-19T06:33:09.003 回答