android的二进制XML的InflateException

时间:2015-05-27 21:53:38

标签: java android layout-inflater

我对android很新,我在代码的这一行得到了这个错误

public void onCreate(Bundle savedInstanceState)
    {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.splash);
        ....

加载此

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" 
    android:background="@drawable/splash">

</LinearLayout>

使用此stacktrace:

1808-1808/com.xxx.asso.xxx E/AndroidRuntime﹕ FATAL 

    EXCEPTION: main
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.xxx.asso.xxx/com.xxx.asso.xxx.SplashScreen}: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
    at android.app.ActivityThread.access$600(ActivityThread.java:141)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:5041)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
    at dalvik.system.NativeStart.main(Native Method)
    Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
    at android.view.LayoutInflater.createView(LayoutInflater.java:613)
    at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
    at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
    at android.app.Activity.setContentView(Activity.java:1881)
    at com.xxx.asso.xxx.SplashScreen.onCreate(SplashScreen.java:19)
    at android.app.Activity.performCreate(Activity.java:5104)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
                at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
                at android.app.ActivityThread.access$600(ActivityThread.java:141)
                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
                at android.os.Handler.dispatchMessage(Handler.java:99)
                at android.os.Looper.loop(Looper.java:137)
                at android.app.ActivityThread.main(ActivityThread.java:5041)
                at java.lang.reflect.Method.invokeNative(Native Method)
                at java.lang.reflect.Method.invoke(Method.java:511)
                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
                at dalvik.system.NativeStart.main(Native Method)
    Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Constructor.constructNative(Native Method)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
    at android.view.LayoutInflater.createView(LayoutInflater.java:587)
                at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
                at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
                at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
                at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
                at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
                at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
                at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
                at android.app.Activity.setContentView(Activity.java:1881)
                at com.xxx.asso.xxx.SplashScreen.onCreate(SplashScreen.java:19)
                at android.app.Activity.performCreate(Activity.java:5104)
                at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
                at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
                at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
                at android.app.ActivityThread.access$600(ActivityThread.java:141)
                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
                at android.os.Handler.dispatchMessage(Handler.java:99)
                at android.os.Looper.loop(Looper.java:137)
                at android.app.ActivityThread.main(ActivityThread.java:5041)
                at java.lang.reflect.Method.invokeNative(Native Method)
                at java.lang.reflect.Method.invoke(Method.java:511)
                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
                at dalvik.system.NativeStart.main(Native Method)
    Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f02007f a=-1 r=0x7f02007f}
    at android.content.res.Resources.loadDrawable(Resources.java:1927)
    at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
    at android.view.View.<init>(View.java:3330)
    at android.view.ViewGroup.<init>(ViewGroup.java:431)
        at android.widget.LinearLayout.<init>(LinearLayout.java:176)
            at android.widget.LinearLayout.<init>(LinearLayout.java:172)
                            at java.lang.reflect.Constructor.constructNative(Native Method)
                            at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
                            at android.view.LayoutInflater.createView(LayoutInflater.java:587)
                            at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
                            at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
                            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
                            at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
                            at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
                            at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
                            at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
                            at android.app.Activity.setContentView(Activity.java:1881)
                            at com.xxx.asso.xxx.SplashScreen.onCreate(SplashScreen.java:19)
                            at android.app.Activity.performCreate(Activity.java:5104)
                            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
                            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
                            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
                            at android.app.ActivityThread.access$600(ActivityThread.java:141)
                            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
                            at android.os.Handler.dispatchMessage(Handler.java:99)
                            at android.os.Looper.loop(Looper.java:137)
                            at android.app.ActivityThread.main(ActivityThread.java:5041)
                            at java.lang.reflect.Method.invokeNative(Native Method)
                            at java.lang.reflect.Method.invoke(Method.java:511)

我尝试了SO上找到的所有内容,但没有成功

1 个答案:

答案 0 :(得分:1)

 Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path)

Android无法找到这个可绘制的。

  

这是一些drawable-large-mdpi文件夹中的.png图像

也许您在小于-large的设备或模拟器上运行应用程序,并且您在其他地方没有其他实现。当您覆盖常规资源目录中可用的某些资源版本时,仅将资源放在-large资源目录中。所以,如果你splash.png中也有res/drawable-mdpi/,那很好,但我的猜测是你没有这样的抽奖。