문제

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