这是我的问题,我的应用程序启动完美,调用它们时活动工作正常,但是当我回到主要活动并开始另一个活动时,我的应用程序崩溃了。
这是 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>
安卓清单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.whaoapps.maths"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.SET_WALLPAPER"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application
android:allowBackup="true"
android:icon="@drawable/maths_icono"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|s mallestScreenSize" />
<activity
android:name="com.whaoapps.maths.MainActivity"
android:screenOrientation="portrait"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.whaoapps.maths.Derivadas"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Light.NoTitleBar"></activity>
<activity
android:name="com.whaoapps.maths.Integrales"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Light.NoTitleBar"></activity>
</application>
</manifest>