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:
- Create a New Project in Visual Studio 2015. Cross-Platform->Cross Platform App (Xamarin)
- Create a new blank Xamarin Forms app. (Native app will also have the same problem)
- 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).
- After the app is launch, immediately the app will close and exit from debug mode.
- The problem is not showing any hint in the output or device log.
- 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.
- Go to Android project properties->Android Options, uncheck “Use Shared RunTime”
- 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.
- Advanced Android Options dialog will be show and you will notice that the Supported architectures is updated.
- Change back the Supported architectures to select all in Debug mode.
- The app should now able to deploy and run in pre-lollipop device.