1

我对这一切都很陌生,所以请多多包涵!我今天一直在尝试确定我的应用程序的风格,但无法完全理解。当我尝试在我的 AVD 上运行应用程序时,我不断收到这个错误膨胀类。我不知道这意味着什么,或者如何解决它。我可以说它在谈论我的 MainActivity,所以我也会发布相关信息。

   07-29 21:41:35.751: D/dalvikvm(431): GC_EXTERNAL_ALLOC freed 53K, 53% free 2546K/5379K, external 1625K/2137K, paused 104ms
07-29 21:41:35.811: E/dalvikvm-heap(431): 31740000-byte external allocation too large for this process.
07-29 21:41:35.911: E/GraphicsJNI(431): VM won't let us allocate 31740000 bytes
07-29 21:41:35.911: D/dalvikvm(431): GC_FOR_MALLOC freed <1K, 53% free 2546K/5379K, external 1625K/2137K, paused 91ms
07-29 21:41:35.911: D/skia(431): --- decoder->decode returned false
07-29 21:41:35.971: D/AndroidRuntime(431): Shutting down VM
07-29 21:41:35.971: W/dalvikvm(431): threadid=1: thread exiting with uncaught exception (group=0x40015560)
07-29 21:41:36.021: E/AndroidRuntime(431): FATAL EXCEPTION: main
07-29 21:41:36.021: E/AndroidRuntime(431): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.madonk.louisiana.festivals/com.madonk.louisiana.festivals.MainActivity}: android.view.InflateException: Binary XML file line #1: Error inflating class android.widget.RelativeLayout
07-29 21:41:36.021: E/AndroidRuntime(431):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
07-29 21:41:36.021: E/AndroidRuntime(431):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
07-29 21:41:36.021: E/AndroidRuntime(431):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
07-29 21:41:36.021: E/AndroidRuntime(431):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
07-29 21:41:36.021: E/AndroidRuntime(431):  at android.os.Handler.dispatchMessage(Handler.java:99)
07-29 21:41:36.021: E/AndroidRuntime(431):  at android.os.Looper.loop(Looper.java:123)
07-29 21:41:36.021: E/AndroidRuntime(431):  at android.app.ActivityThread.main(ActivityThread.java:3683)
07-29 21:41:36.021: E/AndroidRuntime(431):  at java.lang.reflect.Method.invokeNative(Native Method)
07-29 21:41:36.021: E/AndroidRuntime(431):  at java.lang.reflect.Method.invoke(Method.java:507)
07-29 21:41:36.021: E/AndroidRuntime(431):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
07-29 21:41:36.021: E/AndroidRuntime(431):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
07-29 21:41:36.021: E/AndroidRuntime(431):  at dalvik.system.NativeStart.main(Native Method)
07-29 21:41:36.021: E/AndroidRuntime(431): Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class android.widget.RelativeLayout
07-29 21:41:36.021: E/AndroidRuntime(431):  at android.view.LayoutInflater.createView(LayoutInflater.java:518)
07-29 21:41:36.021: E/AndroidRuntime(431):  at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
07-29 21:41:36.021: E/AndroidRuntime(431):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
07-29 21:41:36.021: E/AndroidRuntime(431):  at android.view.LayoutInflater.inflate(LayoutInflater.java:386)
07-29 21:41:36.021: E/AndroidRuntime(431):  at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
07-29 21:41:36.021: E/AndroidRuntime(431):  at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
07-29 21:41:36.021: E/AndroidRuntime(431):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
07-29 21:41:36.021: E/AndroidRuntime(431):  at android.app.Activity.setContentView(Activity.java:1657)
07-29 21:41:36.021: E/AndroidRuntime(431):  at com.madonk.louisiana.festivals.MainActivity.onCreate(MainActivity.java:16)
07-29 21:41:36.021: E/AndroidRuntime(431):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
07-29 21:41:36.021: E/AndroidRuntime(431):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
07-29 21:41:36.021: E/AndroidRuntime(431):  ... 11 more
07-29 21:41:36.021: E/AndroidRuntime(431): Caused by: java.lang.reflect.InvocationTargetException
07-29 21:41:36.021: E/AndroidRuntime(431):  at java.lang.reflect.Constructor.constructNative(Native Method)
07-29 21:41:36.021: E/AndroidRuntime(431):  at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
07-29 21:41:36.021: E/AndroidRuntime(431):  at android.view.LayoutInflater.createView(LayoutInflater.java:505)
07-29 21:41:36.021: E/AndroidRuntime(431):  ... 21 more
07-29 21:41:36.021: E/AndroidRuntime(431): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
07-29 21:41:36.021: E/AndroidRuntime(431):  at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
07-29 21:41:36.021: E/AndroidRuntime(431):  at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:460)
07-29 21:41:36.021: E/AndroidRuntime(431):  at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:336)
07-29 21:41:36.021: E/AndroidRuntime(431):  at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
07-29 21:41:36.021: E/AndroidRuntime(431):  at android.content.res.Resources.loadDrawable(Resources.java:1709)
07-29 21:41:36.021: E/AndroidRuntime(431):  at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
07-29 21:41:36.021: E/AndroidRuntime(431):  at android.view.View.<init>(View.java:1951)
07-29 21:41:36.021: E/AndroidRuntime(431):  at android.view.View.<init>(View.java:1899)
07-29 21:41:36.021: E/AndroidRuntime(431):  at android.view.ViewGroup.<init>(ViewGroup.java:286)
07-29 21:41:36.021: E/AndroidRuntime(431):  at android.widget.RelativeLayout.<init>(RelativeLayout.java:173)
07-29 21:41:36.021: E/AndroidRuntime(431):  ... 24 more
07-29 21:42:43.762: I/Process(431): Sending signal. PID: 431 SIG: 9

Main_Activity.xml

    <RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/background" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="39dp"
        android:text="@string/Definitive"
        android:textColor="@style/AppTheme"
        android:textSize="20dp"
        android:textStyle="bold"
        tools:context=".MainActivity" />

    <Button
        android:id="@+id/button_southwest"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="136dp"
        android:onClick="showOther"
        android:text="@string/Southwest" />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/textView1"
        android:layout_centerHorizontal="true"
        android:text="@string/Select_a_region"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textColor="@style/AppTheme"
        android:textSize="20dp" />

</RelativeLayout>
4

2 回答 2

6

看起来您的背景可绘制对象太大,请尝试在没有背景的情况下运行相对布局的应用程序。考虑使用颜色而不是可绘制的背景作为背景。

于 2012-07-29T22:07:26.170 回答
0

在 Android 中命名资源时不能使用大写字母。在这里你有@string/Definitive@string/Select_a_region。重命名这些,你应该没问题。希望这可以帮助。

于 2012-07-29T22:03:37.823 回答