Error importing HoloEverywhere

廉价感情. 提交于 2019-11-26 05:20:59

问题


First of all, I am new with Android. I am doing an app, and I am implementing a library called HoloEverywhere. This library use in the themes.xml the library ActionBar Sherlock. I have imported to my workspace ActionBar Sherlock and I have added it to HoloEverywhere. Next, I have added HoloEverywhere to my project, but when I try to use it, I have an error (I tried to use a button):

The following classes could not be instantiated:
- com.WazaBe.HoloEverywhere.ButtonHolo (Open Class, Show Error Log)
See the Error Log (Window > Show View) for more details.
Tip: Use View.isInEditMode() in your custom views to skip code when shown in Eclipse.

I put the path of the class in my layout, like this:

<com.WazaBe.HoloEverywhere.ButtonHolo
        android:layout_width=\"fill_parent\"
        android:layout_height=\"wrap_content\"
        android:text=\"@string/text\" />

How I can solve this problem and use this library in my project?. Thanks :) PS. Sorry for my english, I know it is not very good.


回答1:


Follow the steps below(taken from blog here) to add ActionBarSherlock

  1. Download the .zip/.tgz and extract it
  2. Go to eclipse and choose File->New-> Android Project
  3. Select Create project from existing source and then browse to the library folder inside extracted AndroidBarSherlock folder
  4. Build Target should be the latest(14 or15), but your minSdkVersion can be less (7 or 8)
  5. Press Finish
  6. Right click on the newly created project and go to Properties.
  7. Under the Android heading, you should see a section for Library with a checkbox IsLibrary. Make sure that's checked.
  8. Right click -> Properies on the project in which you wish to add AndroidBarSherlock under the Android heading and the Library section choose Add.
  9. You should see the ActionBarSherlock library, add this to your project
  10. Lastly, if you were using the compatibility support , you need to delete that jar since it's included in ActionBarSherlock.

Follow the steps below to add HoloEverywhere

  1. Download Zip from GitHub to your computer
  2. UnZip the folder
  3. Go to eclipse and choose File->New-> Android Project
  4. Select Create project from existing source and then browse to the HoloEverywhereLib folder inside extracted folder
  5. Press Finish
  6. Right click on the newly created project and go to Properties.
  7. Under the Android heading, you should see a section for Library with a checkbox IsLibrary. Make sure that's checked and press Add and previously added library ActionBarSherlock.

Follow these steps to add HoloEverywhere to your project

  1. Create a new Android project
  2. Right Click on project -> Properties -> Android -> Add, add both ActionBarSherlock and HoloEverywhere
  3. Change the Android Manifest to following

    <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/Holo.Theme">

  4. Edit you main.xml to include Holo theme widgets.

  5. Change your activity as follows

    public class ChkActionBarSherlock extends SherlockActivity {
        @Override
         public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
        }
    
    }
    



回答2:


It seems that

android:theme="@style/Theme.HoloEverywhereDark.Sherlock"

cause an error.

change it:

android:theme="@style/Holo.Theme"

resons here:

Github

correct!




回答3:


I had the same error on my project, This is what I did, right click the HoloEverywhere (properties->android->library) remove the ActionBarSherlock from the list then re-add the ActionBarSherlock project by click add, after that clean up the project and all errors will disappear.




回答4:


The creator of ActionBarSherlock, Jake Wharton, announced on Google+ that further development of ActionBarSherlock has been stopped. ActionBarSherlock 4.4 is the last release and might get bug fixes – but there won’t be any new features:

While there may be a dot release or two in the coming weeks, version 4.4 is shaping up to be The Last Release™.

https://plus.google.com/+JakeWharton/posts/F3HkWY9J8fK

As i asked on holoeverywhere issues forum and answered by devs:

HoloEverywhere doesn't have any dependency with ABS since v2.0

So you should not use ABS anymore and remove the library from your project and replace it holoeverywhere directly or with ActionbarCompat from google support library.



来源:https://stackoverflow.com/questions/10608539/error-importing-holoeverywhere

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