I’m trying to set-up a basic structure for my project, which is supposed to run on API-levels 8 – 16, uses google location services and ActionBarSherlock.
See my other question for the setup.
I generated a simple activity with Eclipse (Master-Detail-Flow). My project currently has just one Activity and one Fragment. All I did so far is replacing the super classes with their ABS counterparts:
public class CouponListActivity extends SherlockFragmentActivity implements CouponListFragment.Callbacks {
...
}
and
public class CouponListFragment extends SherlockListFragment {
...
}
This is the one and only layout-element I’m using
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:name="....activity.CouponListFragment"
android:id="@+id/coupon_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
tools:context=".CouponListActivity" />
This runs fine on an emulator on API 16, but fails on another emulator with API 8.
The problem is that I cannot interpret the stacktrace in any helpful way. My code does not the seem to get touched at all…
java.lang.NullPointerException
at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:355)
at android.widget.ArrayAdapter.getView(ArrayAdapter.java:323)
at android.widget.AbsListView.obtainView(AbsListView.java:1315)
at android.widget.ListView.makeAndAddView(ListView.java:1727)
at android.widget.ListView.fillDown(ListView.java:652)
at android.widget.ListView.fillFromTop(ListView.java:709)
at android.widget.ListView.layoutChildren(ListView.java:1580)
at android.widget.AbsListView.onLayout(AbsListView.java:1147)
at android.view.View.layout(View.java:7035)
at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
at android.view.View.layout(View.java:7035)
at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
at android.view.View.layout(View.java:7035)
at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
at android.view.View.layout(View.java:7035)
at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
at android.view.View.layout(View.java:7035)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1249)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1125)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1042)
at android.view.View.layout(View.java:7035)
at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
at android.view.View.layout(View.java:7035)
at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
at android.view.View.layout(View.java:7035)
at android.view.ViewRoot.performTraversals(ViewRoot.java:1045)
at android.view.ViewRoot.handleMessage(ViewRoot.java:1727)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
Where can I start looking for the problem? Let me know if I can provide more information.
Update: I have the exact same stacktrace if I rule out ABS and simply try to create a List-Activity / -Fragment combination that runs in API 8. Here is the project.
After reviewing your source code, you are using
simple_list_item_activated_1resource. Which was new to Android API level 11 So Solution for your problem is.onCreatemethod should be something like thisSince this was new to API Level 11, You will get same error with or without ActionBarSherlock. If you want to use
simple_list_item_activated_1then you need to create a local copy of it. Sorry for being late