2013-09-03 15 views
11

Następuje awaria na Samsung Galaxy Ace/Y/Pocket/Mini. Działa dobrze na wszystkich innych urządzeniach. Awarie występują tylko w systemie Android 2.3.5 lub 2.3.6Samsung Galaxy/Holoeverywhere - Zasób nie jest ColorStateList (kolor lub ścieżka)

Nie ma odwołania do mojego kodu w stosie stacków. Wydaje się, że pochodzi z układu menu, którego nie dostosowałem.

Podejrzewam, że jest to błąd w systemie Galaxy OS. Ale nie mogę potwierdzić.

Co ważniejsze, co mogę zrobić, aby uniknąć lub złagodzić ten błąd?

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) 

Oto cała 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's 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's 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> 

A źródłem 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> 
+0

Wygląda na to, że masz domyślny kolor tekstu ustawiony na coś, co prawdopodobnie jest drawowalne lub ustawione na zero lub coś podobnego. W swoim motywie czynności jaki jest tekst TextViewStyle i powiązana z nim definicja TextAppearance? –

+0

Witaj Greg, dodałem szczegóły powyżej. Jedynym momentem, w którym nadpisuję TextAppearance, jest ustawienie go na @ style/CustomWindowTitleText. – William

Odpowiedz

5

Jest to zdecydowanie błąd kilku członków urządzeń z serii Samsung Galaxy. Udało mi się powielić to w kieszeni Galaxy, ale nie byłem w stanie powtórzyć tego na emulatorze dla AVD, który był małym piernikiem.

Zajęło trochę czasu, aby się rozmnażać. Występuje, gdy jest więcej niż 6 pozycji menu, więc naciśnięcie przycisku menu sprzętowego pokazuje 5 elementów oraz opcję "Więcej" przepełnienia. Kliknięcie "Więcej" powoduje awarię.

Przycinanie motywu w dół nadal powoduje błąd.

<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> 

Ale przycięcie motywu w dół do poniższego sprawia, że ​​błąd znika.

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

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

więc z jakiegoś powodu urządzenia Galaxy szukaliśmy w „android: actionBarStyle”, mimo że nie powinno być i to stawia ich w bardzo dziwnym stanie.

Rozwiązaniem, które zastosowałem, było utworzenie folderu zasobów wartości-v11, w którym mój plik theme.xml zawiera odniesienia do "android: actionBarStyle" i wszystkich innych atrybutów Honeycomb + ActionBar oraz w moich wartościach \ theme.xml do używania tylko Atrybuty ABS (np. ActionBarStyle/actionBarSize).

+0

Najpierw pytanie o informacje: dla jakiej wersji interfejsu API została skompilowana? I uwaga: Galaxy Pocket ma ekran 240x320. To stawia go w zakresie urządzeń o niskiej rozdzielczości. Pasek akcji Sherlock ma pusty folder do rysowania-ldpi, w którym nawet go nie ma. Ale urządzenia radzą sobie z tym inaczej. Mam sytuację, w której aplikacja działa w systemie Android 2.2 i kończy się niepowodzeniem w wersji 4.3. Czy jest możliwe sprawdzenie tej możliwości (brakujące grafiki w drawable-ldpi), abyśmy mogli zawęzić problem i być może stworzyć problem na Github? – Anderson

+0

Skompilowałbym dla 4.3. Zdajemy sobie sprawę, że Pocket to urządzenie o małej rozdzielczości, ale to także Gingerbread. Urządzenia Gingerbread NIE powinny patrzeć na atrybut "android: actionBarStyle", ponieważ ActionBar został wprowadzony tylko w Honeycomb. Usunięcie tego attrribute w urządzeniach pre Gingerbread nadal pozwala ABS działać, ponieważ używa atrybutu "actionBarStyle". – William

22

Jestem całkiem pewien, miałem ten sam problem. Mogę się założyć, że nie ma to nic wspólnego z systemem operacyjnym. Jest to spowodowane przez to, że w Androidzie można zastąpić go jednym Drawable w zależności od motywu lub innego warunku. Okazuje się, że kompilator zasobów Androida nie zawsze (zawsze?) Sprawdza, czy za aliasem jest coś "prawdziwego".

Oto jak go debugować ...

start z tej linii, to powie Ci coś konkretnego o tym, co brakuje - identyfikator:

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

Teraz przejdź do bin/R.text, i wyszukaj podany kod identyfikacyjny: 0x7f0d014c. Nie powinno być coś takiego: int attr actionModeCloseDrawable 0x7f0d014c

Teraz poszukaj nazwy actionModeCloseDrawable lub cokolwiek to jest w obszarze roboczym. Wierzę, że przekonasz się, że jest to alias dla nieistniejącego zasobu. tj. istnieje konfiguracja (numer wersji, rozmiar ekranu itp.), w której to atr nie jest w ogóle mapowane.

Ważne rzeczy do zapamiętania: Pamiętaj, aby sprawdzić WSZYSTKIE miejsca, w których znajdziesz actionModeCloseDrawable lub cokolwiek innego. Może wyglądać tak, jakby znajdował się w miejscu, w którym "nie ma znaczenia", ale napotkaliśmy drugi problem: po "naprawieniu" problemu w jednym abc_myfragment.xml, faktycznie musiałem go naprawić w abc_myfragment_large.xml - Android automatycznie dzwonił inny plik XML niż ten podany w kodzie, na podstawie urządzenia, na którym go uruchomiłem.

Górny wiersz swojego śladu stosu powinien pomóc zweryfikować, że szukasz w odpowiednim miejscu: android.view.InflateException: Binary XML file line #45: Error inflating class

ten informuje, że brakuje ColorStateList jest mowa w punkcie jakiegoś pliku XML gdzieś, i że ta kłopotliwa sekcja zaczyna się od linii 45 (tzn. tam jest otwarty wspornik kątowy - "<" - początek sekcji.)

PS Co to znaczy przez alias jest jednym z nich:

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

który dostaje osobne dalsze definicje w dwóch oddzielnych tematach:

<item name="afc_button_home">@drawable/afc_button_home_light</item> w themes_light.xml plików

i

<item name="afc_button_home">@drawable/afc_button_home_dark</item> w pliku themes_dark.xml

Kłopot powstaje, gdy ostatnia definicja zostanie usunięta z jednego z plików motywu.

EDIT

Następny krok: Zbadaj CustomActionBar „s zależności. Nie jestem ekspertem od stylów, więc zakładam, że istnieje 9 możliwych miejsc, w których Android może zobaczyć odniesienie do ColorStateList, których nie może znaleźć: w rodzicu CustomActionBar (Widget.Sherlock.Light.ActionBar.Solid.Inverse) oraz w każdym z 8 przedmioty, które zawiera. Skomentuj te 8 elementów i pozbądź się elementu nadrzędnego, a następnie uruchom ponownie aplikację w kłopotliwej konfiguracji. Sprawdź, czy błąd środowiska wykonawczego nie działa, lub, co bardziej prawdopodobne, zmiany (np. Numer linii (i identyfikator) zmieniają się z numeru 45, aby wskazać CustomActionBar.Facebook, w przypadku której wywoływanych jest wiele takich samych zasobów). Następnie cofaj zmiany jeden po drugim, aż błąd powróci do poprzedniego stanu. Spowoduje to dalszą lokalizację problemu. Po wprowadzeniu poprawki poruszaj się powoli, ponieważ jest możliwe, że jeśli znajdziesz problem (np. Jako nieistniejący odnośnik), zostanie on zreplikowany w wielu z 8 elementów. Odkomentuj jeden po drugim.

+0

Witam Merk, ta wartość jest odwzorowywana na atrybut stylu R $ CustomActionBar = 0x7f0d014c; To, co widzisz jest zdefiniowane powyżej, jest zdefiniowane dla wszystkich konfiguracji urządzeń i jest wymienione tylko w powyższym pliku theme.xml. – William

+0

patrz sekcja Edytuj powyżej ... – Merk

+1

Dzięki Merck. To nie było rozwiązanie, ale dałeś mi wystarczająco dużo pomysłów i włożyłeś w to wystarczająco dużo wysiłku, że przyznam ci nagrodę. Wymienię rozwiązanie za minutę. – William

2

Powtórz każdy plik zasobów, który właśnie skopiowałeś z innego projektu. Android nie rozpozna pliku zasobów. utwórz nowy plik zasobów i skopiuj i wklej kod ze starego do nowego.Nowy plik zasobów powinien zostać rozpoznany, a twoje kolory będą zbyt kolorowe.

1

Jednym szybkim i prostym rozwiązaniem tego problemu jest wyszukanie kodu binarnego w folderze projektu. To da nazwę zmiennej, która odnosi się do tej wartości. Na przykład w moim przypadku było to coś, tak -

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

Potem wystarczy wymienić wszystkie odniesienia dla tej zmiennej (akcent) w projekcie o wartości zakodowanego na stałe zdefiniowane odpowiadającego mu jakiś plik xml w projekcie, w moim przypadku był to #009688. To rozwiązało problem w moim przypadku.

Powiązane problemy