주어진 문제가 있습니다.android.view.InflateException : 이진 XML 파일 줄 # 39 : 오류가 발생하는 클래스
갤럭시 s2에서 모든 것이 잘 작동합니다. noname android 2.3 (휴대 전화 및 7 '태블릿) - 모든 것이 정상입니다. 하지만 은하계 tab2 및 note2는이 오류를 제공합니다. 여기
는 스택 추적입니다 :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 :
<?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, hdpi에와 xhdpi 폴더에 존재합니다.
오류가 다음 줄에 발생합니다
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main);
그리고 여기에 버튼
<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" />
어떤 문제에 대한 XML의 일부인가?
'btn_copy.xml'은'/ drawable /'에 있습니까? –
예 /res/drawable/btn_copy.xml – user1284151
이상합니다. 'MainActivity'에서'btn_copy.xml'을 참조하는 방법을 게시하여 더 많은 단서를 제공 할 수 있습니까? –