Xamarin deploying not working with Android

2019-06-18 04:55发布

I've set up a new Xamarin.Forms Project. I want to build and deploy it to an emulator or an Android device, but it is not working. In the Outputwindow of Visual Studio, the following error is displayed:

The application could not be started. Ensure that the application has been installed to the target device and has a launchable activity (MainLauncher = true).

Update:

If I look in the build logs i can find following:

2>Mono.AndroidTools.InstallFailedException: Unexpected install output: Error: Could not access the Package Manager. Is the system running?

2> bei Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess(String output, String packageName)

2> bei Mono.AndroidTools.AndroidDevice.c__AnonStoreyD.<>m__0(Task`1 t)

2> bei System.Threading.Tasks.ContinuationTaskFromResultTask`1.InnerInvoke()

2> bei System.Threading.Tasks.Task.Execute()

2>Deployment failed because of an internal error: Unexpected install output: Error: Could not access the Package Manager. Is the system running?

5条回答
来,给爷笑一个
2楼-- · 2019-06-18 05:09

This can be caused by a few things. When ever I get this, I switch the Output window drop-down to Build. Usually that shows an INCOMPATIBLE error of some kind. That usually means the app install on the device/emulator got corrupted/messed up in some way. The app probably will not even show up on the app dashboard area but if you go into Settings -> App (or App Manager) -> then look for the app's App ID (NOT the app's name). When you find it, uninstall it and try again.

Another common cause of the error for me is that the correct architecture is not selected in the Android project properties. This usually is the case when trying to run on the Xamarin Android Player. To fix that, right-click the Xamarin Android project -> Properties -> Android Options -> Advanced -> select x86

查看更多
该账号已被封号
3楼-- · 2019-06-18 05:15

You need to first set the Android project as the Startup Project. Right click the Android Project and select Set as StartUp project.

Ensure that you have checked the Build and Deploy checkboxes. You can right click the Solution and select Configuration Manager.


Also, please ensure that the Emulator is already running.

You need to wait for the emulator to full start - takes about a few minutes. Once it is fully started (UI on the emulator will change), it should work.

You will need to restart the app after the emulator is running and choose the running emulator (when prompted).

查看更多
Luminary・发光体
4楼-- · 2019-06-18 05:17

This means you are deploying to a device/emulator with an app that doesn't contain the appropriate architecture.

So let's make sure you have the following, first go to your android project options and make sure you have these checked:

enter image description here

Then you might also need to click Advanced on this screen and check the appropriate architectures:

enter image description here

查看更多
叛逆
5楼-- · 2019-06-18 05:23

In my case application icon needs to be set on Android Manifest.

enter image description here

查看更多
【Aperson】
6楼-- · 2019-06-18 05:27

I keep getting this error too with an Android emulator running Android 4.4.2 (though I am not using Xamarin.Forms) and it only happens with that emulator. I resolve it as follows:

1) In the command console (cmd.exe) type the following commands to restart ADB:

adb kill-server
adb start-server

2) In your project choose the Build menu and choose Clean Solution.

3) Try deploying the app again.

You might have to repeat the above twice sometimes (if it doesn't work its a good idea to shut down the emulator and then restart ADB then try deploy again).

查看更多
登录 后发表回答