Подтвердить что ты не робот

Samsung Galaxy/Holoeverywhere - ресурс не является ColorStateList (цвет или путь)

Я получаю следующий крах на Samsung Galaxy Ace/Y/Pocket/Mini. Он отлично работает на всех других устройствах. Сбои происходят только на Android 2.3.5 или 2.3.6

В стеке нет ссылки на мой код. Кажется, это из макета меню, который я не настроил.

Я подозреваю, что это ошибка в Galaxy OS. Но не могу подтвердить.

Что еще более важно, что я могу избежать или уменьшить эту ошибку?

android.view.InflateException: Binary XML file line #45: Error inflating class 
at org.holoeverywhere.LayoutInflater._createView(SourceFile:382)
at org.holoeverywhere.LayoutInflater.onCreateView(SourceFile:594)
at org.holoeverywhere.LayoutInflater.createViewFromTag(SourceFile:444)
at org.holoeverywhere.LayoutInflater.rInflate(SourceFile:731)
at org.holoeverywhere.LayoutInflater.rInflate(SourceFile:734)
at org.holoeverywhere.LayoutInflater.inflate(SourceFile:538)
at org.holoeverywhere.LayoutInflater.inflate(SourceFile:488)
at com.android.internal.view.menu.MenuItemImpl.createItemView(MenuItemImpl.java:592)
at com.android.internal.view.menu.MenuItemImpl.getItemView(MenuItemImpl.java:577)
at com.android.internal.view.menu.MenuBuilder$MenuAdapter.getView(MenuBuilder.java:1173)
at android.widget.AbsListView.obtainView(AbsListView.java:1592)
at android.widget.ListView.measureHeightOfChildren(ListView.java:1251)
at android.widget.ListView.onMeasure(ListView.java:1162)
at android.view.View.measure(View.java:8313)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
at android.view.View.measure(View.java:8313)
at android.view.ViewRoot.performTraversals(ViewRoot.java:845)
at android.view.ViewRoot.handleMessage(ViewRoot.java:1865)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3687)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
at org.holoeverywhere.LayoutInflater._createView(SourceFile:358)
... 26 more Caused by: android.content.res.Resources$NotFoundException: Resource is not a ColorStateList (color or path): TypedValue{t=0x1/d=0x7f0d014c a=3 r=0x7f0d014c}
at android.content.res.Resources.loadColorStateList(Resources.java:1804)
at android.content.res.TypedArray.getColorStateList(TypedArray.java:342)
at android.widget.TextView.(TextView.java:445)
at org.holoeverywhere.widget.TextView.(SourceFile:133)
at org.holoeverywhere.widget.TextView.(SourceFile:129)
... 29 more java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
at org.holoeverywhere.LayoutInflater._createView(SourceFile:358)
at org.holoeverywhere.LayoutInflater.onCreateView(SourceFile:594)
at org.holoeverywhere.LayoutInflater.createViewFromTag(SourceFile:444)
at org.holoeverywhere.LayoutInflater.rInflate(SourceFile:731)
at org.holoeverywhere.LayoutInflater.rInflate(SourceFile:734)
at org.holoeverywhere.LayoutInflater.inflate(SourceFile:538)
at org.holoeverywhere.LayoutInflater.inflate(SourceFile:488)
at com.android.internal.view.menu.MenuItemImpl.createItemView(MenuItemImpl.java:592)
at com.android.internal.view.menu.MenuItemImpl.getItemView(MenuItemImpl.java:577)
at com.android.internal.view.menu.MenuBuilder$MenuAdapter.getView(MenuBuilder.java:1173)
at android.widget.AbsListView.obtainView(AbsListView.java:1592)
at android.widget.ListView.measureHeightOfChildren(ListView.java:1251)
at android.widget.ListView.onMeasure(ListView.java:1162)
at android.view.View.measure(View.java:8313)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
at android.view.View.measure(View.java:8313)
at android.view.ViewRoot.performTraversals(ViewRoot.java:845)
at android.view.ViewRoot.handleMessage(ViewRoot.java:1865)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3687)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
at dalvik.system.NativeStart.main(Native Method) Caused by: android.content.res.Resources$NotFoundException: Resource is not a ColorStateList (color or path): TypedValue{t=0x1/d=0x7f0d014c a=3 r=0x7f0d014c}
at android.content.res.Resources.loadColorStateList(Resources.java:1804)
at android.content.res.TypedArray.getColorStateList(TypedArray.java:342)
at android.widget.TextView.(TextView.java:445)
at org.holoeverywhere.widget.TextView.(SourceFile:133)
at org.holoeverywhere.widget.TextView.(SourceFile:129)
... 29 more android.content.res.Resources$NotFoundException: Resource is not a ColorStateList (color or path): TypedValue{t=0x1/d=0x7f0d014c a=3 r=0x7f0d014c}
at android.content.res.Resources.loadColorStateList(Resources.java:1804)
at android.content.res.TypedArray.getColorStateList(TypedArray.java:342)
at android.widget.TextView.(TextView.java:445)
at org.holoeverywhere.widget.TextView.(SourceFile:133)
at org.holoeverywhere.widget.TextView.(SourceFile:129)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
at org.holoeverywhere.LayoutInflater._createView(SourceFile:358)
at org.holoeverywhere.LayoutInflater.onCreateView(SourceFile:594)
at org.holoeverywhere.LayoutInflater.createViewFromTag(SourceFile:444)
at org.holoeverywhere.LayoutInflater.rInflate(SourceFile:731)
at org.holoeverywhere.LayoutInflater.rInflate(SourceFile:734)
at org.holoeverywhere.LayoutInflater.inflate(SourceFile:538)
at org.holoeverywhere.LayoutInflater.inflate(SourceFile:488)
at com.android.internal.view.menu.MenuItemImpl.createItemView(MenuItemImpl.java:592)
at com.android.internal.view.menu.MenuItemImpl.getItemView(MenuItemImpl.java:577)
at com.android.internal.view.menu.MenuBuilder$MenuAdapter.getView(MenuBuilder.java:1173)
at android.widget.AbsListView.obtainView(AbsListView.java:1592)
at android.widget.ListView.measureHeightOfChildren(ListView.java:1251)
at android.widget.ListView.onMeasure(ListView.java:1162)
at android.view.View.measure(View.java:8313)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
at android.view.View.measure(View.java:8313)
at android.view.ViewRoot.performTraversals(ViewRoot.java:845)
at android.view.ViewRoot.handleMessage(ViewRoot.java:1865)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3687)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
at dalvik.system.NativeStart.main(Native Method)

Вот весь theme.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <style name="CustomWindowTitleText" parent="TextAppearance.Sherlock.Widget.ActionBar.Title">
         <item name="android:textColor">@color/primary_text_yellow</item>
         <item name="android:textStyle">bold|italic</item>
    </style>

    <style name="CustomWindowTitleText.ActionBar">
        <item name="android:textSize">@dimen/textsize_mid</item>
    </style>

    <style name="CustomWindowSubTitleText" parent="TextAppearance.Sherlock.Widget.ActionBar.Subtitle">
    </style>


    <!-- Changes the background color of the title bar -->
    <style name="CustomWindowTitleBackground">
         <item name="android:background">@drawable/background_window_title</item>
    </style>

    <!-- Set the theme for the window title -->
    <!-- NOTE: setting android:textAppearance to style defined above -->
    <style name="CustomWindowTitle">
        <item name="android:singleLine">true</item>
        <item name="android:shadowColor">#BB000000</item>
        <item name="android:shadowRadius">2.75</item>
        <item name="android:textAppearance">@style/CustomWindowTitleText</item>
        <item name="android:paddingLeft">40dp</item>
    </style>

    <!--
        http://actionbarsherlock.com/theming.html
        Due to limitations in Android theming system any theme customizations must be declared in two attributes.
        The normal android-prefixed attributes apply the theme to the native action bar and the unprefixed attributes are for the custom implementation.
    -->
    <style name="CustomActionBar" parent="Widget.Sherlock.Light.ActionBar.Solid.Inverse"> <!--parent="@android:style/Widget.Holo.ActionBar"-->
        <item name="android:background">@drawable/gradient_lightpurple_darkpurple_off</item> <!-- Use background that has color but not icon. -->
        <item name="android:backgroundSplit">@drawable/gradient_lightpurple_darkpurple_off</item> <!-- Use background that has color but not icon. -->
        <item name="android:titleTextStyle">@style/CustomWindowTitleText.ActionBar</item>
        <item name="android:subtitleTextStyle">@style/CustomWindowSubTitleText</item>

        <item name="background">@drawable/gradient_lightpurple_darkpurple_off</item> <!-- Use background that has color but not icon. -->
        <item name="backgroundSplit">@drawable/gradient_lightpurple_darkpurple_off</item> <!-- Use background that has color but not icon. -->
        <item name="titleTextStyle">@style/CustomWindowTitleText.ActionBar</item>
        <item name="subtitleTextStyle">@style/CustomWindowSubTitleText</item>
    </style>

     <!-- Override properties in the default theme -->
     <!-- NOTE: If you change the windowTitleTextSize you must explicitly the windowTitleSize property, the title bar will not re-size automatically, text will be clipped -->
    <style name="JumbleeTheme" parent="Holo.Theme"> <!-- extends Theme.Sherlock -->
        <item name="android:windowTitleStyle">@style/CustomWindowTitle</item>
        <item name="android:windowTitleBackgroundStyle">@style/CustomWindowTitleBackground</item>
        <item name="android:windowBackground">@drawable/gradient_off_darkpurple_off</item>
        <item name="android:windowActionBar">true</item>
        <item name="android:actionBarStyle">@style/CustomActionBar</item>
        <item name="actionBarStyle">@style/CustomActionBar</item>
    </style>

    <style name="JumbleeTheme.GameScreen">
        <item name="android:windowBackground">@color/black</item>
    </style>


    <!-- Facebook Theme -->

    <style name="CustomWindowTitleText.ActionBar.Facebook">
        <item name="android:textColor">@color/primary_text_white</item>
    </style>
    <!--
        http://actionbarsherlock.com/theming.html
        Due to limitations in Android theming system any theme customizations must be declared in two attributes.
        The normal android-prefixed attributes apply the theme to the native action bar and the unprefixed attributes are for the custom implementation.
    -->
    <style name="CustomActionBar.Facebook">
        <item name="android:background">@drawable/background_window_title_facebook</item> <!-- Use background that has color but not icon. -->
        <item name="android:backgroundSplit">@drawable/background_window_title_facebook</item> <!-- Use background that has color but not icon. -->
        <item name="android:titleTextStyle">@style/CustomWindowTitleText.ActionBar.Facebook</item>

        <item name="background">@drawable/background_window_title_facebook</item> <!-- Use background that has color but not icon. -->
        <item name="backgroundSplit">@drawable/background_window_title_facebook</item> <!-- Use background that has color but not icon. -->
        <item name="titleTextStyle">@style/CustomWindowTitleText.ActionBar.Facebook</item>
    </style>

    <!-- Facebook Sender Activity -->
    <style name="FacebookSenderTheme" parent="Holo.Theme.Light">
        <item name="android:actionBarStyle">@style/CustomActionBar.Facebook</item>
        <item name="actionBarStyle">@style/CustomActionBar.Facebook</item>
    </style>
</resources>

И источник для primary_text_yellow

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_enabled="false" android:color="@color/text_light_disabled" />
    <item android:color="@color/app_yellow"/>
</selector>
4b9b3361

Ответ 1

Это определенно ошибка в нескольких членах серии устройств Samsung Galaxy. Мне удалось воспроизвести его на Galaxy Pocket, но не удалось воспроизвести его на эмуляторе для AVD, который был маленьким-ldpi Gingerbread.

Прошло некоторое время, чтобы воспроизвести. Происходит при наличии более 6 пунктов меню, так что нажатие на кнопку меню аппаратного обеспечения показывает 5 элементов плюс опцию "Больше" переполнения. Нажатие "Больше" вызывает сбой.

Обрезание темы до следующего все еще вызвало ошибку.

<style name="CustomActionBar"> 
   <!-- No styles -->
</style>

<style name="JumbleeTheme" parent="Holo.Theme">
    <item name="android:actionBarStyle">@style/CustomActionBar</item>
    <item name="actionBarStyle">@style/CustomActionBar</item>
</style>

Но обрезка темы до следующего приводит к исчезновению ошибки.

<style name="CustomActionBar"> 
   <!-- No styles -->
</style>

<style name="JumbleeTheme" parent="Holo.Theme">
    <item name="actionBarStyle">@style/CustomActionBar</item>
</style>

Итак, почему-то устройства Galaxy смотрели на "android: actionBarStyle", хотя они не должны быть, и это ставит их в очень странное состояние.

Решением, которое я принял, было создание папки ресурсов values-v11, где my theme.xml имеет ссылки на "android: actionBarStyle" и все другие атрибуты Honeycomb + ActionBar и в моих значениях \theme.xml, чтобы использовать только ABS атрибуты (например, actionBarStyle/actionBarSize).

Ответ 2

Я уверен, что у меня была такая же проблема. Я готов поспорить, что это не имеет никакого отношения к ОС. Это вызвано тем, что в Android, где вы можете заменить один Drawable для другого в зависимости от вашей темы или какого-то другого условия. Оказывается, компилятор ресурсов Android не всегда (всегда?) Проверяет, есть ли что-то "реальное" за псевдонимом.

Вот как вы его отлаживаете...

Начните с этой строки, она сообщит вам что-то конкретное о том, чего не хватает - ID:

Caused by: android.content.res.Resources$NotFoundException: Resource is not a ColorStateList (color or path): TypedValue{t=0x1/d=0x7f0d014c a=3 r=0x7f0d014c}

Теперь перейдите к bin/R.text и выполните поиск кода идентификатора: 0x7f0d014c. Должно быть что-то вроде этого: int attr actionModeCloseDrawable 0x7f0d014c

Теперь найдите имя actionModeCloseDrawable или все, что есть в вашей рабочей области. Я считаю, что вы обнаружите, что это псевдоним для несуществующего ресурса. то есть есть конфигурация (номер версии, размер экрана и т.д.), при которой это attr не отображает ничего вообще.

Важно отметить: Обязательно проверяйте ВСЕ места, где вы находите actionModeCloseDrawable или что-то еще. Возможно, это похоже на то место, где оно "не имеет значения", но это была вторая проблема: после того, как я "исправил" проблему в одном abc_myfragment.xml, мне действительно пришлось исправить ее в abc_myfragment_large.xml - Android автоматически вызывал другой XML файл, чем тот, который указан в коде, на основе устройства, на котором я его запускал.

Верхняя строка трассировки стека должна помочь вам проверить, что вы смотрите в нужном месте: android.view.InflateException: Binary XML file line #45: Error inflating class

Это говорит о том, что отсутствующий ColorStateList упоминается в разделе какого-либо файла XML где-то и что этот неприятный раздел начинается в строке 45 (то есть, когда открытая угловая скобка - "<" - начало секции.)

PS Я имею в виду под псевдонимом один из них:

<attr name="abc_my_home_button" format="reference" />

который получает отдельные дополнительные определения в двух отдельных темах:

<item name="afc_button_home">@drawable/afc_button_home_light</item> в файле themes_light.xml

и

<item name="afc_button_home">@drawable/afc_button_home_dark</item> в файле themes_dark.xml

Проблема возникает, когда вы оставляете окончательное определение из одного из файлов темы.

ИЗМЕНИТЬ

Следующий шаг: Изучите зависимости CustomActionBar. Я не специалист по стилям, поэтому я предполагаю, что осталось 9 возможных мест, где Android может видеть ссылку на ColorStateList, которую он не может найти: в родительском элементе CustomActionBar (Widget.Sherlock.Light.ActionBar.Solid.Inverse), и в каждом из 8 пунктов, которые он содержит. Комментируйте эти 8 пунктов и избавьтесь от родителя, а затем повторно запустите приложение в сложной конфигурации. Проверьте, не исчезла ли ошибка времени выполнения или, что более вероятно, изменения (например, номер строки (и идентификатор) изменяется С# 45, чтобы вместо CustomActionBar.Facebook указать, где задействованы многие из одних и тех же ресурсов). Затем отмените изменения один за другим, пока ошибка не вернется к тому, что было раньше. Это позволит локализовать проблему. После попытки исправить движение медленно, так как возможно, что если вы обнаружите проблему (например, в качестве несуществующей ссылки), она реплицируется в несколько из восьми элементов. Так разобейте один за другим.

Ответ 3

Восстановите каждый файл ресурсов, который вы только что скопировали из другого проекта. Android не будет распознавать файл ресурсов. создать новый файл ресурсов и скопировать и вставить код из старого в новый. Новый файл ресурсов должен быть распознан и ваши цвета будут слишком

Ответ 4

Одним быстрым и грубым решением этой проблемы является просто grep двоичный код в папке проекта. Это даст имя переменной, которая ссылается на это значение. Например, в моем случае это было что-то вроде этого -

myviewpager/R.java:        public static final int accent=0x7f0c0000;

После этого просто замените все ссылки на эту переменную (акцент) в вашем проекте по жестко заданному значению, соответствующему ему, в файл xml файла, в моем случае это было #009688. Это решило проблему в моем случае.