Android failed creating starting window

简介: /***************************************************************************** * Android failed creating starting window * 声明: * 最近正在整的一个App在logcat中总是报这种异常,貌似也不影响程序的运行,但 * 每次都看到这种异常实在是难受,于是还是查点资料解决了去吧。
/*****************************************************************************
 *               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>
    

 

目录
相关文章
|
7月前
|
Android开发
【Bug】Android resource linking failed和error: failed linking references.
【Bug】Android resource linking failed和error: failed linking references.
|
Android开发
android学习之——Gradle sync failed: Could not determine artifacts for xxxxx
android学习之——Gradle sync failed: Could not determine artifacts for xxxxx
android学习之——Gradle sync failed: Could not determine artifacts for xxxxx
|
7月前
|
Android开发
Caused by: android.system.ErrnoException: android_getaddrinfo failed: EACCES (Permission denied)
Caused by: android.system.ErrnoException: android_getaddrinfo failed: EACCES (Permission denied)
83 3
|
7月前
Caused by: android.system.GaiException: android_getaddrinfo failed: EAI_NODATA (No address associate
Caused by: android.system.GaiException: android_getaddrinfo failed: EAI_NODATA (No address associate
220 2
|
4月前
|
Android开发
Android Studio: 解决Gradle sync failed 错误
本文介绍了解决Android Studio中出现的Gradle同步失败错误的步骤,包括从`gradle-wrapper.properties`文件中获取Gradle的下载链接,手动下载Gradle压缩包,并替换默认下载路径中的临时文件,然后重新触发Android Studio的"Try Again"来完成同步。
1783 0
Android Studio: 解决Gradle sync failed 错误
|
4月前
|
开发工具 Android开发
解决Manifest merger failed : android:exported needs to be explicitly specified for <activity>
解决Manifest merger failed : android:exported needs to be explicitly specified for <activity>
113 1
|
4月前
|
开发工具 Android开发
Android Studio resource linking failed
Android Studio resource linking failed
99 1
|
5月前
|
消息中间件 前端开发 Android开发
Android面试题自定义View之Window、ViewRootImpl和View的三大流程
Android开发中,View的三大核心流程包括measure(测量)、layout(布局)和draw(绘制)。MeasureSpec类在测量过程中起到关键作用,它结合尺寸大小和模式(EXACTLY、AT_MOST、UNSPECIFIED)来指定View应如何测量。onMeasure方法用于自定义View的测量,布局阶段,ViewGroup调用onLayout确定子元素位置,而draw阶段按照特定顺序绘制背景、内容、子元素和装饰。整个流程始于ViewRootImpl的performTraversals,该方法触发测量、布局和绘制。
123 0
|
6月前
|
Java Linux 开发工具
由" failed to run the android sdk manager"引起的一系列问题 android
由" failed to run the android sdk manager"引起的一系列问题 android
|
开发工具 Android开发 iOS开发
使用xamarin开发Android、iOS报错failed to open directory: 系统找不到指定的文件
使用vs2019学习xamarin时,创建新程序。使用模拟器真机等测试都报错如下图错误: ![请在此添加图片描述](https://developer-private-1258344699.cos.ap-guangzhou.myqcloud.com/column/article/5877188/20231030-de8ce5fd.png?x-cos-security-token=r4KyZDEowPT0kGTL0LqE8EnwfN1Nzexadb05dcffed3939ff8d7591c528c01706nvpGSE93QwHpZM8NwhJNTZctNRQa0l3KDhEnqj8P7d8t
127 0
使用xamarin开发Android、iOS报错failed to open directory: 系统找不到指定的文件