I am getting the following random Exception when running this Activity. I found another thread here on SO suggesting that all of my styles inherit from parent="android:Theme" but that did not help. I have run HierarchyViewer and layoutopt tools but have not found any problems with the layout file. And I have cleaned the project.
The exception is happening on the line:
ReceiptActivity.java:54 setContentView(R.layout.receipt_activity);
Here is the layout file, receipt_activity.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@drawable/background">
<LinearLayout android:layout_width="fill_parent"
android:paddingLeft="10dip"
android:paddingRight="10dip"
android:layout_height="wrap_content" android:orientation="vertical">
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="3dip"
android:layout_marginRight="3dip"
android:layout_marginTop="10dip"
android:textSize="19sp"
android:text="@string/receipt_question"
android:gravity="center"/>
<EditText
android:id="@+id/txtEmailOrSms"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dip"
android:layout_marginLeft="3dip"
android:layout_marginRight="3dip"
android:textSize="15sp"
android:maxLines="1"
android:layout_gravity="left"
android:focusable="true"
android:focusableInTouchMode="true"
android:inputType="textEmailAddress"
android:hint="@string/enter_email"
android:imeOptions="actionDone"
/>
<RadioGroup
android:id="@+id/receiptTypeRadioGroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<RadioButton
android:id="@+id/emailReceipt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=开发者_运维知识库"Email Receipt"
android:textSize="15sp"
android:checked="true"
android:width="150dip"
android:layout_marginRight="5dip"
android:textColor="#FFF"
>
</RadioButton>
<RadioButton
android:id="@+id/smsReceipt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Text Receipt"
android:textSize="15sp"
android:width="150dip"
android:layout_marginRight="5dip"
android:textColor="#FFF"
>
</RadioButton>
</RadioGroup>
</LinearLayout>
<LinearLayout android:id="@+id/footer"
android:layout_width="fill_parent"
android:layout_height="60dip"
android:background="@drawable/button_bar_background"
android:orientation="horizontal"
android:gravity="bottom"
android:layout_alignParentBottom="true"
style="@android:style/ButtonBar">
<Button
android:id="@+id/noThanksBtn"
android:layout_height="fill_parent"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_marginLeft="1dip"
style="@style/DarkButton"
android:text="@string/no_thanks"/>
<Button
android:id="@+id/sendReceiptBtn"
android:layout_height="fill_parent"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_marginRight="1dip"
style="@style/DarkButton"
android:text="@string/send_receipt"/>
</LinearLayout>
</RelativeLayout>
Here is the Exception:
07-11 07:08:01.040: ERROR/AndroidRuntime(15635): FATAL EXCEPTION: main
07-11 07:08:01.040: ERROR/AndroidRuntime(15635): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.bestfitmobile.netsecure/com.bestfitmobile.netsecure.ui.ReceiptActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
07-11 07:08:01.040: ERROR/AndroidRuntime(15635): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
07-11 07:08:01.040: ERROR/AndroidRuntime(15635): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
07-11 07:08:01.040: ERROR/AndroidRuntime(15635): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
07-11 07:08:01.040: ERROR/AndroidRuntime(15635): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
07-11 07:08:01.040: ERROR/AndroidRuntime(15635): at android.os.Handler.dispatchMessage(Handler.java:99)
07-11 07:08:01.040: ERROR/AndroidRuntime(15635): at android.os.Looper.loop(Looper.java:130)
07-11 07:08:01.040: ERROR/AndroidRuntime(15635): at android.app.ActivityThread.main(ActivityThread.java:3683)
07-11 07:08:01.040: ERROR/AndroidRuntime(15635): at java.lang.reflect.Method.invokeNative(Native Method)
07-11 07:08:01.040: ERROR/AndroidRuntime(15635): at java.lang.reflect.Method.invoke(Method.java:507)
07-11 07:08:01.040: ERROR/AndroidRuntime(15635): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
07-11 07:08:01.040: ERROR/AndroidRuntime(15635): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
07-11 07:08:01.040: ERROR/AndroidRuntime(15635): at dalvik.system.NativeStart.main(Native Method)
07-11 07:08:01.040: ERROR/AndroidRuntime(15635): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
07-11 07:08:01.040: ERROR/AndroidRuntime(15635): at android.view.LayoutInflater.createView(LayoutInflater.java:518)
07-11 07:08:01.040: ERROR/AndroidRuntime(15635): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
07-11 07:08:01.040: ERROR/AndroidRuntime(15635): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
07-11 07:08:01.040: ERROR/AndroidRuntime(15635): at android.view.LayoutInflater.inflate(LayoutInflater.java:386)
07-11 07:08:01.040: ERROR/AndroidRuntime(15635): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
07-11 07:08:01.040: ERROR/AndroidRuntime(15635): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
07-11 07:08:01.040: ERROR/AndroidRuntime(15635): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
07-11 07:08:01.040: ERROR/AndroidRuntime(15635): at android.app.Activity.setContentView(Activity.java:1657)
07-11 07:08:01.040: ERROR/AndroidRuntime(15635): at com.bestfitmobile.netsecure.ui.ReceiptActivity.onCreate(ReceiptActivity.java:54)
07-11 07:08:01.040: ERROR/AndroidRuntime(15635): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
07-11 07:08:01.040: ERROR/AndroidRuntime(15635): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
07-11 07:08:01.040: ERROR/AndroidRuntime(15635): ... 11 more
07-11 07:08:01.040: ERROR/AndroidRuntime(15635): Caused by: java.lang.reflect.InvocationTargetException
07-11 07:08:01.040: ERROR/AndroidRuntime(15635): at java.lang.reflect.Constructor.constructNative(Native Method)
07-11 07:08:01.040: ERROR/AndroidRuntime(15635): at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
07-11 07:08:01.040: ERROR/AndroidRuntime(15635): at android.view.LayoutInflater.createView(LayoutInflater.java:505)
07-11 07:08:01.040: ERROR/AndroidRuntime(15635): ... 21 more
07-11 07:08:01.040: ERROR/AndroidRuntime(15635): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
07-11 07:08:01.040: ERROR/AndroidRuntime(15635): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
07-11 07:08:01.040: ERROR/AndroidRuntime(15635): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:460)
07-11 07:08:01.040: ERROR/AndroidRuntime(15635): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:336)
07-11 07:08:01.040: ERROR/AndroidRuntime(15635): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
07-11 07:08:01.040: ERROR/AndroidRuntime(15635): at android.content.res.Resources.loadDrawable(Resources.java:1709)
07-11 07:08:01.040: ERROR/AndroidRuntime(15635): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
07-11 07:08:01.040: ERROR/AndroidRuntime(15635): at android.view.View.<init>(View.java:1951)
07-11 07:08:01.040: ERROR/AndroidRuntime(15635): at android.view.View.<init>(View.java:1899)
07-11 07:08:01.040: ERROR/AndroidRuntime(15635): at android.view.ViewGroup.<init>(ViewGroup.java:286)
07-11 07:08:01.040: ERROR/AndroidRuntime(15635): at android.widget.RelativeLayout.<init>(RelativeLayout.java:173)
07-11 07:08:01.040: ERROR/AndroidRuntime(15635): ... 24 more
The answer is here:
07-11 07:08:01.040: ERROR/AndroidRuntime(15635): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
The drawable called background
is too large. If you remove that it should load fine. Not sure how big that can be, but evidently you used an image too large.
精彩评论