由于资源$NotFoundException,应用程序在Android API 10启动时崩溃,但不会在API 16上崩溃

由于资源$NotFoundException,应用程序在Android API 10启动时崩溃,但不会在API 16上崩溃,第1张

概述我的应用程序在我运行 Android 4.1.2的Samsung Galaxy S3手机上启动并启动,但是当我尝试在运行Android 2.3.4的摩托罗拉Droid X上测试相同的应用程序时,在我的Droid X屏幕上甚至显示任何内容之前,该应用程序崩溃. 我的LogCat在下面.不幸的是,它并没有指出我的代码正在失败的部分,但由于这些例外,它似乎与我的布局有关: 08-09 10:43:39. 我的应用程序在我运行 Android 4.1.2的Samsung galaxy S3手机上启动并启动,但是当我尝试在运行AndroID 2.3.4的摩托罗拉DroID X上测试相同的应用程序时,在我的DroID X屏幕上甚至显示任何内容之前,该应用程序崩溃.

我的LogCat在下面.不幸的是,它并没有指出我的代码正在失败的部分,但由于这些例外,它似乎与我的布局有关:

08-09 10:43:39.686: E/AndroIDRuntime(3192): FATAL EXCEPTION: main08-09 10:43:39.686: E/AndroIDRuntime(3192): androID.vIEw.InflateException: Binary XML file line #11: Error inflating class <unkNown>08-09 10:43:39.686: E/AndroIDRuntime(3192): Caused by: java.lang.reflect.InvocationTargetException`  08-09 10:43:39.686: E/AndroIDRuntime(3192): Caused by: androID.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x2/d=0x10102fd a=-1}

日志猫:

08-09 10:43:39.686: E/AndroIDRuntime(3192): FATAL EXCEPTION: main08-09 10:43:39.686: E/AndroIDRuntime(3192): androID.vIEw.InflateException: Binary XML file line #11: Error inflating class <unkNown>08-09 10:43:39.686: E/AndroIDRuntime(3192):     at androID.vIEw.LayoutInflater.createVIEw(LayoutInflater.java:518)08-09 10:43:39.686: E/AndroIDRuntime(3192):     at com.androID.internal.policy.impl.PhoneLayoutInflater.onCreateVIEw(PhoneLayoutInflater.java:56)08-09 10:43:39.686: E/AndroIDRuntime(3192):     at androID.vIEw.LayoutInflater.createVIEwFromTag(LayoutInflater.java:568)08-09 10:43:39.686: E/AndroIDRuntime(3192):     at androID.vIEw.LayoutInflater.inflate(LayoutInflater.java:386)08-09 10:43:39.686: E/AndroIDRuntime(3192):     at androID.vIEw.LayoutInflater.inflate(LayoutInflater.java:320)08-09 10:43:39.686: E/AndroIDRuntime(3192):     at androID.Widget.ArrayAdapter.createVIEwFromresource(ArrayAdapter.java:332)08-09 10:43:39.686: E/AndroIDRuntime(3192):     at androID.Widget.ArrayAdapter.getVIEw(ArrayAdapter.java:323)08-09 10:43:39.686: E/AndroIDRuntime(3192):     at androID.Widget.AbsListVIEw.obtainVIEw(AbsListVIEw.java:1456)08-09 10:43:39.686: E/AndroIDRuntime(3192):     at androID.Widget.ListVIEw.makeAndAddVIEw(ListVIEw.java:1821)08-09 10:43:39.686: E/AndroIDRuntime(3192):     at androID.Widget.ListVIEw.fillDown(ListVIEw.java:686)08-09 10:43:39.686: E/AndroIDRuntime(3192):     at androID.Widget.ListVIEw.fillFromtop(ListVIEw.java:754)08-09 10:43:39.686: E/AndroIDRuntime(3192):     at androID.Widget.ListVIEw.layoutChildren(ListVIEw.java:1670)08-09 10:43:39.686: E/AndroIDRuntime(3192):     at androID.Widget.AbsListVIEw.onLayout(AbsListVIEw.java:1286)08-09 10:43:39.686: E/AndroIDRuntime(3192):     at androID.vIEw.VIEw.layout(VIEw.java:7184)08-09 10:43:39.686: E/AndroIDRuntime(3192):     at androID.support.v4.Widget.DrawerLayout.onLayout(DrawerLayout.java:702)08-09 10:43:39.686: E/AndroIDRuntime(3192):     at androID.vIEw.VIEw.layout(VIEw.java:7184)08-09 10:43:39.686: E/AndroIDRuntime(3192):     at androID.Widget.FrameLayout.onLayout(FrameLayout.java:338)08-09 10:43:39.686: E/AndroIDRuntime(3192):     at androID.vIEw.VIEw.layout(VIEw.java:7184)08-09 10:43:39.686: E/AndroIDRuntime(3192):     at androID.Widget.linearLayout.setChildFrame(linearLayout.java:1254)08-09 10:43:39.686: E/AndroIDRuntime(3192):     at androID.Widget.linearLayout.layoutVertical(linearLayout.java:1130)08-09 10:43:39.686: E/AndroIDRuntime(3192):     at androID.Widget.linearLayout.onLayout(linearLayout.java:1047)08-09 10:43:39.686: E/AndroIDRuntime(3192):     at androID.vIEw.VIEw.layout(VIEw.java:7184)08-09 10:43:39.686: E/AndroIDRuntime(3192):     at androID.Widget.FrameLayout.onLayout(FrameLayout.java:338)08-09 10:43:39.686: E/AndroIDRuntime(3192):     at androID.vIEw.VIEw.layout(VIEw.java:7184)08-09 10:43:39.686: E/AndroIDRuntime(3192):     at androID.Widget.FrameLayout.onLayout(FrameLayout.java:338)08-09 10:43:39.686: E/AndroIDRuntime(3192):     at androID.vIEw.VIEw.layout(VIEw.java:7184)08-09 10:43:39.686: E/AndroIDRuntime(3192):     at androID.vIEw.VIEwRoot.performTraversals(VIEwRoot.java:1140)08-09 10:43:39.686: E/AndroIDRuntime(3192):     at androID.vIEw.VIEwRoot.handleMessage(VIEwRoot.java:1859)08-09 10:43:39.686: E/AndroIDRuntime(3192):     at androID.os.Handler.dispatchMessage(Handler.java:99)08-09 10:43:39.686: E/AndroIDRuntime(3192):     at androID.os.Looper.loop(Looper.java:130)08-09 10:43:39.686: E/AndroIDRuntime(3192):     at androID.app.ActivityThread.main(ActivityThread.java:3806)08-09 10:43:39.686: E/AndroIDRuntime(3192):     at java.lang.reflect.Method.invokeNative(Native Method)08-09 10:43:39.686: E/AndroIDRuntime(3192):     at java.lang.reflect.Method.invoke(Method.java:507)08-09 10:43:39.686: E/AndroIDRuntime(3192):     at com.androID.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)08-09 10:43:39.686: E/AndroIDRuntime(3192):     at com.androID.internal.os.ZygoteInit.main(ZygoteInit.java:597)08-09 10:43:39.686: E/AndroIDRuntime(3192):     at dalvik.system.NativeStart.main(Native Method)08-09 10:43:39.686: E/AndroIDRuntime(3192): Caused by: java.lang.reflect.InvocationTargetException08-09 10:43:39.686: E/AndroIDRuntime(3192):     at java.lang.reflect.Constructor.constructNative(Native Method)08-09 10:43:39.686: E/AndroIDRuntime(3192):     at java.lang.reflect.Constructor.newInstance(Constructor.java:415)08-09 10:43:39.686: E/AndroIDRuntime(3192):     at androID.vIEw.LayoutInflater.createVIEw(LayoutInflater.java:505)08-09 10:43:39.686: E/AndroIDRuntime(3192):     ... 35 more08-09 10:43:39.686: E/AndroIDRuntime(3192): Caused by: androID.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x2/d=0x10102fd a=-1}08-09 10:43:39.686: E/AndroIDRuntime(3192):     at androID.content.res.Resources.loadDrawable(Resources.java:1719)08-09 10:43:39.686: E/AndroIDRuntime(3192):     at androID.content.res.TypedArray.getDrawable(TypedArray.java:601)08-09 10:43:39.686: E/AndroIDRuntime(3192):     at androID.vIEw.VIEw.<init>(VIEw.java:1951)08-09 10:43:39.686: E/AndroIDRuntime(3192):     at androID.Widget.TextVIEw.<init>(TextVIEw.java:453)08-09 10:43:39.686: E/AndroIDRuntime(3192):     at androID.Widget.TextVIEw.<init>(TextVIEw.java:446)08-09 10:43:39.686: E/AndroIDRuntime(3192):     ... 38 more08-09 10:43:42.201: I/Process(3192): Sending signal. PID: 3192 SIG: 9
解决方法 固定!!

看看它更多,它看起来像它与ArrayAdapter以及我的布局有关.我正在为我的ArrayAdapter使用一个自定义布局(drawer_List_item.xml),它具有我猜测的一些ICS特定代码,所以我只需要从该XML文件中删除一些行,并且该应用在AndroID API 10(特别是AndroID 2.3)上启动. 4).特别在我的布局文件中引起问题的行是:

androID:background="?androID:attr/activatedBackgroundindicator"androID:minHeight="?androID:attr/ListPreferredItemHeightSmall"

以下是我的SherlockFragmentActivity中导致布局异常/崩溃的代码:

m_drawerList.setAdapter(new ArrayAdapter<String>(getSupportActionbar().getthemedContext(),R.layout.drawer_List_item,m_drawernames));

olD drawer_List_item.xml代码:

<TextVIEw xmlns:androID="http://schemas.androID.com/apk/res/androID"androID:ID="@androID:ID/text1"androID:layout_wIDth="match_parent"androID:layout_height="wrap_content"androID:textAppearance="?androID:attr/textAppearanceListItemSmall"<!-- Deleted line-->androID:gravity="center_vertical"androID:paddingleft="16dp"androID:paddingRight="16dp"androID:textcolor="#fff"androID:background="?androID:attr/activatedBackgroundindicator"<!-- Deleted line-->androID:minHeight="?androID:attr/ListPreferredItemHeightSmall"/> <!-- Deleted line-->

FIXED drawer_List_item.xml代码:

<TextVIEw xmlns:androID="http://schemas.androID.com/apk/res/androID"androID:ID="@androID:ID/text1"androID:layout_wIDth="match_parent"androID:layout_height="wrap_content"androID:gravity="center_vertical"androID:padding="16dp"androID:textcolor="#fff" />
总结

以上是内存溢出为你收集整理的由于资源$NotFoundException,应用程序在Android API 10启动时崩溃,但不会在API 16上崩溃全部内容,希望文章能够帮你解决由于资源$NotFoundException,应用程序在Android API 10启动时崩溃,但不会在API 16上崩溃所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1132022.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存