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"

、そして2番目のボタンで置き換えます

android:layout_above="@+id/button2"

android:layout_above="@id/button2".

+新しいアイテムを宣言するために使用されるため、アプリがクラッシュします。

于 2013-06-30T02:37:20.243 に答える
0
android.view.InflateException: Binary XML file line #16: Error inflating class <unknown>

質問を投稿する前に logcat を確認する

于 2013-06-30T00:17:55.053 に答える