Невозможно запустить действие ComponentInfo. Вызвано: android.view.InflateException
Мое приложение для Android аварийно завершает работу при открытии определенной активности и выдает мне следующее исключение:
02-06 10:31:53.608: ERROR/AndroidRuntime(594): FATAL EXCEPTION: main
02-06 10:31:53.608: ERROR/AndroidRuntime(594): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.solaceap/com.example.solaceap.RemoteTV}: android.view.InflateException: Binary XML file line #600: Error inflating class <unknown>
02-06 10:31:53.608: ERROR/AndroidRuntime(594): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1955)
02-06 10:31:53.608: ERROR/AndroidRuntime(594): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
02-06 10:31:53.608: ERROR/AndroidRuntime(594): at android.app.ActivityThread.access$600(ActivityThread.java:122)
02-06 10:31:53.608: ERROR/AndroidRuntime(594): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
02-06 10:31:53.608: ERROR/AndroidRuntime(594): at android.os.Handler.dispatchMessage(Handler.java:99)
02-06 10:31:53.608: ERROR/AndroidRuntime(594): at android.os.Looper.loop(Looper.java:137)
02-06 10:31:53.608: ERROR/AndroidRuntime(594): at android.app.ActivityThread.main(ActivityThread.java:4340)
02-06 10:31:53.608: ERROR/AndroidRuntime(594): at java.lang.reflect.Method.invokeNative(Native Method)
02-06 10:31:53.608: ERROR/AndroidRuntime(594): at java.lang.reflect.Method.invoke(Method.java:511)
02-06 10:31:53.608: ERROR/AndroidRuntime(594): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
02-06 10:31:53.608: ERROR/AndroidRuntime(594): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
02-06 10:31:53.608: ERROR/AndroidRuntime(594): at dalvik.system.NativeStart.main(Native Method)
02-06 10:31:53.608: ERROR/AndroidRuntime(594): Caused by: android.view.InflateException: Binary XML file line #600: Error inflating class <unknown>
02-06 10:31:53.608: ERROR/AndroidRuntime(594): at android.view.LayoutInflater.createView(LayoutInflater.java:606)
02-06 10:31:53.608: ERROR/AndroidRuntime(594): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
02-06 10:31:53.608: ERROR/AndroidRuntime(594): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:653)
02-06 10:31:53.608: ERROR/AndroidRuntime(594): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678)
02-06 10:31:53.608: ERROR/AndroidRuntime(594): at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
02-06 10:31:53.608: ERROR/AndroidRuntime(594): at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
02-06 10:31:53.608: ERROR/AndroidRuntime(594): at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
02-06 10:31:53.608: ERROR/AndroidRuntime(594): at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
02-06 10:31:53.608: ERROR/AndroidRuntime(594): at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
02-06 10:31:53.608: ERROR/AndroidRuntime(594): at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
02-06 10:31:53.608: ERROR/AndroidRuntime(594): at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
02-06 10:31:53.608: ERROR/AndroidRuntime(594): at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
02-06 10:31:53.608: ERROR/AndroidRuntime(594): at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
02-06 10:31:53.608: ERROR/AndroidRuntime(594): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
02-06 10:31:53.608: ERROR/AndroidRuntime(594): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
02-06 10:31:53.608: ERROR/AndroidRuntime(594): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
02-06 10:31:53.608: ERROR/AndroidRuntime(594): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
02-06 10:31:53.608: ERROR/AndroidRuntime(594): at android.app.Activity.setContentView(Activity.java:1835)
02-06 10:31:53.608: ERROR/AndroidRuntime(594): at com.example.solaceap.RemoteTV.onCreate(RemoteTV.java:84)
02-06 10:31:53.608: ERROR/AndroidRuntime(594): at android.app.Activity.performCreate(Activity.java:4465)
02-06 10:31:53.608: ERROR/AndroidRuntime(594): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
02-06 10:31:53.608: ERROR/AndroidRuntime(594): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1919)
02-06 10:31:53.608: ERROR/AndroidRuntime(594): ... 11 more
02-06 10:31:53.608: ERROR/AndroidRuntime(594): Caused by: java.lang.reflect.InvocationTargetException
02-06 10:31:53.608: ERROR/AndroidRuntime(594): at java.lang.reflect.Constructor.constructNative(Native Method)
02-06 10:31:53.608: ERROR/AndroidRuntime(594): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
02-06 10:31:53.608: ERROR/AndroidRuntime(594): at android.view.LayoutInflater.createView(LayoutInflater.java:586)
02-06 10:31:53.608: ERROR/AndroidRuntime(594): ... 32 more
02-06 10:31:53.608: ERROR/AndroidRuntime(594): Caused by: android.content.res.Resources$NotFoundException: File res/drawable/remote_tv_num_buttons.xml from drawable resource ID #0x7f02017f
02-06 10:31:53.608: ERROR/AndroidRuntime(594): at android.content.res.Resources.loadDrawable(Resources.java:1925)
02-06 10:31:53.608: ERROR/AndroidRuntime(594): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
02-06 10:31:53.608: ERROR/AndroidRuntime(594): at android.view.View.<init>(View.java:2780)
02-06 10:31:53.608: ERROR/AndroidRuntime(594): at android.widget.TextView.<init>(TextView.java:445)
02-06 10:31:53.608: ERROR/AndroidRuntime(594): at android.widget.Button.<init>(Button.java:108)
02-06 10:31:53.608: ERROR/AndroidRuntime(594): at android.widget.Button.<init>(Button.java:104)
02-06 10:31:53.608: ERROR/AndroidRuntime(594): ... 35 more
02-06 10:31:53.608: ERROR/AndroidRuntime(594): Caused by: android.content.res.Resources$NotFoundException: File res/drawable/remote_tv_number_selected.xml from drawable resource ID #0x7f020180
02-06 10:31:53.608: ERROR/AndroidRuntime(594): at android.content.res.Resources.loadDrawable(Resources.java:1925)
02-06 10:31:53.608: ERROR/AndroidRuntime(594): at android.content.res.Resources.getDrawable(Resources.java:664)
02-06 10:31:53.608: ERROR/AndroidRuntime(594): at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:173)
02-06 10:31:53.608: ERROR/AndroidRuntime(594): at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:867)
02-06 10:31:53.608: ERROR/AndroidRuntime(594): at android.graphics.drawable.Drawable.createFromXml(Drawable.java:804)
02-06 10:31:53.608: ERROR/AndroidRuntime(594): at android.content.res.Resources.loadDrawable(Resources.java:1922)
02-06 10:31:53.608: ERROR/AndroidRuntime(594): ... 40 more
02-06 10:31:53.608: ERROR/AndroidRuntime(594): Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file
Это исключение брошено на setContentView(R.layout.xml_file)
линия на onCreate
метод, и после того, как есть туалет в журнале исключений, я обнаружил, что строка 600 в XML, вероятно, является причиной этого, и это часть кода, который содержит строку 600 в XML, которая, кажется, вызывает эту ошибку:
<LinearLayout
android:id="@+id/zone_control"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:gravity="center"
android:orientation="vertical"
android:padding="5dp"
android:weightSum="7" >
<Button //this is the line 600
android:id="@+id/one"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="7dp"
android:layout_weight="1"
android:background="@drawable/num_buttons"
android:clickable="false"
android:paddingRight="10dp"
android:paddingLeft="10dp"
android:text="1"
android:textColor="@android:color/white" />
<!.. another three Buttons with the same statistics !..>
</LinearLayout>
А это то num_buttons
рисовать:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_selected="true"
android:drawable="@drawable/remote_tv_number_unselected" />
<item
android:drawable="@drawable/remote_tv_number_selected" />
</selector>
а это remote_tv_number_selected
:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="1dp"/>
<gradient
android:startColor="#121212"
android:centerColor="#212121"
android:endColor="#353535"
android:angle="30"/>
</shape>
только несколько перевернутых цветов и другой угол даст вам remote_tv_number_unselected
1 ответ
Ошибка была в android:angle
из remote_tv_number_selected
файл, как я установил угол на 30
но похоже, что он не принимает никаких углов, кроме строгих (0, 90, 180, 270), поэтому я изменил это так:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="1dp"/>
<gradient
android:startColor="#121212"
android:centerColor="#212121"
android:endColor="#353535"
android:angle="180"/>
</shape>