ActionBarSherlock icon indicating copy to clipboard operation
ActionBarSherlock copied to clipboard

Search View Widget Crashes in ICS and above

Open jcampbell05 opened this issue 14 years ago • 68 comments

When using the Search View Widget as a Action View in the latest sherlock with Ice Cream Sandwich or above it crashes complaining about a layout file.

I've fixed it by setting the code in my activity that uses a plain button for Eclair (As google recommends), The sherlock implementation from Froyo to Honeycomb and then the native one from Ice Cream Upwards.

I think the Sherlock Implementation should wrap around the native widget by default or is this not possible ? At least it should throw an error complaining it isn't compatible with anything newer than Honeycomb and the user should use the Native Widget

jcampbell05 avatar Nov 03 '12 00:11 jcampbell05

Stack trace? Example code? Demo project?

It works on all APIs using the example in the 'demos' sample app.

JakeWharton avatar Nov 03 '12 00:11 JakeWharton

This is the error I got.

11-03 00:50:22.587: E/AndroidRuntime(928): FATAL EXCEPTION: main 11-03 00:50:22.587: E/AndroidRuntime(928): android.view.InflateException: Binary XML file line #29: Error inflating class 11-03 00:50:22.587: E/AndroidRuntime(928): at android.view.LayoutInflater.createView(LayoutInflater.java:606) 11-03 00:50:22.587: E/AndroidRuntime(928): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) 11-03 00:50:22.587: E/AndroidRuntime(928): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:653) 11-03 00:50:22.587: E/AndroidRuntime(928): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678) 11-03 00:50:22.587: E/AndroidRuntime(928): at android.view.LayoutInflater.rInflate(LayoutInflater.java:739) 11-03 00:50:22.587: E/AndroidRuntime(928): at android.view.LayoutInflater.inflate(LayoutInflater.java:489) 11-03 00:50:22.587: E/AndroidRuntime(928): at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 11-03 00:50:22.587: E/AndroidRuntime(928): at com.actionbarsherlock.widget.SearchView.(SearchView.java:264) 11-03 00:50:22.587: E/AndroidRuntime(928): at com.actionbarsherlock.widget.SearchView.(SearchView.java:252) 11-03 00:50:22.587: E/AndroidRuntime(928): at com.NYXDigital.LookBunnyFind.Activities.LookBunnyFindActivity.onCreateOptionsMenu(LookBunnyFindActivity.java:63) 11-03 00:50:22.587: E/AndroidRuntime(928): at android.support.v4.app.Watson.onCreatePanelMenu(Watson.java:45) 11-03 00:50:22.587: E/AndroidRuntime(928): at com.actionbarsherlock.ActionBarSherlock.callbackCreateOptionsMenu(ActionBarSherlock.java:559) 11-03 00:50:22.587: E/AndroidRuntime(928): at com.actionbarsherlock.internal.ActionBarSherlockNative.dispatchCreateOptionsMenu(ActionBarSherlockNative.java:60) 11-03 00:50:22.587: E/AndroidRuntime(928): at com.actionbarsherlock.app.SherlockFragmentActivity.onCreatePanelMenu(SherlockFragmentActivity.java:165) 11-03 00:50:22.587: E/AndroidRuntime(928): at com.android.internal.policy.impl.PhoneWindow.preparePanel(PhoneWindow.java:388) 11-03 00:50:22.587: E/AndroidRuntime(928): at com.android.internal.policy.impl.PhoneWindow.invalidatePanelMenu(PhoneWindow.java:739) 11-03 00:50:22.587: E/AndroidRuntime(928): at com.android.internal.policy.impl.PhoneWindow$1.run(PhoneWindow.java:2833) 11-03 00:50:22.587: E/AndroidRuntime(928): at android.os.Handler.handleCallback(Handler.java:605) 11-03 00:50:22.587: E/AndroidRuntime(928): at android.os.Handler.dispatchMessage(Handler.java:92) 11-03 00:50:22.587: E/AndroidRuntime(928): at android.os.Looper.loop(Looper.java:137) 11-03 00:50:22.587: E/AndroidRuntime(928): at android.app.ActivityThread.main(ActivityThread.java:4424) 11-03 00:50:22.587: E/AndroidRuntime(928): at java.lang.reflect.Method.invokeNative(Native Method) 11-03 00:50:22.587: E/AndroidRuntime(928): at java.lang.reflect.Method.invoke(Method.java:511) 11-03 00:50:22.587: E/AndroidRuntime(928): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) 11-03 00:50:22.587: E/AndroidRuntime(928): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 11-03 00:50:22.587: E/AndroidRuntime(928): at dalvik.system.NativeStart.main(Native Method) 11-03 00:50:22.587: E/AndroidRuntime(928): Caused by: java.lang.reflect.InvocationTargetException 11-03 00:50:22.587: E/AndroidRuntime(928): at java.lang.reflect.Constructor.constructNative(Native Method) 11-03 00:50:22.587: E/AndroidRuntime(928): at java.lang.reflect.Constructor.newInstance(Constructor.java:417) 11-03 00:50:22.587: E/AndroidRuntime(928): at android.view.LayoutInflater.createView(LayoutInflater.java:586) 11-03 00:50:22.587: E/AndroidRuntime(928): ... 25 more 11-03 00:50:22.587: E/AndroidRuntime(928): Caused by: android.content.res.Resources$NotFoundException: Resource is not a ColorStateList (color or path): TypedValue{t=0x2/d=0x7f01002b a=-1} 11-03 00:50:22.587: E/AndroidRuntime(928): at android.content.res.Resources.loadColorStateList(Resources.java:2040) 11-03 00:50:22.587: E/AndroidRuntime(928): at android.content.res.TypedArray.getColorStateList(TypedArray.java:342) 11-03 00:50:22.587: E/AndroidRuntime(928): at android.widget.TextView.(TextView.java:774) 11-03 00:50:22.587: E/AndroidRuntime(928): at android.widget.TextView.(TextView.java:442) 11-03 00:50:22.587: E/AndroidRuntime(928): ... 28 more

jcampbell05 avatar Nov 03 '12 01:11 jcampbell05

And here is the code that triggered it


import android.os.Bundle;
import android.support.v4.view.ViewPager;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;
import com.actionbarsherlock.widget.SearchView;
import com.NYXDigital.LookBunnyFind.Adapters.FragmentViewPagerAdapter;
import com.NYXDigital.LookBunnyFind.Fragments.BranchListFragment;
import com.NYXDigital.LookBunnyFind.Fragments.FindFragment;
import com.NYXDigital.LookBunnyFind.Widget.FragmentViewPagerItem;
import com.viewpagerindicator.*;

public class LookBunnyFindActivity extends SherlockFragmentActivity {

/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Create adapter for pager and add fragments to be displayed
FragmentViewPagerAdapter adapter = new FragmentViewPagerAdapter(
        getSupportFragmentManager());

// Local
FragmentViewPagerItem localFragment = new FragmentViewPagerItem(
        "Local", new BranchListFragment());
adapter.addFragment(localFragment);

// Find
FragmentViewPagerItem findFragment = new FragmentViewPagerItem("Find",
        new FindFragment());
adapter.addFragment(findFragment);

// Events
FragmentViewPagerItem eventsFragment = new FragmentViewPagerItem(
        "Events", new BranchListFragment());
adapter.addFragment(eventsFragment);

// Set the pager with an adapter
ViewPager pager = (ViewPager) findViewById(R.id.pager);
pager.setAdapter(adapter);

// Bind the title indicator to the adapter
TabPageIndicator mIndicator = (TabPageIndicator) findViewById(R.id.indicator);
mIndicator.setViewPager(pager);

}

public boolean onCreateOptionsMenu(Menu menu) {

// Create the Search Menu Item
MenuItem searchItem = menu.add("Search").setIcon(
        R.drawable.abs__ic_search);
searchItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM
        | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);

// Check Application is running on Android Froyo or Above
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.FROYO) {
    // Create the search view
    SearchView searchView = new SearchView(getSupportActionBar()
            .getThemedContext());
    searchView.setQueryHint("e.g Farm park");

    // Setup Action View
    searchItem.setActionView(searchView);

}

return true;

}

public boolean onOptionsItemSelected(MenuItem item) {

// If this is the search button then
if (item.getTitle() == "Search") {
    this.onSearchRequested();
    return true;
}

return false;

}


}

jcampbell05 avatar Nov 03 '12 01:11 jcampbell05

@jcampbell05 android.content.res.Resources$NotFoundException: Resource is not a ColorStateList (color or path): TypedValue{t=0x2/d=0x7f01002b a=-1}

iNoles avatar Nov 03 '12 01:11 iNoles

What would cause that error ? Is that something in my code ?

jcampbell05 avatar Nov 03 '12 08:11 jcampbell05

same thing, crash with JB 4.2; Works with Android 2.2 though.

faridz avatar Dec 04 '12 20:12 faridz

We are also seeing a similar crash, though it only seems to effect a few devices. I cannot reproduce it myself, but users report that the app crashes right away.

    <item
    android:id="@+id/menu_search"
    android:icon="@drawable/ic_action_search_default"
    android:actionViewClass="com.actionbarsherlock.widget.SearchView"
    android:showAsAction="always|collapseActionView"
    android:menuCategory="system"
    android:orderInCategory="11"
    android:title="@string/menu_search"/>


@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getSupportMenuInflater().inflate(R.menu.base_menu, menu);
    mSearchItem = menu.findItem(R.id.menu_search);

    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    mSearchView = (SearchView) mSearchItem.getActionView();
    if( null != mSearchView ){
        mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    }

    return true;
}

java.lang.RuntimeException: Unable to resume activity {com.zappos.android/com.zappos.android.activities.HomeActivity}: android.content.res.Resources$NotFoundException: String resource ID #0x7f0d008e at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2634) ....... Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x7f0d008e at android.content.res.Resources.getText(Resources.java:229) at android.content.res.Resources.getString(Resources.java:313) at android.content.Context.getString(Context.java:292) at com.actionbarsherlock.widget.SearchView.updateQueryHint(SearchView.java:1090) at com.actionbarsherlock.widget.SearchView.setSearchableInfo(SearchView.java:371) at com.zappos.android.activities.BaseActivity.onCreateOptionsMenu(BaseActivity.java:176) at com.zappos.android.activities.BaseCartActivity.onCreateOptionsMenu(BaseCartActivity.java:246) at com.zappos.android.activities.HomeActivity.onCreateOptionsMenu(HomeActivity.java:323) at android.support.v4.app.Watson.onCreatePanelMenu(Watson.java:45) at com.actionbarsherlock.ActionBarSherlock.callbackCreateOptionsMenu(ActionBarSherlock.java:559) at com.actionbarsherlock.internal.ActionBarSherlockNative.dispatchCreateOptionsMenu(ActionBarSherlockNative.java:60) at com.actionbarsherlock.app.SherlockFragmentActivity.onCreatePanelMenu(SherlockFragmentActivity.java:165) at com.android.internal.policy.impl.PhoneWindow.preparePanel(PhoneWindow.java:393) at com.android.internal.policy.impl.PhoneWindow.invalidatePanelMenu(PhoneWindow.java:747) at com.actionbarsherlock.internal.ActionBarSherlockNative.dispatchInvalidateOptionsMenu(ActionBarSherlockNative.java:49) at com.actionbarsherlock.app.SherlockFragmentActivity.invalidateOptionsMenu(SherlockFragmentActivity.java:150) at com.zappos.android.activities.HomeActivity.onResume(HomeActivity.java:403) at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1184) at android.app.Activity.performResume(Activity.java:5132) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2617)

inktomi avatar Dec 11 '12 17:12 inktomi

I don't think that this is a device related issue. I'm encountering the crash in my app, but the sample is running fine (Galaxy Nexus, 4.2.1 stock). I'll see if I can get a minimal testcase.

esteluk avatar Dec 11 '12 18:12 esteluk

Ok, this looks like it's due to the Application Theme and theme inheritance.

esteluk avatar Dec 11 '12 19:12 esteluk

Yes I noticed we are both getting a resource not found.

I think if the sherlock search view can't be made to wrap the existing native one or does already. Then a warning or error should be thrown and documentation updated warning that this widget isn't compatible with all android 4+ devices. And people encouraged to detect the os versipn and load the correct class accordingly like I ended up dong (i can post code)

On Tuesday, 11 December 2012, Nathan Wong [email protected] wrote:

Ok, this looks like it's due to the Application Theme and theme inheritance.

— Reply to this email directly or view it on GitHub.

< https://github.com/notifications/beacon/jXIouyFjklbiNRrPH22PBl5IGsA-BCvnFhtrw115pl7J409tw1hYQPHZOj2AlWQ7.gif

jcampbell05 avatar Dec 11 '12 22:12 jcampbell05

If you're using HoloEverywhere: https://github.com/ChristopheVersieux/HoloEverywhere/issues/156

esteluk avatar Dec 12 '12 00:12 esteluk

So, out of the blue I suddenly get this error. The app was building and running fine and suddenly this happen.

12-17 17:56:20.901: W/MenuInflater(11863): Cannot instantiate class: com.actionbarsherlock.widget.SearchView
12-17 17:56:20.901: W/MenuInflater(11863): java.lang.reflect.InvocationTargetException
12-17 17:56:20.901: W/MenuInflater(11863):  at java.lang.reflect.Constructor.constructNative(Native Method)
12-17 17:56:20.901: W/MenuInflater(11863):  at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
12-17 17:56:20.901: W/MenuInflater(11863):  at com.actionbarsherlock.view.MenuInflater$MenuState.newInstance(MenuInflater.java:488)
12-17 17:56:20.901: W/MenuInflater(11863):  at com.actionbarsherlock.view.MenuInflater$MenuState.setItem(MenuInflater.java:447)
12-17 17:56:20.901: W/MenuInflater(11863):  at com.actionbarsherlock.view.MenuInflater$MenuState.addItem(MenuInflater.java:468)
12-17 17:56:20.901: W/MenuInflater(11863):  at com.actionbarsherlock.view.MenuInflater.parseMenu(MenuInflater.java:190)
12-17 17:56:20.901: W/MenuInflater(11863):  at com.actionbarsherlock.view.MenuInflater.inflate(MenuInflater.java:112)
12-17 17:56:20.901: W/MenuInflater(11863):  at com.mondial.thailand.rsa.fragment.MapFragment$SearchActionMode.onCreateActionMode(MapFragment.java:586)
12-17 17:56:20.901: W/MenuInflater(11863):  at com.actionbarsherlock.internal.ActionBarSherlockNative$ActionModeCallbackWrapper.onCreateActionMode(ActionBarSherlockNative.java:233)
12-17 17:56:20.901: W/MenuInflater(11863):  at com.android.internal.policy.impl.PhoneWindow$DecorView$ActionModeCallbackWrapper.onCreateActionMode(PhoneWindow.java:2550)
12-17 17:56:20.901: W/MenuInflater(11863):  at com.android.internal.app.ActionBarImpl$ActionModeImpl.dispatchOnCreate(ActionBarImpl.java:871)
12-17 17:56:20.901: W/MenuInflater(11863):  at com.android.internal.app.ActionBarImpl.startActionMode(ActionBarImpl.java:446)
12-17 17:56:20.901: W/MenuInflater(11863):  at android.app.Activity.onWindowStartingActionMode(Activity.java:4881)
12-17 17:56:20.901: W/MenuInflater(11863):  at com.android.internal.policy.impl.PhoneWindow$DecorView.startActionMode(PhoneWindow.java:2256)
12-17 17:56:20.901: W/MenuInflater(11863):  at android.app.Activity.startActionMode(Activity.java:4864)
12-17 17:56:20.901: W/MenuInflater(11863):  at com.actionbarsherlock.internal.ActionBarSherlockNative.startActionMode(ActionBarSherlockNative.java:211)
12-17 17:56:20.901: W/MenuInflater(11863):  at com.actionbarsherlock.app.SherlockFragmentActivity.startActionMode(SherlockFragmentActivity.java:47)
12-17 17:56:20.901: W/MenuInflater(11863):  at com.mondial.thailand.rsa.fragment.MapFragment.showActionMode(MapFragment.java:576)
12-17 17:56:20.901: W/MenuInflater(11863):  at com.mondial.thailand.rsa.fragment.MapFragment.onClick(MapFragment.java:570)
12-17 17:56:20.901: W/MenuInflater(11863):  at android.view.View.performClick(View.java:4202)
12-17 17:56:20.901: W/MenuInflater(11863):  at android.view.View$PerformClick.run(View.java:17340)
12-17 17:56:20.901: W/MenuInflater(11863):  at android.os.Handler.handleCallback(Handler.java:725)
12-17 17:56:20.901: W/MenuInflater(11863):  at android.os.Handler.dispatchMessage(Handler.java:92)
12-17 17:56:20.901: W/MenuInflater(11863):  at android.os.Looper.loop(Looper.java:137)
12-17 17:56:20.901: W/MenuInflater(11863):  at android.app.ActivityThread.main(ActivityThread.java:5039)
12-17 17:56:20.901: W/MenuInflater(11863):  at java.lang.reflect.Method.invokeNative(Native Method)
12-17 17:56:20.901: W/MenuInflater(11863):  at java.lang.reflect.Method.invoke(Method.java:511)
12-17 17:56:20.901: W/MenuInflater(11863):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
12-17 17:56:20.901: W/MenuInflater(11863):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
12-17 17:56:20.901: W/MenuInflater(11863):  at dalvik.system.NativeStart.main(Native Method)
12-17 17:56:20.901: W/MenuInflater(11863): Caused by: android.view.InflateException: Binary XML file line #29: Error inflating class <unknown>
12-17 17:56:20.901: W/MenuInflater(11863):  at android.view.LayoutInflater.createView(LayoutInflater.java:613)
12-17 17:56:20.901: W/MenuInflater(11863):  at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
12-17 17:56:20.901: W/MenuInflater(11863):  at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
12-17 17:56:20.901: W/MenuInflater(11863):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
12-17 17:56:20.901: W/MenuInflater(11863):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
12-17 17:56:20.901: W/MenuInflater(11863):  at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
12-17 17:56:20.901: W/MenuInflater(11863):  at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
12-17 17:56:20.901: W/MenuInflater(11863):  at com.actionbarsherlock.widget.SearchView.<init>(SearchView.java:264)
12-17 17:56:20.901: W/MenuInflater(11863):  at com.actionbarsherlock.widget.SearchView.<init>(SearchView.java:252)
12-17 17:56:20.901: W/MenuInflater(11863):  ... 30 more
12-17 17:56:20.901: W/MenuInflater(11863): Caused by: java.lang.reflect.InvocationTargetException
12-17 17:56:20.901: W/MenuInflater(11863):  at java.lang.reflect.Constructor.constructNative(Native Method)
12-17 17:56:20.901: W/MenuInflater(11863):  at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
12-17 17:56:20.901: W/MenuInflater(11863):  at android.view.LayoutInflater.createView(LayoutInflater.java:587)
12-17 17:56:20.901: W/MenuInflater(11863):  ... 38 more
12-17 17:56:20.901: W/MenuInflater(11863): Caused by: android.content.res.Resources$NotFoundException: Resource is not a ColorStateList (color or path): TypedValue{t=0x2/d=0x7f01001f a=-1}
12-17 17:56:20.901: W/MenuInflater(11863):  at android.content.res.Resources.loadColorStateList(Resources.java:2074)
12-17 17:56:20.901: W/MenuInflater(11863):  at android.content.res.TypedArray.getColorStateList(TypedArray.java:342)
12-17 17:56:20.901: W/MenuInflater(11863):  at android.widget.TextView.<init>(TextView.java:775)
12-17 17:56:20.901: W/MenuInflater(11863):  at android.widget.TextView.<init>(TextView.java:449)
12-17 17:56:20.901: W/MenuInflater(11863):  ... 41 more

R.menu.interactive_map

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:panel="http://schemas.android.com/apk/res-auto">
    <item android:id="@+id/action_search"
          android:title="@string/app_name"
          android:icon="@android:drawable/ic_menu_search"
          android:showAsAction="always"
          android:actionViewClass="com.actionbarsherlock.widget.SearchView" />
</menu>

This is placed inside a Fragment. ActionMode, Menu, and MenuInflater are all ABS.

private class SearchActionMode implements ActionMode.Callback{

        @Override
        public boolean onCreateActionMode(ActionMode mode, Menu menu) {
            Log.d(TAG, "onCreateActionMode creating inflater");
            MenuInflater inflater = new MenuInflater(getActivity());
            Log.d(TAG, "onCreateActionMode inflating"); // **Exception thrown after this line.**
            inflater.inflate(R.menu.interactive_map, menu); 
            Log.d(TAG, "onCreateActionMode finding SearchView");
            mSearchView = (SearchView) menu.findItem(R.id.action_search).getActionView();

            Log.d(TAG, "mSearchView: " + mSearchView);
            setupSearchView();
            return true;
        }

        @Override
        public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
            Log.d(TAG, "onPrepareActionMode");

            mSearchView.requestFocus();
            return false;
        }

        @Override
        public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
            Log.d(TAG, "onActionItemClicked");
            return false;
        }

        @Override
        public void onDestroyActionMode(ActionMode mode) {
            Log.d(TAG, "onDestroyActionMode");
            closeTopTray();
            closeListView();
        }

    }

RobGThai avatar Dec 17 '12 11:12 RobGThai

I created an empty project and added just a single line to it to get the error:

SearchView searchView = new SearchView(getSupportActionBar().getThemedContext());

12-17 16:49:56.844: E/AndroidRuntime(12016): FATAL EXCEPTION: main 12-17 16:49:56.844: E/AndroidRuntime(12016): android.view.InflateException: Binary XML file line #29: Error inflating class 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.view.LayoutInflater.createView(LayoutInflater.java:606) 12-17 16:49:56.844: E/AndroidRuntime(12016): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:653) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.view.LayoutInflater.rInflate(LayoutInflater.java:739) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.view.LayoutInflater.inflate(LayoutInflater.java:489) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 12-17 16:49:56.844: E/AndroidRuntime(12016): at com.actionbarsherlock.widget.SearchView.(SearchView.java:264) 12-17 16:49:56.844: E/AndroidRuntime(12016): at com.actionbarsherlock.widget.SearchView.(SearchView.java:252) 12-17 16:49:56.844: E/AndroidRuntime(12016): at com.example.testsearchview.MainActivity.onCreateOptionsMenu(MainActivity.java:23) 12-17 16:49:56.844: E/AndroidRuntime(12016): at com.actionbarsherlock.app.SherlockActivity.onCreatePanelMenu(SherlockActivity.java:184) 12-17 16:49:56.844: E/AndroidRuntime(12016): at com.actionbarsherlock.ActionBarSherlock.callbackCreateOptionsMenu(ActionBarSherlock.java:559) 12-17 16:49:56.844: E/AndroidRuntime(12016): at com.actionbarsherlock.internal.ActionBarSherlockNative.dispatchCreateOptionsMenu(ActionBarSherlockNative.java:60) 12-17 16:49:56.844: E/AndroidRuntime(12016): at com.actionbarsherlock.app.SherlockActivity.onCreateOptionsMenu(SherlockActivity.java:149) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.app.Activity.onCreatePanelMenu(Activity.java:2444) 12-17 16:49:56.844: E/AndroidRuntime(12016): at com.android.internal.policy.impl.PhoneWindow.preparePanel(PhoneWindow.java:405) 12-17 16:49:56.844: E/AndroidRuntime(12016): at com.android.internal.policy.impl.PhoneWindow.invalidatePanelMenu(PhoneWindow.java:756) 12-17 16:49:56.844: E/AndroidRuntime(12016): at com.android.internal.policy.impl.PhoneWindow$1.run(PhoneWindow.java:2852) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.os.Handler.handleCallback(Handler.java:605) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.os.Handler.dispatchMessage(Handler.java:92) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.os.Looper.loop(Looper.java:137) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.app.ActivityThread.main(ActivityThread.java:4424) 12-17 16:49:56.844: E/AndroidRuntime(12016): at java.lang.reflect.Method.invokeNative(Native Method) 12-17 16:49:56.844: E/AndroidRuntime(12016): at java.lang.reflect.Method.invoke(Method.java:511) 12-17 16:49:56.844: E/AndroidRuntime(12016): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:817) 12-17 16:49:56.844: E/AndroidRuntime(12016): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584) 12-17 16:49:56.844: E/AndroidRuntime(12016): at dalvik.system.NativeStart.main(Native Method) 12-17 16:49:56.844: E/AndroidRuntime(12016): Caused by: java.lang.reflect.InvocationTargetException 12-17 16:49:56.844: E/AndroidRuntime(12016): at java.lang.reflect.Constructor.constructNative(Native Method) 12-17 16:49:56.844: E/AndroidRuntime(12016): at java.lang.reflect.Constructor.newInstance(Constructor.java:417) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.view.LayoutInflater.createView(LayoutInflater.java:586) 12-17 16:49:56.844: E/AndroidRuntime(12016): ... 26 more 12-17 16:49:56.844: E/AndroidRuntime(12016): Caused by: android.content.res.Resources$NotFoundException: Resource is not a ColorStateList (color or path): TypedValue{t=0x2/d=0x7f01001f a=-1} 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.content.res.Resources.loadColorStateList(Resources.java:2044) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.content.res.TypedArray.getColorStateList(TypedArray.java:342) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.widget.TextView.(TextView.java:786) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.widget.TextView.(TextView.java:454) 12-17 16:49:56.844: E/AndroidRuntime(12016): ... 29 more

pijusn avatar Dec 17 '12 14:12 pijusn

Thats what happened to me. I ended up just using the native search view for the modern OS as a work around as it works the same without the pain.

On 17 Dec 2012, at 14:53, Pijus Navickas wrote:

I created an empty project and added just a single line to it to get the error:

SearchView searchView = new SearchView(getSupportActionBar().getThemedContext()); 12-17 16:49:56.844: E/AndroidRuntime(12016): FATAL EXCEPTION: main 12-17 16:49:56.844: E/AndroidRuntime(12016): android.view.InflateException: Binary XML file line #29: Error inflating class 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.view.LayoutInflater.createView(LayoutInflater.java:606) 12-17 16:49:56.844: E/AndroidRuntime(12016): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:653) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.view.LayoutInflater.rInflate(LayoutInflater.java:739) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.view.LayoutInflater.inflate(LayoutInflater.java:489) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 12-17 16:49:56.844: E/AndroidRuntime(12016): at com.actionbarsherlock.widget.SearchView.(SearchView.java:264) 12-17 16:49:56.844: E/AndroidRuntime(12016): at com.actionbarsherlock.widget.SearchView.(SearchView.java:252) 12-17 16:49:56.844: E/AndroidRuntime(12016): at com.example.testsearchview.MainActivity.onCreateOptionsMenu(MainActivity.java:23) 12-17 16:49:56.844: E/AndroidRuntime(12016): at com.actionbarsherlock.app.SherlockActivity.onCreatePanelMenu(SherlockActivity.java:184) 12-17 16:49:56.844: E/AndroidRuntime(12016): at com.actionbarsherlock.ActionBarSherlock.callbackCreateOptionsMenu(ActionBarSherlock.java:559) 12-17 16:49:56.844: E/AndroidRuntime(12016): at com.actionbarsherlock.internal.ActionBarSherlockNative.dispatchCreateOptionsMenu(ActionBarSherlockNative.java:60) 12-17 16:49:56.844: E/AndroidRuntime(12016): at com.actionbarsherlock.app.SherlockActivity.onCreateOptionsMenu(SherlockActivity.java:149) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.app.Activity.onCreatePanelMenu(Activity.java:2444) 12-17 16:49:56.844: E/AndroidRuntime(12016): at com.android.internal.policy.impl.PhoneWindow.preparePanel(PhoneWindow.java:405) 12-17 16:49:56.844: E/AndroidRuntime(12016): at com.android.internal.policy.impl.PhoneWindow.invalidatePanelMenu(PhoneWindow.java:756) 12-17 16:49:56.844: E/AndroidRuntime(12016): at com.android.internal.policy.impl.PhoneWindow$1.run(PhoneWindow.java:2852) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.os.Handler.handleCallback(Handler.java:605) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.os.Handler.dispatchMessage(Handler.java:92) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.os.Looper.loop(Looper.java:137) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.app.ActivityThread.main(ActivityThread.java:4424) 12-17 16:49:56.844: E/AndroidRuntime(12016): at java.lang.reflect.Method.invokeNative(Native Method) 12-17 16:49:56.844: E/AndroidRuntime(12016): at java.lang.reflect.Method.invoke(Method.java:511) 12-17 16:49:56.844: E/AndroidRuntime(12016): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:817) 12-17 16:49:56.844: E/AndroidRuntime(12016): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584) 12-17 16:49:56.844: E/AndroidRuntime(12016): at dalvik.system.NativeStart.main(Native Method) 12-17 16:49:56.844: E/AndroidRuntime(12016): Caused by: java.lang.reflect.InvocationTargetException 12-17 16:49:56.844: E/AndroidRuntime(12016): at java.lang.reflect.Constructor.constructNative(Native Method) 12-17 16:49:56.844: E/AndroidRuntime(12016): at java.lang.reflect.Constructor.newInstance(Constructor.java:417) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.view.LayoutInflater.createView(LayoutInflater.java:586) 12-17 16:49:56.844: E/AndroidRuntime(12016): ... 26 more 12-17 16:49:56.844: E/AndroidRuntime(12016): Caused by: android.content.res.Resources$NotFoundException: Resource is not a ColorStateList (color or path): TypedValue{t=0x2/d=0x7f01001f a=-1} 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.content.res.Resources.loadColorStateList(Resources.java:2044) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.content.res.TypedArray.getColorStateList(TypedArray.java:342) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.widget.TextView.(TextView.java:786) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.widget.TextView.(TextView.java:454) 12-17 16:49:56.844: E/AndroidRuntime(12016): ... 29 more

— Reply to this email directly or view it on GitHub.

jcampbell05 avatar Dec 17 '12 15:12 jcampbell05

Add a test case to the known-bugs project on the dev branch.

SimonVT avatar Dec 17 '12 16:12 SimonVT

Thanks to @esteluk and @Prototik. I fixed it by adding to v14 ofSherlock theme.

    <item name="textColorPrimary">@color/abs__primary_text_holo_light</item>
    <item name="textColorPrimaryInverse">@color/abs__primary_text_holo_dark</item>

RobGThai avatar Dec 19 '12 08:12 RobGThai

@RobGThai, can you please post an example? Your fix seems to not working on my side. Thanks.

chinhnguyen avatar Dec 22 '12 17:12 chinhnguyen

Basically, in res/values-v14/abs__themes.xml

Added those items to Sherlock.__Theme

<style name="Sherlock.__Theme" parent="android:Theme.Holo">
    <item name="textColorPrimary">@color/abs__primary_text_holo_light</item>
    <item name="textColorPrimaryInverse">@color/abs__primary_text_holo_dark</item>
</style>

RobGThai avatar Dec 25 '12 08:12 RobGThai

Both of those attributes are already defined in the Theme.Sherlock* themes.

SimonVT avatar Dec 25 '12 13:12 SimonVT

@RobGThai, thanks for the snippet. But it doesn't work on my side and I did follow the example code in your first post.

chinhnguyen avatar Dec 26 '12 03:12 chinhnguyen