Forum Xamarin Xamarin.Android

ImageView is crashing my app

zzinzzin CAMember ✭✭

ndroidRuntime] Caused by: java.lang.reflect.InvocationTargetException
[AndroidRuntime] at java.lang.reflect.Constructor.constructNative(Native Method)
[AndroidRuntime] at java.lang.reflect.Constructor.newInstance(
[AndroidRuntime] at android.view.LayoutInflater.createView(
[AndroidRuntime] ... 25 more
[AndroidRuntime] Caused by: java.lang.OutOfMemoryError
[AndroidRuntime] at Method)
[AndroidRuntime] at
[AndroidRuntime] at
[AndroidRuntime] at
[AndroidRuntime] at android.content.res.Resources.loadDrawable(
[AndroidRuntime] at android.content.res.TypedArray.getDrawable(
[AndroidRuntime] at android.widget.ImageView.(
[AndroidRuntime] at android.widget.ImageView.(
[AndroidRuntime] ... 28 more


  • zzinzzin CAMember ✭✭

    need help.

  • StevaSteva RSMember ✭✭✭

    For some strange reason when activity was destroyed drawable set from resources wasn't cleared from memory and was giving me same troubles. This was just a wild guess from my side but setting image drawable to null prior to activity being destroyed fixed the memory issues for me.

    public override void OnDestroy()
  • zzinzzin CAMember ✭✭

    i have a question @Steva , do i need to use Ondestroy, Onresume, OnStart() etc because currently all i use is OnCreate()

  • StevaSteva RSMember ✭✭✭

    Well in this case you need OnDestroy but generaly you only use what you need. If in your case you only need OnCreate then just use that one.

  • zzinzzin CAMember ✭✭

    also, the ondestroy() did not help sadly

Sign In or Register to comment.