0

这是我的问题,我的应用程序启动完美,调用它们时活动工作正常,但是当我回到主要活动并开始另一个活动时,我的应用程序崩溃了。

这是 logcat 中显示的错误:

06-29 23:48:46.885: E/AndroidRuntime(860): FATAL EXCEPTION: main
06-29 23:48:46.885: E/AndroidRuntime(860): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.whaoapps.maths/com.whaoapps.maths.Integrales}: android.view.InflateException: Binary XML file line #16: Error inflating class <unknown>
06-29 23:48:46.885: E/AndroidRuntime(860):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
06-29 23:48:46.885: E/AndroidRuntime(860):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
06-29 23:48:46.885: E/AndroidRuntime(860):  at android.app.ActivityThread.access$600(ActivityThread.java:141)
06-29 23:48:46.885: E/AndroidRuntime(860):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
06-29 23:48:46.885: E/AndroidRuntime(860):  at android.os.Handler.dispatchMessage(Handler.java:99)
06-29 23:48:46.885: E/AndroidRuntime(860):  at android.os.Looper.loop(Looper.java:137)
06-29 23:48:46.885: E/AndroidRuntime(860):  at android.app.ActivityThread.main(ActivityThread.java:5041)
06-29 23:48:46.885: E/AndroidRuntime(860):  at java.lang.reflect.Method.invokeNative(Native Method)
06-29 23:48:46.885: E/AndroidRuntime(860):  at java.lang.reflect.Method.invoke(Method.java:511)
06-29 23:48:46.885: E/AndroidRuntime(860):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
06-29 23:48:46.885: E/AndroidRuntime(860):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
06-29 23:48:46.885: E/AndroidRuntime(860):  at dalvik.system.NativeStart.main(Native Method)
06-29 23:48:46.885: E/AndroidRuntime(860): Caused by: android.view.InflateException: Binary XML file line #16: Error inflating class <unknown>
06-29 23:48:46.885: E/AndroidRuntime(860):  at android.view.LayoutInflater.createView(LayoutInflater.java:613)
06-29 23:48:46.885: E/AndroidRuntime(860):  at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
06-29 23:48:46.885: E/AndroidRuntime(860):  at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
06-29 23:48:46.885: E/AndroidRuntime(860):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
06-29 23:48:46.885: E/AndroidRuntime(860):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
06-29 23:48:46.885: E/AndroidRuntime(860):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
06-29 23:48:46.885: E/AndroidRuntime(860):  at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
06-29 23:48:46.885: E/AndroidRuntime(860):  at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
06-29 23:48:46.885: E/AndroidRuntime(860):  at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
06-29 23:48:46.885: E/AndroidRuntime(860):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
06-29 23:48:46.885: E/AndroidRuntime(860):  at android.app.Activity.setContentView(Activity.java:1881)
06-29 23:48:46.885: E/AndroidRuntime(860):  at com.whaoapps.maths.Integrales.onCreate(Integrales.java:14)
06-29 23:48:46.885: E/AndroidRuntime(860):  at android.app.Activity.performCreate(Activity.java:5104)
06-29 23:48:46.885: E/AndroidRuntime(860):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
06-29 23:48:46.885: E/AndroidRuntime(860):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
06-29 23:48:46.885: E/AndroidRuntime(860):  ... 11 more
06-29 23:48:46.885: E/AndroidRuntime(860): Caused by: java.lang.reflect.InvocationTargetException
06-29 23:48:46.885: E/AndroidRuntime(860):  at java.lang.reflect.Constructor.constructNative(Native Method)
06-29 23:48:46.885: E/AndroidRuntime(860):  at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
06-29 23:48:46.885: E/AndroidRuntime(860):  at android.view.LayoutInflater.createView(LayoutInflater.java:587)
06-29 23:48:46.885: E/AndroidRuntime(860):  ... 25 more
06-29 23:48:46.885: E/AndroidRuntime(860): Caused by: java.lang.OutOfMemoryError
06-29 23:48:46.885: E/AndroidRuntime(860):  at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
06-29 23:48:46.885: E/AndroidRuntime(860):  at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:502)
06-29 23:48:46.885: E/AndroidRuntime(860):  at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:355)
06-29 23:48:46.885: E/AndroidRuntime(860):  at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:785)
06-29 23:48:46.885: E/AndroidRuntime(860):  at android.content.res.Resources.loadDrawable(Resources.java:1965)
06-29 23:48:46.885: E/AndroidRuntime(860):  at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
06-29 23:48:46.885: E/AndroidRuntime(860):  at android.view.View.<init>(View.java:3330)
06-29 23:48:46.885: E/AndroidRuntime(860):  at android.view.View.<init>(View.java:3259)
06-29 23:48:46.885: E/AndroidRuntime(860):  at android.view.ViewGroup.<init>(ViewGroup.java:425)
06-29 23:48:46.885: E/AndroidRuntime(860):  at android.widget.RelativeLayout.<init>(RelativeLayout.java:210)
06-29 23:48:46.885: E/AndroidRuntime(860):  ... 28 more

这是xml文件:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:src="@drawable/maths"
    android:background="@android:color/white" />

<Button
    android:id="@+id/button2"
    android:layout_width="205dp"
    android:layout_height="50dp"
    android:layout_alignLeft="@+id/button1"
    android:layout_centerVertical="true"
    android:background="@android:color/transparent"
    android:onClick="derivadas" />

<Button
    android:id="@+id/button1"
    android:layout_width="205dp"
    android:layout_height="50dp"
    android:layout_above="@+id/button2"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="58dp"
    android:background="@android:color/transparent"
    android:onClick="integrales" />

<com.google.ads.AdView android:id="@+id/ad"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="my_unit_id"
ads:adSize="BANNER"
ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID"
ads:loadAdOnCreate="true"/>

</RelativeLayout>
4

3 回答 3

0

在第一个按钮中,替换:

android:layout_alignLeft="@+id/button1"

android:layout_alignLeft="@id/button1"

,并在第二个按钮中替换

android:layout_above="@+id/button2"

android:layout_above="@id/button2".

+用于声明一个新项目,这就是你的应用程序崩溃的原因。

于 2013-06-30T02:37:20.243 回答
0

你能从你的xml中删除它 android:src="@drawable/maths"吗,因为你的内存不足,更好地@+id用作参考,并尝试在代码中设置监听器。如果问题仍然存在,最好删除可能导致问题的 adView 作为调试,稍后您可以添加视图。

于 2013-06-30T06:07:59.610 回答
0
android.view.InflateException: Binary XML file line #16: Error inflating class <unknown>

在发布问题之前观看 logcat

于 2013-06-30T00:17:55.053 回答