Run Xamarin Android App In Pre-Lollipop Device

Recently when I try to deploy app in pre-lollipop devices (KitKat, Jelly Bean, …), I encounter a problem that the app will stop immediately after it is launch.

To simulate the problem, here is the steps:

  1. Create a New Project in Visual Studio 2015. Cross-Platform->Cross Platform App (Xamarin)
    2017-09-26 22_30_50-New Project.png
  2. Create a new blank Xamarin Forms app. (Native app will also have the same problem)
    2017-09-26 22_31_33-New Cross Platform App - App29.png
  3. Build solution and deploy the app to pre-lollipop device. In my case, I’m deploying to 4.1.2 emulator (Jelly Bean API 16).
    2017-09-26 22_32_39-App29 - Microsoft Visual Studio.png
  4. After the app is launch, immediately the app will close and exit from debug mode.
  5. The problem is not showing any hint in the output or device log.
    2017-09-26 22_38_10-App29.png
  6. Without writing any code, we already not able to deploy the app to pre-lollipop device.

Solution

The reason of the problem is due to the app is using Mono Shared RunTime. To solve the issue, we will need to turn off this feature in Visual Studio.

  1. Go to Android project properties->Android Options, uncheck “Use Shared RunTime”
    2017-09-27 00_06_40-App29 (Running) - Microsoft Visual Studio.png
  2. There is another bug in Xamarin that after we turn on/off “Use Shared RunTime”, Supported Architecture settings will be updated. To change back the settings, click Advanced button in the same screen.
    2017-09-27 00_06_54-App29 (Running) - Microsoft Visual Studio.png
  3. Advanced Android Options dialog will be show and you will notice that the Supported architectures is updated.
    2017-09-27 00_05_11-Advanced Android Options.png
  4. Change back the Supported architectures to select all in Debug mode.
    2017-09-27 00_06_05-App29 (Running) - Microsoft Visual Studio.png
  5. The app should now able to deploy and run in pre-lollipop device.
    2017-09-27 07_27_29-Android Emulator - Nexus4_412_5554.png

Leave a comment