Xamarin Android - application could not be started
The steps I took to successfully deploy to an Android device after receiving "The application could not be started" error.
Having re-built my machine I could no longer deploy to an Android device. The project would build successfully and then I would receive the following error.
The application could not be started. Ensure that the application has been installed to the target device and has a launchable activity (MainLauncher = true).
I had uninstalled the existing app on the device but I was still unable to deploy without getting this error. In my search for a fix I noticed that people often got this error when they were deploying from a different machine. Given I had reinstalled my OS, I could probably consider this to be a different machine.
Nuke it
Having no luck resolving the issue, I decided to try an uninstall command using adb
(Android Debug Bridge) and it worked!
Here's how to do it from Visual Studio.
Make sure your Android device has USB debugging enabled and is connected to your machine via USB.
From the top menu in Visual Studio select Tools -> Android -> Android Adb Command Prompt... This will open a command prompt.
- In the command prompt type
adb uninstall my.package.id
replacingmy.package.id
with the package id for the project. If you are unsure of this go to the properties of your Android project and under Android Manifest there is a package name. This is your package id.
After following these steps I was once again able to deploy to my Android device.