/***************************************************************************** * 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( 2520): Token{4116dcf8 ActivityRecord{410d1f00 u0 com.aplex.ethernet/.MainActivity}} failed creating starting window W/WindowManager( 2520): android.view.InflateException: Binary XML file line #34: Error inflating class <unknown> W/WindowManager( 2520): at android.view.LayoutInflater.createView(LayoutInflater.java:613) W/WindowManager( 2520): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) W/WindowManager( 2520): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660) W/WindowManager( 2520): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685) W/WindowManager( 2520): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746) W/WindowManager( 2520): at android.view.LayoutInflater.inflate(LayoutInflater.java:489) W/WindowManager( 2520): at android.view.LayoutInflater.inflate(LayoutInflater.java:396) W/WindowManager( 2520): at android.view.LayoutInflater.inflate(LayoutInflater.java:352) W/WindowManager( 2520): at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2812) W/WindowManager( 2520): at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:2875) W/WindowManager( 2520): at com.android.internal.policy.impl.PhoneWindow.getDecorView(PhoneWindow.java:1568) W/WindowManager( 2520): at com.android.internal.policy.impl.PhoneWindowManager.addStartingWindow(PhoneWindowManager.java:1591) W/WindowManager( 2520): at com.android.server.wm.WindowManagerService$H.handleMessage(WindowManagerService.java:7450) W/WindowManager( 2520): at android.os.Handler.dispatchMessage(Handler.java:99) W/WindowManager( 2520): at android.os.Looper.loop(Looper.java:137) W/WindowManager( 2520): at android.os.HandlerThread.run(HandlerThread.java:60) W/WindowManager( 2520): Caused by: java.lang.reflect.InvocationTargetException W/WindowManager( 2520): at java.lang.reflect.Constructor.constructNative(Native Method) W/WindowManager( 2520): at java.lang.reflect.Constructor.newInstance(Constructor.java:417) W/WindowManager( 2520): at android.view.LayoutInflater.createView(LayoutInflater.java:587) W/WindowManager( 2520): ... 15 more W/WindowManager( 2520): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x2/d=0x1010059 a=-1} W/WindowManager( 2520): at android.content.res.Resources.loadDrawable(Resources.java:1927) W/WindowManager( 2520): at android.content.res.TypedArray.getDrawable(TypedArray.java:601) W/WindowManager( 2520): at android.widget.FrameLayout.<init>(FrameLayout.java:109) W/WindowManager( 2520): at android.widget.FrameLayout.<init>(FrameLayout.java:97) W/WindowManager( 2520): ... 18 more 三、解决办法: 1. cat AndroidManifest.xml ...... <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/theme" > ...... 2. 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> 3. 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> 4. 修改为如下: 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>
时间: 2024-11-05 02:00:34