0

我在我的項目中使用了ActionBarSherlock和HoloEverywhere。一切都完美的作品,除了當我嘗試導出我的簽名的應用程序,ProGuard的帶給我的悲傷:ProGuard和HoloEverywhere:導出簽名的應用程序錯誤

[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

我需要添加以下兩行:

-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 
0

悲傷是對的。我從未使用ProGuard,但我知道它是什麼。這裏有一些我希望能幫到的信息。

據ProGuards網站

NoSuchMethodException

您的代碼可能調用類似myClass.getMethod,試圖動態找到一些方法。由於ProGuard不能總是自動檢測到這種情況,因此必須使用適當的-keep選項使缺少的方法保持不變,例如, 「-keepclassmembers class mypackage.MyClass {void myMethod();}」。

更具體地說,如果報告缺失的方法是values或valueOf,則可能必須保留與枚舉相關的一些方法。

類似Overstack問題 Proguard error when exporting signed app using android.support.v4.app honeycomb compatibility package

所有所以看相關主題右側 - >> >> >>

希望這有助於幫助或指向你在正確的方向。

+0

這裏的大多數各地正在處理忽略了警告,我已經能夠做的一樣好主題。然而,這樣做會破壞使用ProGuard的目的,因爲我的APK發佈爲21 MB。 –

+0

我很高興你解決了你的問題。如果我不知道確切的答案,我只是通過提供相關信息來嘗試和幫助。但我真的很高興你自己解決了這個問題。你現在不會忘記它:)好工作的人! – RedRumming

相關問題