已解决_Android_Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (

报这种错误,但是程序不强制退出。

11-18 16:02:26.490: W/WindowManager(312): Token{420aaa08 ActivityRecord{41c5fef8 com.rk.jcz/.IndexActivity}} failed creating starting window

11-18 16:02:26.490: W/WindowManager(312): android.view.InflateException: Binary XML file line #34: Error inflating class

11-18 16:02:26.490: W/WindowManager(312):  at android.view.LayoutInflater.createView(LayoutInflater.java:606)

11-18 16:02:26.490: W/WindowManager(312):  at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)

11-18 16:02:26.490: W/WindowManager(312):  at android.view.LayoutInflater.onCreateView(LayoutInflater.java:653)

11-18 16:02:26.490: W/WindowManager(312):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678)

11-18 16:02:26.490: W/WindowManager(312):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)

11-18 16:02:26.490: W/WindowManager(312):  at android.view.LayoutInflater.inflate(LayoutInflater.java:489)

11-18 16:02:26.490: W/WindowManager(312):  at android.view.LayoutInflater.inflate(LayoutInflater.java:396)

11-18 16:02:26.490: W/WindowManager(312):  at android.view.LayoutInflater.inflate(LayoutInflater.java:352)

11-18 16:02:26.490: W/WindowManager(312):  at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2753)

11-18 16:02:26.490: W/WindowManager(312):  at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:2813)

11-18 16:02:26.490: W/WindowManager(312):  at com.android.internal.policy.impl.PhoneWindow.getDecorView(PhoneWindow.java:1554)

11-18 16:02:26.490: W/WindowManager(312):  at com.android.internal.policy.impl.PhoneWindowManager.addStartingWindow(PhoneWindowManager.java:1369)

11-18 16:02:26.490: W/WindowManager(312):  at com.android.server.wm.WindowManagerService$H.handleMessage(WindowManagerService.java:6677)

11-18 16:02:26.490: W/WindowManager(312):  at android.os.Handler.dispatchMessage(Handler.java:99)

11-18 16:02:26.490: W/WindowManager(312):  at android.os.Looper.loop(Looper.java:137)

11-18 16:02:26.490: W/WindowManager(312):  at com.android.server.wm.WindowManagerService$WMThread.run(WindowManagerService.java:703)

11-18 16:02:26.490: W/WindowManager(312): Caused by: java.lang.reflect.InvocationTargetException

11-18 16:02:26.490: W/WindowManager(312):  at java.lang.reflect.Constructor.constructNative(Native Method)

11-18 16:02:26.490: W/WindowManager(312):  at java.lang.reflect.Constructor.newInstance(Constructor.java:417)

11-18 16:02:26.490: W/WindowManager(312):  at android.view.LayoutInflater.createView(LayoutInflater.java:586)

11-18 16:02:26.490: W/WindowManager(312):  ... 15 more

11-18 16:02:26.490: W/WindowManager(312): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x2/d=0x1010059 a=-1}

11-18 16:02:26.490: W/WindowManager(312):  at android.content.res.Resources.loadDrawable(Resources.java:1906)

11-18 16:02:26.490: W/WindowManager(312):  at android.content.res.TypedArray.getDrawable(TypedArray.java:601)

11-18 16:02:26.490: W/WindowManager(312):  at android.widget.FrameLayout.(FrameLayout.java:107)

11-18 16:02:26.490: W/WindowManager(312):  at android.widget.FrameLayout.(FrameLayout.java:95)

11-18 16:02:26.490: W/WindowManager(312):  ... 18 more

程序报这种错误,但是不强制退出,尤其是红色部分误导思路,虽然它提示找不到图片资源,从理论上来说应该是某个图片没有引用对,或者所引用的资源不存在,当然,假如所引用的图片资源不存在也可能报这个错误,但是这里经过调试,发现明显不是这么回事。

解决方案
经过多方查资料,发现有的朋友发现了解决之道,但是没有描述清楚,在这里我详细描述一下:
AndroidManifest.xml 工程的这个文件中,如果
 
        android:name=".v3.JCZApp"
        android:allowBackup="true"
        android:icon="@drawable/icon"
        android:label="@string/app_name"
        android:theme="@style/ThemeActivity" >
这部分,有指定了theme: ,我这里是   android:theme="@style/ThemeActivity" ,
然后查看详细的 @style/ThemeActivity 定义如下:
 
有的朋友点出了关键点:theme,就是主题定义,在这个style中,加上   parent="android:Theme" ,再运行,发现问题解决,改后的style如下:
 


你可能感兴趣的:(Android开发)