ProGuard and HoloEverywhere: Export Signed Application Errors

蹲街弑〆低调 提交于 2019-12-12 03:03:23

问题


I'm using ActionBarSherlock and HoloEverywhere in my project. Everything works perfectly, except when I try to export my signed application, ProGuard gives me grief:

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

I tried including the following lines in my proguard-project.txt, but it didn't seem to do anything:

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

This is my 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

This is my 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.**

Anyone know how to fix this?


回答1:


I needed to add the following two lines:

-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



回答2:


Grief is right. I have never used ProGuard but I know what it is. Here is some information I hope it helps.

According to ProGuards website

NoSuchMethodException

Your code is probably calling something like myClass.getMethod, trying to find some method dynamically. Since ProGuard can't always detect this automatically, you have to keep the missing method in using the appropriate -keep option, e.g. "-keepclassmembers class mypackage.MyClass { void myMethod(); }".

More specifically, if the method reported as missing is values or valueOf, you probably have to keep some methods related to enumerations.

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

All so look at the related topics to the right side ->> >> >>

Hope this helps or helps point you in the right direction.



来源:https://stackoverflow.com/questions/16631392/proguard-and-holoeverywhere-export-signed-application-errors

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