Forum Xamarin.Forms


The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

"Java.Lang.IllegalStateException: Activity has been destroyed" when using AdMob

I have done some tests of how to use AdMob in Xamarin.Forms and I got stuck on this.

  • A MasterDetailPage containing an empty master and a detail that is a new NavigationPage(myAdPage)
  • Start the application
  • Click on the (test)-ad and it will open a window
  • Click on the hardware back button twice and you get Java.Lang.IllegalStateException: Activity has been destroyed

A simple solution is attached.

Any clues of what to change to avoid this crash?

Best Answers


  • Digged further into this. It does not seem to have anything to do with AdMob. I replace AdMob with a button that pushed another page to the navigation stack. This gives the same result.
    Java.Lang.IllegalStateException: Activity has been destroyed

  • DoganCoruhDoganCoruh USMember ✭✭

    I am getting the same exception but i am not using admob. There is no clue about this exception clearly. Another guy says that this is a lifecycle issue OnCreate fixes instead of OnResume but not worked for me :(

  • This is a problem in of Xamarin.Forms. works great.

  • JohnHardmanJohnHardman GBUniversity admin

    @ChristerOlsson @DoganCoruh - this sounds like for which @AdrianKnight has provided a fix that the bug report suggests is included in 2.3.4-pre1

  • Yes, it does. Thanks!

  • BinuraDodangodaBinuraDodangoda USMember
    edited December 2016

    @ChristerOlsson said:
    This is a problem in of Xamarin.Forms. works great.

    I had a problem in closing the app. That means when I press the back button to close the app, the app gets crashed. After I downgrading Xamarin.Forms to the version, the problem was solved !

  • LuccasClezarLuccasClezar USMember
    edited January 2017

    I'm having the same problem of @BinuraDodangoda. When I close with the back button, Android displays a message saying that the application stopped working. From what I know this is a problem related to having a NavigationPage as the Detail of a MasterDetailPage. I think that the NavigationPage tries to handle the navigation but the system is closing the app, resulting in Android saying that the activity has been destroyed.

  • I'm having the same problem too when i reopen the application (like when press on notification).
    i have mater detail page and navigation page as detail .
    i try to install xamarin.forms v2.3.3.180 (released on 5-1-2017) but not worked too.

  • Tried 2.3.4-pre1 but the problem looks like its still there.

  • jurmb84jurmb84 USMember

    Apparently there is a fix in the works and part of 2.3.4

    So the question I would like answered is, Could this get added to the 2.3.3 line and released... or could someone point me to good documentation on how to custom build xamarin from github so I can put it in a working build myself?

    Thanx in advance...

  • CrosevenCroseven USMember ✭✭

    xamarin.forms v2.3.3.180 have the same problem. when will 2.3.4 come

  • DoganCoruhDoganCoruh USMember ✭✭

    For God sake, please fix that problem guys...

  • Lewis_tLewis_t GBUniversity ✭✭

    I don't see how you can have a stable version out there with this kind of bug in it. It should be a critical fix for 2.3.3 in my opinion. We had to hold back to 2.3.2 for our last version for this and a couple of other issues. hopefully 2.3.4 will be stable enough by the time we're ready to release again.

  • ChristerOlssonChristerOlsson USMember
    edited February 2017

    Tried with but still not working. Followed codercampos advice above (clean, delete obj/bin, rebuild) and it worked.

  • Sanjay_RajputSanjay_Rajput USMember ✭✭

    Thanks @JoeManke, its working .

Sign In or Register to comment.