1
votes

I'm porting ActionBar functionality in my app for android 2.2. When starting any ActionBarActivity gets following error:

java.lang.ExceptionInInitializerError
at android.support.v7.app.ActionBarActivityDelegate.createDelegate(ActionBarActivityDelegate.java:54)
at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:96)

...

Caused by: java.lang.NoClassDefFoundError: android.support.v7.appcompat.R$attr
        at android.support.v7.app.ActionBarActivityDelegateBase.<clinit>(ActionBarActivityDelegateBase.java:47)

My set up is: IntelliJ Idea CE - 135.406 Android support library - 19.0.1

Based on similar questions, I have:

  • Added v7 support as jar
  • Added appcompat as library project
  • Changed Activity to extend ActionBarActivity
  • Added to Manifest android:theme="@style/Theme.AppCompat"

But still getting resource error, any suggestions how I can fix this?

1
sure you have referenced the appcompat properly??. Right click on your project go to propeties check if AppCompat is referenced properly assuming you use eclipse as IDE - Raghunandan
@Raghunandan Pretty sure, I've created new module appcompat from extras and set it up as dependency for my main app module. - sigrlami
then you should not get this error. - Raghunandan
Try cleaning the project, fixing project properties and restarting eclipse. Worked for me - samleighton87

1 Answers

1
votes

I solved this problem. The problem was that IDE add strange package location and jar can't find it, so when you add such libraries, be careful to rename package with proper path, see example at image below:

beforeafter

I put android.support.v7.appcompat by hand in a "Package name" field. It's a little bit obscure because you don't pay attention to this field when adding library.