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?

有帮助吗?

解决方案

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:

before after

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top