/*****************************************************************************
* Android failed creating starting window
* 声明:
* 最近正在整的一个App在logcat中总是报这种异常,貌似也不影响程序的运行,但
* 每次都看到这种异常实在是难受,于是还是查点资料解决了去吧。
*
* 2016-5-5 深圳 南山平山村 曾剑锋
****************************************************************************/ 一、参考文章:
已解决_Android_Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (
http://blog.csdn.net/tianshanaoxue/article/details/16806283 二、error:
W/WindowManager( ): Token{4116dcf8 ActivityRecord{410d1f00 u0 com.aplex.ethernet/.MainActivity}} failed creating starting window
W/WindowManager( ): android.view.InflateException: Binary XML file line #: Error inflating class <unknown>
W/WindowManager( ): at android.view.LayoutInflater.createView(LayoutInflater.java:)
W/WindowManager( ): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:)
W/WindowManager( ): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:)
W/WindowManager( ): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:)
W/WindowManager( ): at android.view.LayoutInflater.rInflate(LayoutInflater.java:)
W/WindowManager( ): at android.view.LayoutInflater.inflate(LayoutInflater.java:)
W/WindowManager( ): at android.view.LayoutInflater.inflate(LayoutInflater.java:)
W/WindowManager( ): at android.view.LayoutInflater.inflate(LayoutInflater.java:)
W/WindowManager( ): at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:)
W/WindowManager( ): at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:)
W/WindowManager( ): at com.android.internal.policy.impl.PhoneWindow.getDecorView(PhoneWindow.java:)
W/WindowManager( ): at com.android.internal.policy.impl.PhoneWindowManager.addStartingWindow(PhoneWindowManager.java:)
W/WindowManager( ): at com.android.server.wm.WindowManagerService$H.handleMessage(WindowManagerService.java:)
W/WindowManager( ): at android.os.Handler.dispatchMessage(Handler.java:)
W/WindowManager( ): at android.os.Looper.loop(Looper.java:)
W/WindowManager( ): at android.os.HandlerThread.run(HandlerThread.java:)
W/WindowManager( ): Caused by: java.lang.reflect.InvocationTargetException
W/WindowManager( ): at java.lang.reflect.Constructor.constructNative(Native Method)
W/WindowManager( ): at java.lang.reflect.Constructor.newInstance(Constructor.java:)
W/WindowManager( ): at android.view.LayoutInflater.createView(LayoutInflater.java:)
W/WindowManager( ): ... more
W/WindowManager( ): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x2/d=0x1010059 a=-}
W/WindowManager( ): at android.content.res.Resources.loadDrawable(Resources.java:)
W/WindowManager( ): at android.content.res.TypedArray.getDrawable(TypedArray.java:)
W/WindowManager( ): at android.widget.FrameLayout.<init>(FrameLayout.java:)
W/WindowManager( ): at android.widget.FrameLayout.<init>(FrameLayout.java:)
W/WindowManager( ): ... more 三、解决办法:
. cat AndroidManifest.xml
......
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/theme" >
......
. cat res/values/styles.xml
<resources> <!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style> <!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style> <style name="style_quicksettings_category_text">
<item name="android:textColor">@color/qs_text_title</item>
<item name="android:fontFamily">sans-serif</item>
</style> </resources>
. cat res/values/themes.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="theme">
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">?android:windowNoTitle</item>
<item name="android:windowBackground">@android:drawable/screen_background_dark</item>
<item name="android:windowFrame">@null</item>
<item name="android:windowAnimationStyle">@android:style/Animation.Activity</item>
</style>
</resources>
. 修改为如下:
cat res/values/themes.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="theme" parent="AppTheme">
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">?android:windowNoTitle</item>
<item name="android:windowBackground">@android:drawable/screen_background_dark</item>
<item name="android:windowFrame">@null</item>
<item name="android:windowAnimationStyle">@android:style/Animation.Activity</item>
</style>
</resources>