二进制XML文件行#39

二进制XML文件行#39

本文介绍了android.view.InflateException:二进制XML文件行#39:错误充气类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在面临的问题给出

在银河S2一切正常,在NONAME的Andr​​oid 2.3(手机和7平板电脑) - 万物是确定的。
但银河TAB2和注2给出了这样的错误。

On galaxy s2 everything works well, on noname android 2.3 (phone and 7' tablet) - everythings is ok.But galaxy tab2 and note2 gives this error.

下面是堆栈跟踪:

06-27 21:28:20.659: E/AndroidRuntime(23924): FATAL EXCEPTION: main
06-27 21:28:20.659: E/AndroidRuntime(23924): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myPackage.myProject/com.myPackage.myProject.MainActivity}: android.view.InflateException: Binary XML file line #39: Error inflating class <unknown>
06-27 21:28:20.659: E/AndroidRuntime(23924):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1968)
06-27 21:28:20.659: E/AndroidRuntime(23924):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1993)
06-27 21:28:20.659: E/AndroidRuntime(23924):    at android.app.ActivityThread.access$600(ActivityThread.java:127)
06-27 21:28:20.659: E/AndroidRuntime(23924):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1159)
06-27 21:28:20.659: E/AndroidRuntime(23924):    at android.os.Handler.dispatchMessage(Handler.java:99)
06-27 21:28:20.659: E/AndroidRuntime(23924):    at android.os.Looper.loop(Looper.java:137)
06-27 21:28:20.659: E/AndroidRuntime(23924):    at android.app.ActivityThread.main(ActivityThread.java:4507)
06-27 21:28:20.659: E/AndroidRuntime(23924):    at java.lang.reflect.Method.invokeNative(Native Method)
06-27 21:28:20.659: E/AndroidRuntime(23924):    at java.lang.reflect.Method.invoke(Method.java:511)
06-27 21:28:20.659: E/AndroidRuntime(23924):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:978)
06-27 21:28:20.659: E/AndroidRuntime(23924):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:745)
06-27 21:28:20.659: E/AndroidRuntime(23924):    at dalvik.system.NativeStart.main(Native Method)
06-27 21:28:20.659: E/AndroidRuntime(23924): Caused by: android.view.InflateException: Binary XML file line #39: Error inflating class <unknown>
06-27 21:28:20.659: E/AndroidRuntime(23924):    at android.view.LayoutInflater.createView(LayoutInflater.java:606)
06-27 21:28:20.659: E/AndroidRuntime(23924):    at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
06-27 21:28:20.659: E/AndroidRuntime(23924):    at android.view.LayoutInflater.onCreateView(LayoutInflater.java:653)
06-27 21:28:20.659: E/AndroidRuntime(23924):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678)
06-27 21:28:20.659: E/AndroidRuntime(23924):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
06-27 21:28:20.659: E/AndroidRuntime(23924):    at android.view.LayoutInflater.parseInclude(LayoutInflater.java:798)
06-27 21:28:20.659: E/AndroidRuntime(23924):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:729)
06-27 21:28:20.659: E/AndroidRuntime(23924):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
06-27 21:28:20.659: E/AndroidRuntime(23924):    at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
06-27 21:28:20.659: E/AndroidRuntime(23924):    at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
06-27 21:28:20.659: E/AndroidRuntime(23924):    at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
06-27 21:28:20.659: E/AndroidRuntime(23924):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:272)
06-27 21:28:20.659: E/AndroidRuntime(23924):    at android.app.Activity.setContentView(Activity.java:1835)
06-27 21:28:20.659: E/AndroidRuntime(23924):    at com.myPackage.myProject.MainActivity.onCreate(MainActivity.java:53)
06-27 21:28:20.659: E/AndroidRuntime(23924):    at android.app.Activity.performCreate(Activity.java:4469)
06-27 21:28:20.659: E/AndroidRuntime(23924):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1052)
06-27 21:28:20.659: E/AndroidRuntime(23924):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1932)
06-27 21:28:20.659: E/AndroidRuntime(23924):    ... 11 more
06-27 21:28:20.659: E/AndroidRuntime(23924): Caused by: java.lang.reflect.InvocationTargetException
06-27 21:28:20.659: E/AndroidRuntime(23924):    at java.lang.reflect.Constructor.constructNative(Native Method)
06-27 21:28:20.659: E/AndroidRuntime(23924):    at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
06-27 21:28:20.659: E/AndroidRuntime(23924):    at android.view.LayoutInflater.createView(LayoutInflater.java:586)
06-27 21:28:20.659: E/AndroidRuntime(23924):    ... 27 more
06-27 21:28:20.659: E/AndroidRuntime(23924): Caused by: android.content.res.Resources$NotFoundException: File res/drawable/btn_copy.xml from drawable resource ID #0x7f020002
06-27 21:28:20.659: E/AndroidRuntime(23924):    at android.content.res.Resources.loadDrawable(Resources.java:1956)
06-27 21:28:20.659: E/AndroidRuntime(23924):    at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
06-27 21:28:20.659: E/AndroidRuntime(23924):    at android.widget.ImageView.<init>(ImageView.java:119)
06-27 21:28:20.659: E/AndroidRuntime(23924):    at android.widget.ImageButton.<init>(ImageButton.java:85)
06-27 21:28:20.659: E/AndroidRuntime(23924):    at android.widget.ImageButton.<init>(ImageButton.java:81)
06-27 21:28:20.659: E/AndroidRuntime(23924):    ... 30 more
06-27 21:28:20.659: E/AndroidRuntime(23924): Caused by: java.lang.NullPointerException
06-27 21:28:20.659: E/AndroidRuntime(23924):    at android.graphics.drawable.DrawableContainer$DrawableContainerState.addChild(DrawableContainer.java:515)
06-27 21:28:20.659: E/AndroidRuntime(23924):    at android.graphics.drawable.StateListDrawable$StateListState.addStateSet(StateListDrawable.java:278)
06-27 21:28:20.659: E/AndroidRuntime(23924):    at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:186)
06-27 21:28:20.659: E/AndroidRuntime(23924):    at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:867)
06-27 21:28:20.659: E/AndroidRuntime(23924):    at android.graphics.drawable.Drawable.createFromXml(Drawable.java:804)
06-27 21:28:20.659: E/AndroidRuntime(23924):    at android.content.res.Resources.loadDrawable(Resources.java:1953)
06-27 21:28:20.659: E/AndroidRuntime(23924):    ... 34 more

btn_copy.xml:

btn_copy.xml:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:state_pressed="true" android:drawable="@drawable/btn_copy_clicked" /> <!-- pressed -->
  <item android:drawable="@drawable/btn_copy_normal" /> <!-- default -->
</selector>

btn_copy_clicked和btn_copy_normal在LDPI,MDPI,华电国际和xhdpi文件夹存在。

btn_copy_clicked and btn_copy_normal exists in ldpi, mdpi, hdpi and xhdpi folders.

以下行发生错误:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_main);

这是XML为按钮

<ImageButton
    android:id="@+id/button_copy"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:layout_below="@+id/edit_to"
    android:layout_marginTop="8dp"
    android:background="@android:color/transparent"
    android:src="@drawable/btn_copy" />

怎么了?

推荐答案

尝试移动btn_copy_clicked和平淡的绘制的文件夹btn_copy_normal

Try moving btn_copy_clicked and btn_copy_normal in plain "drawable" folder

这篇关于android.view.InflateException:二进制XML文件行#39:错误充气类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-02 02:11