gpt4 book ai didi

android - Samsung Galaxy/Holoeverywhere - 资源不是 ColorStateList(颜色或路径)

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:33:00 25 4
gpt4 key购买 nike

我在 Samsung Galaxy Ace/Y/Pocket/Mini 上遇到以下崩溃。它在所有其他设备上运行良好。崩溃仅发生在 Android 2.3.5 或 2.3.6 上

堆栈跟踪中没有对我的代码的引用。它似乎来 self 没有定制的菜单布局。

我怀疑这是 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'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>

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

最佳答案

我很确定我遇到过同样的问题。我敢打赌它与操作系统无关。这是由 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 ,并搜索给定的 ID 代码: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 项并删除父项,然后在麻烦的配置中重新运行您的应用程序。检查运行时错误是否消失,或者更有可能发生变化(例如,行号(和 id)从 #45 变为指示 CustomActionBar.Facebook 而不是调用许多相同的资源)。然后一个一个的撤销修改,直到错误变回原来的样子。这将进一步定位问题。尝试修复后,慢慢移动,因为如果您确实发现了问题(例如,作为不存在的引用),它可能会在 8 个项目中的多个项目中重复出现。所以一一取消注释。

关于android - Samsung Galaxy/Holoeverywhere - 资源不是 ColorStateList(颜色或路径),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18602820/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com