I am currently taking a free online course in Android and we are learning to make a simple output app. My app was working fine until today. I changed the images used in it and the background color of the TextViews, but that's about it. I don't know why the app will no longer run on my phone. (Note 3, Android 5.0 Stock ROM)
Here's my code:
<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"
tools:context=".MainActivity">
<ImageView
android:src="@drawable/tanwood"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:scaleType="centerCrop"
/>
<ImageView
android:src="@drawable/congrats"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:paddingTop="75dp"
android:paddingBottom="75dp"
android:scaleType="centerInside"
/>
<TextView android:text="Congratulations, Bro!!!"
android:textSize="26dp"
android:fontFamily="sans-serif-light"
android:textColor="@android:color/white"
android:background="#D50000"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:padding="10dp"
android:layout_marginTop="8dp"
/>
<TextView android:text="You are an official G! (graduate)"
android:textSize="25dp"
android:fontFamily="sans-serif-light"
android:textColor="@android:color/white"
android:background="#D50000"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:layout_marginBottom="8dp"
android:padding="5dp"
/>
</RelativeLayout>
Here is the logcat:
06-11 01:32:33.646 15489-15489/com.example.justi.happybirthday E/Zygote﹕ MountEmulatedStorage()
06-11 01:32:33.646 15489-15489/com.example.justi.happybirthday E/Zygote﹕ v2
06-11 01:32:33.646 15489-15489/com.example.justi.happybirthday I/libpersona﹕ KNOX_SDCARD checking this for 10254
06-11 01:32:33.646 15489-15489/com.example.justi.happybirthday I/libpersona﹕ KNOX_SDCARD not a persona
06-11 01:32:33.676 15489-15489/com.example.justi.happybirthday I/SELinux﹕ Function: selinux_compare_spd_ram , priority [2] , priority version is VE=SEPF_SM-N900T_5.0_0002
06-11 01:32:33.676 15489-15489/com.example.justi.happybirthday E/SELinux﹕ [DEBUG] get_category: variable seinfo: default sensitivity: NULL, cateogry: NULL
06-11 01:32:33.676 15489-15489/com.example.justi.happybirthday I/art﹕ Late-enabling -Xcheck:jni
06-11 01:32:33.756 15489-15489/com.example.justi.happybirthday D/ResourcesManager﹕ creating new AssetManager and set to /data/app/com.example.justi.happybirthday-2/base.apk
06-11 01:32:33.766 15489-15489/com.example.justi.happybirthday W/ActivityThread﹕ Application com.example.justi.happybirthday can be debugged on port 8100...
06-11 01:32:34.586 15489-15489/com.example.justi.happybirthday I/art﹕ Forcing collection of SoftReferences for 58MB allocation
06-11 01:32:34.596 15489-15489/com.example.justi.happybirthday E/art﹕ Throwing OutOfMemoryError "Failed to allocate a 61382172 byte allocation with 8388608 free bytes and 19MB until OOM"
06-11 01:32:34.596 15489-15489/com.example.justi.happybirthday D/skia﹕ --- allocation failed for scaled bitmap
06-11 01:32:34.596 15489-15489/com.example.justi.happybirthday D/AndroidRuntime﹕ Shutting down VM
06-11 01:32:34.596 15489-15489/com.example.justi.happybirthday E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.example.justi.happybirthday, PID: 15489
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.justi.happybirthday/com.example.justi.happybirthday.MainActivity}: android.view.InflateException: Binary XML file line #22: Error inflating class <unknown>
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2693)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2760)
at android.app.ActivityThread.access$900(ActivityThread.java:177)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1448)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5944)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1388)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1183)
Caused by: android.view.InflateException: Binary XML file line #22: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:640)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:689)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:748)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
at android.view.LayoutInflater.inflate(LayoutInflater.java:511)
at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
at android.view.LayoutInflater.inflate(LayoutInflater.java:366)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:249)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106)
at com.example.justi.happybirthday.MainActivity.onCreate(MainActivity.java:14)
at android.app.Activity.performCreate(Activity.java:6288)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2760)
at android.app.ActivityThread.access$900(ActivityThread.java:177)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1448)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5944)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1388)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1183)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:614)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:689)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:748)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
at android.view.LayoutInflater.inflate(LayoutInflater.java:511)
at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
at android.view.LayoutInflater.inflate(LayoutInflater.java:366)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:249)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106)
at com.example.justi.happybirthday.MainActivity.onCreate(MainActivity.java:14)
at android.app.Activity.performCreate(Activity.java:6288)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2760)
at android.app.ActivityThread.access$900(ActivityThread.java:177)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1448)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5944)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1388)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1183)
Caused by: java.lang.OutOfMemoryError: Failed to allocate a 61382172 byte allocation with 8388608 free bytes and 19MB until OOM
at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:726)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:547)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:1014)
at android.content.res.Resources.loadDrawableForCookie(Resources.java:3730)
at android.content.res.Resources.loadDrawable(Resources.java:3603)
at android.content.res.TypedArray.getDrawable(TypedArray.java:762)
at android.widget.ImageView.<init>(ImageView.java:151)
at android.widget.ImageView.<init>(ImageView.java:140)
at android.widget.ImageView.<init>(ImageView.java:136)
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:614)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:689)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:748)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
at android.view.LayoutInflater.inflate(LayoutInflater.java:511)
at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
at android.view.LayoutInflater.inflate(LayoutInflater.java:366)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:249)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106)
at com.example.justi.happybirthday.MainActivity.onCreate(MainActivity.java:14)
at android.app.Activity.performCreate(Activity.java:6288)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2760)
at android.app.ActivityThread.access$900(ActivityThread.java:177)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1448)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5944)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1388)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1183)
I truly appreciate any assistance. Thanks in advance!
It is an OutOfMemoryException as from logs -
Caused by: java.lang.OutOfMemoryError: Failed to allocate a 61382172 byte allocation with 8388608 free bytes and 19MB until OOM
I think you have used any/some large sized images (may be in MB) in your res folder.