I am using ActionBarSherlock and have the dreaded problem:
01-08 22:16:05.803: E/AndroidRuntime(432): java.lang.RuntimeException: Unable to start activity ComponentInfo{ar.android.app.glarm/ar.android.app.glarm.gui.GLarmMain}: android.view.InflateException: Binary XML file line #32: Error inflating class com.actionbarsherlock.internal.widget.ActionBarView
01-08 22:16:05.803: E/AndroidRuntime(432): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1736)
[CUT]
01-08 22:16:05.803: E/AndroidRuntime(432): Caused by: android.view.InflateException: Binary XML file line #32: Error inflating class com.actionbarsherlock.internal.widget.ActionBarView
01-08 22:16:05.803: E/AndroidRuntime(432): at android.view.LayoutInflater.createView(LayoutInflater.java:596)
01-08 22:16:05.803: E/AndroidRuntime(432): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:671)
01-08 22:16:05.803: E/AndroidRuntime(432): at android.view.LayoutInflater.rInflate(LayoutInflater.java:724)
01-08 22:16:05.803: E/AndroidRuntime(432): at android.view.LayoutInflater.rInflate(LayoutInflater.java:727)
01-08 22:16:05.803: E/AndroidRuntime(432): at android.view.LayoutInflater.inflate(LayoutInflater.java:479)
01-08 22:16:05.803: E/AndroidRuntime(432): at android.view.LayoutInflater.inflate(LayoutInflater.java:391)
01-08 22:16:05.803: E/AndroidRuntime(432): at android.view.LayoutInflater.inflate(LayoutInflater.java:347)
01-08 22:16:05.803: E/AndroidRuntime(432): at com.actionbarsherlock.internal.ActionBarSherlockCompat.generateLayout(ActionBarSherlockCompat.java:1010)
01-08 22:16:05.803: E/AndroidRuntime(432): at com.actionbarsherlock.internal.ActionBarSherlockCompat.installDecor(ActionBarSherlockCompat.java:902)
01-08 22:16:05.803: E/AndroidRuntime(432): at com.actionbarsherlock.internal.ActionBarSherlockCompat.setContentView(ActionBarSherlockCompat.java:855)
01-08 22:16:05.803: E/AndroidRuntime(432): at com.actionbarsherlock.ActionBarSherlock.setContentView(ActionBarSherlock.java:672)
01-08 22:16:05.803: E/AndroidRuntime(432): at com.actionbarsherlock.app.SherlockListActivity.setContentView(SherlockListActivity.java:239)
01-08 22:16:05.803: E/AndroidRuntime(432): at ar.android.app.glarm.gui.GLarmMain.onCreate(GLarmMain.java:117)
01-08 22:16:05.803: E/AndroidRuntime(432): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
01-08 22:16:05.803: E/AndroidRuntime(432): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1700)
01-08 22:16:05.803: E/AndroidRuntime(432): ... 11 more
01-08 22:16:05.803: E/AndroidRuntime(432): Caused by: java.lang.reflect.InvocationTargetException
01-08 22:16:05.803: E/AndroidRuntime(432): at java.lang.reflect.Constructor.constructNative(Native Method)
01-08 22:16:05.803: E/AndroidRuntime(432): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
01-08 22:16:05.803: E/AndroidRuntime(432): at android.view.LayoutInflater.createView(LayoutInflater.java:576)
01-08 22:16:05.803: E/AndroidRuntime(432): ... 25 more
01-08 22:16:05.803: E/AndroidRuntime(432): Caused by: java.lang.NullPointerException
01-08 22:16:05.803: E/AndroidRuntime(432): at com.actionbarsherlock.internal.widget.ActionBarView$HomeView.setUp(ActionBarView.java:1219)
01-08 22:16:05.803: E/AndroidRuntime(432): at com.actionbarsherlock.internal.widget.ActionBarView.<init>(ActionBarView.java:231)
01-08 22:16:05.803: E/AndroidRuntime(432): ... 28 more
I don't have any style in the manifest as my app takes Theme.Sherlock directly. My ABS version is the last 4.4.0 and I am trying to run my app in an API 11 emulator (API 8 leads to the same result). API 18 works fine.
After a little debugging in Eclipse, it looks that the following returns both null views (ActionBarView.java):
@Override
protected void onFinishInflate() {
mUpView = findViewById(R.id.abs__up);
mIconView = (ImageView) findViewById(R.id.abs__home);
}
and of course the subsequent calls are returning the NPE. It also looks like I have some warning in my LogCat:
01-08 22:54:20.093: I/dalvikvm(626): Could not find method com.actionbarsherlock.internal.nineoldandroids.widget.NineFrameLayout.onHoverEvent, referenced from method com.actionbarsherlock.internal.widget.ActionBarContainer.onHoverEvent
01-08 22:54:20.093: W/dalvikvm(626): VFY: unable to resolve virtual method 8116: Lcom/actionbarsherlock/internal/nineoldandroids/widget/NineFrameLayout;.onHoverEvent (Landroid/view/MotionEvent;)Z
01-08 22:54:20.093: D/dalvikvm(626): VFY: replacing opcode 0x6f at 0x0000
01-08 22:54:49.864: I/dalvikvm(626): Could not find method com.actionbarsherlock.internal.widget.ActionBarView$HomeView.onHoverEvent, referenced from method com.actionbarsherlock.internal.widget.ActionBarView$HomeView.dispatchHoverEvent
01-08 22:54:49.864: W/dalvikvm(626): VFY: unable to resolve virtual method 8980: Lcom/actionbarsherlock/internal/widget/ActionBarView$HomeView;.onHoverEvent (Landroid/view/MotionEvent;)Z
01-08 22:54:49.864: D/dalvikvm(626): VFY: replacing opcode 0x6e at 0x0000
01-08 22:54:49.864: I/dalvikvm(626): Could not find method android.widget.FrameLayout.onPopulateAccessibilityEvent, referenced from method com.actionbarsherlock.internal.widget.ActionBarView$HomeView.onPopulateAccessibilityEvent
01-08 22:54:49.864: W/dalvikvm(626): VFY: unable to resolve virtual method 5731: Landroid/widget/FrameLayout;.onPopulateAccessibilityEvent (Landroid/view/accessibility/AccessibilityEvent;)V
01-08 22:54:49.864: D/dalvikvm(626): VFY: replacing opcode 0x6f at 0x0006
What can be my problem?
PS.: I use Eclipse + Maven and include both android-v4 support 19.0.1 and NineOldAndroids 2.4.0.
EDIT
After some other debugging it looks like the generated resource numbers in ActionBarSherlock and R.txt (target/ folder generated by Maven) are not the same. Checking in the debugger, I have:
R.txt -> int layout abs__action_bar_home 0x7f030000 | Debug -> same
R.txt -> int id abs__up 0x7f07000b | Debug -> ox7f04000b
R.txt -> int id abs__home 0x7f07000a | Debug -> 0x7f04000a
UPDATE
It looks like there is a problem while importing apklibs...something goes wrong with the R compilation. The workaround is to remove the the custom resources that misalign the ids of abs__* ones and mess up the numbering. For instance I did the following:
- I checked where ActionBarSherlock was failing, for me it was while loading the resource R.id.abs__up.
- I have got the resource number from my R.java file and note it down (0x7f07XXXX);
- I removed all the resources before 0x7f07XXXX, cleaned the project, regenerated R. I wanted to align back R.id.abs__up to its apklib number (0x7f04000b). I had to remove three folders (anim/, xml/ , raw/) and three actual resources from my string xml.
- Now R.id.abs__up had the correct number in my compiled R.java.
See discussion here.