A strange error when trying to start Activity
.
i think the error in my Animation Drawable
LogCat:
12-31 06:37:45.138: E/AndroidRuntime(922): FATAL EXCEPTION: main 12-31 06:37:45.138: E/AndroidRuntime(922): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.MalekAlrwily.BasicVaccinations/com.MalekAlrwily.BasicVaccinations.Main}: android.view.InflateException: Binary XML file line #1: Error inflating class android.widget.RelativeLayout 12-31 06:37:45.138: E/AndroidRuntime(922): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211) 12-31 06:37:45.138: E/AndroidRuntime(922): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261) 12-31 06:37:45.138: E/AndroidRuntime(922): at android.app.ActivityThread.access$600(ActivityThread.java:141) 12-31 06:37:45.138: E/AndroidRuntime(922): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256) 12-31 06:37:45.138: E/AndroidRuntime(922): at android.os.Handler.dispatchMessage(Handler.java:99) 12-31 06:37:45.138: E/AndroidRuntime(922): at android.os.Looper.loop(Looper.java:137) 12-31 06:37:45.138: E/AndroidRuntime(922): at android.app.ActivityThread.main(ActivityThread.java:5103) 12-31 06:37:45.138: E/AndroidRuntime(922): at java.lang.reflect.Method.invokeNative(Native Method) 12-31 06:37:45.138: E/AndroidRuntime(922): at java.lang.reflect.Method.invoke(Method.java:525) 12-31 06:37:45.138: E/AndroidRuntime(922): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737) 12-31 06:37:45.138: E/AndroidRuntime(922): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 12-31 06:37:45.138: E/AndroidRuntime(922): at dalvik.system.NativeStart.main(Native Method) 12-31 06:37:45.138: E/AndroidRuntime(922): Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class android.widget.RelativeLayout 12-31 06:37:45.138: E/AndroidRuntime(922): at android.view.LayoutInflater.createView(LayoutInflater.java:620) 12-31 06:37:45.138: E/AndroidRuntime(922): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) 12-31 06:37:45.138: E/AndroidRuntime(922): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669) 12-31 06:37:45.138: E/AndroidRuntime(922): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694) 12-31 06:37:45.138: E/AndroidRuntime(922): at android.view.LayoutInflater.inflate(LayoutInflater.java:469) 12-31 06:37:45.138: E/AndroidRuntime(922): at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 12-31 06:37:45.138: E/AndroidRuntime(922): at android.view.LayoutInflater.inflate(LayoutInflater.java:353) 12-31 06:37:45.138: E/AndroidRuntime(922): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:267) 12-31 06:37:45.138: E/AndroidRuntime(922): at android.app.Activity.setContentView(Activity.java:1895) 12-31 06:37:45.138: E/AndroidRuntime(922): at com.MalekAlrwily.BasicVaccinations.Main.onCreate(Main.java:15) 12-31 06:37:45.138: E/AndroidRuntime(922): at android.app.Activity.performCreate(Activity.java:5133) 12-31 06:37:45.138: E/AndroidRuntime(922): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 12-31 06:37:45.138: E/AndroidRuntime(922): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175) 12-31 06:37:45.138: E/AndroidRuntime(922): ... 11 more 12-31 06:37:45.138: E/AndroidRuntime(922): Caused by: java.lang.reflect.InvocationTargetException 12-31 06:37:45.138: E/AndroidRuntime(922): at java.lang.reflect.Constructor.constructNative(Native Method) 12-31 06:37:45.138: E/AndroidRuntime(922): at java.lang.reflect.Constructor.newInstance(Constructor.java:417) 12-31 06:37:45.138: E/AndroidRuntime(922): at android.view.LayoutInflater.createView(LayoutInflater.java:594) 12-31 06:37:45.138: E/AndroidRuntime(922): ... 23 more 12-31 06:37:45.138: E/AndroidRuntime(922): Caused by: java.lang.OutOfMemoryError 12-31 06:37:45.138: E/AndroidRuntime(922): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method) 12-31 06:37:45.138: E/AndroidRuntime(922): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:503) 12-31 06:37:45.138: E/AndroidRuntime(922): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:356) 12-31 06:37:45.138: E/AndroidRuntime(922): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:800) 12-31 06:37:45.138: E/AndroidRuntime(922): at android.content.res.Resources.loadDrawable(Resources.java:2105) 12-31 06:37:45.138: E/AndroidRuntime(922): at android.content.res.Resources.getDrawable(Resources.java:695) 12-31 06:37:45.138: E/AndroidRuntime(922): at android.graphics.drawable.AnimationDrawable.inflate(AnimationDrawable.java:282) 12-31 06:37:45.138: E/AndroidRuntime(922): at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:901) 12-31 06:37:45.138: E/AndroidRuntime(922): at android.graphics.drawable.Drawable.createFromXml(Drawable.java:837) 12-31 06:37:45.138: E/AndroidRuntime(922): at android.content.res.Resources.loadDrawable(Resources.java:2087) 12-31 06:37:45.138: E/AndroidRuntime(922): at android.content.res.TypedArray.getDrawable(TypedArray.java:601) 12-31 06:37:45.138: E/AndroidRuntime(922): at android.view.View.<init>(View.java:3364) 12-31 06:37:45.138: E/AndroidRuntime(922): at android.view.View.<init>(View.java:3293) 12-31 06:37:45.138: E/AndroidRuntime(922): at android.view.ViewGroup.<init>(ViewGroup.java:453) 12-31 06:37:45.138: E/AndroidRuntime(922): at android.widget.RelativeLayout.<init>(RelativeLayout.java:242) 12-31 06:37:45.138: E/AndroidRuntime(922): ... 26 more
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="match_parent" android:layout_above="@+id/button1" android:layout_centerHorizontal="true" android:background="@drawable/animation" android:gravity="center_horizontal" android:orientation="vertical" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".Main" > <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:background="@android:color/transparent" android:onClick="onClick" android:src="@drawable/next" /> </RelativeLayout>
AnimationDrawable
:
<?xml version="1.0" encoding="utf-8"?> <animation-list xmlns:android="http://schemas.android.com/apk/res/android" > <item android:drawable="@drawable/begin1" android:duration="3000" /> <item android:drawable="@drawable/begin2" android:duration="3000" /> <item android:drawable="@drawable/begin3" android:duration="3000" /> <item android:drawable="@drawable/begin4" android:duration="3000" /> <item android:drawable="@drawable/begin5" android:duration="3000" /> <item android:drawable="@drawable/begin6" android:duration="3000" /> <item android:drawable="@drawable/begin7" android:duration="3000" /> <item android:drawable="@drawable/begin8" android:duration="3000" /> <item android:drawable="@drawable/begin9" android:duration="3000" /> </animation-list>
Looks like whatever is in your Animation Drawable definition is too much memory to decode and sequence. The idea is that it loads up all the items and make them in an array and swaps them in and out of the scene according to the timing specified for each frame.
If this all can't fit into memory, it's probably better to either do this on your own with some sort of handler or better yet just encode a movie with the specified frames at the corresponding images and play the animation through a video codec.
Source: Stackoverflow.com