我刚刚在 Play 商店名称 Indian Logo Quiz上启动了我的第一个 Android 应用程序
我收到了某些崩溃报告。其中一个是这个:
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.indian.logoquiz/com.indian.logoquiz.Play}:
android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2247)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2297)
at android.app.ActivityThread.access$700(ActivityThread.java:152)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1282)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5328)
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:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
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:619)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java: 56)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:666)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:691)
at android.view.LayoutInflater.inflate(LayoutInflater.java:467)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:327)
at android.app.Activity.setContentView(Activity.java:1928)
at com.indian.logoquiz.Play.onCreate(Play.java:39)
at android.app.Activity.performCreate(Activity.java:5250)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
... 11 more
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:593)
... 23 more
Caused by: java.lang.OutOfMemoryError
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:596)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:444)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:817)
at android.content.res.Resources.loadDrawable(Resources.java:2854)
at android.content.res.TypedArray.getDrawable(TypedArray.java:602)
at android.view.View.<init>(View.java:3460)
at android.view.ViewGroup.<init>(ViewGroup.java:446)
at android.widget.LinearLayout.<init>(LinearLayout.java:176)
at android.widget.LinearLayout.<init>(LinearLayout.java:172)
... 26 more
我的play.xml如下:
<?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/playpage">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.33"
android:layout_marginTop="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp">
<Button
android:id="@+id/lvl1"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="0.33"
android:alpha="0.85"
android:text=""
/>
<Button
android:id="@+id/lvl2"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="0.33"
android:alpha="0.85"
android:text=""
/>
<Button
android:id="@+id/lvl3"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="0.34"
android:alpha="0.85"
android:text="" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.33"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp" >
<Button
android:id="@+id/lvl4"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="0.33"
android:alpha="0.85"
android:text="" />
<Button
android:id="@+id/lvl5"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="0.33"
android:alpha="0.85"
android:text="" />
<Button
android:id="@+id/lvl6"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="0.34"
android:alpha="0.85"
android:text="" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.33"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginBottom="5dp">
<Button
android:id="@+id/lvl7"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="0.33"
android:alpha="0.85"
android:text="" />
<Button
android:id="@+id/lvl8"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="0.33"
android:alpha="0.85"
android:text="" />
<Button
android:id="@+id/lvl9"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="0.34"
android:alpha="0.85"
android:text="" />
</LinearLayout>
</LinearLayout>
该应用程序在按下 1 级按钮时崩溃.... 可能是因为嵌套重量在任何情况下?请帮忙 !....