Android compatibility issues (Api 8, ActionbarSherlock)

I'm trying to set up the basic structure for my project, which should run at API levels 8-16, using Google's location services and ActionBarSherlock.

See my other question for customization.

I created a simple activity with Eclipse (Master-Detail-Flow). My project currently has only one action and one fragment. All I have done so far is replacing the superclasses 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 that I use

 <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 one works fine on an emulator in API 16 , but doesn’t work on another emulator with API 8 .

The problem is that I cannot interpret stacktrace in any useful way. My code does not seem to be 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 a problem? Let me know if I can provide more information.

Update . I have the same stack if I exclude ABS and just try to create a List-Activity / -Fragment combination that works in API 8. Here is a project .

+4
source share
1 answer

After viewing the source code, you use the simple_list_item_activated_1 resource. What's New for Android API Level 11 So, the solution to your problem.

onCreate method should be something like this

 @Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setListAdapter(new ArrayAdapter<DummyContent.DummyItem>(getActivity(), android.R.layout.simple_list_item_activated_1,android.R.id.text1, DummyContent.ITEMS)); } 

Since this was new to API level 11, you will get the same error with or without ActionBarSherlock. If you want to use simple_list_item_activated_1 , you need to create a local copy. Sorry for being late

+3
source

All Articles