Forum Visual Studio

Deploy / Launch from VS to Android Emulator or Device Fails

patterrrpatterrr Member ✭✭

Please forgive me, I'm a total noob as of this week with Xamarin. I've started off by reading Microsoft's Xamarin Get Started tutorial, and I followed creating this application step-by-step: "Create a Single Page Xamarin.Forms Application" where it walks the reader through creating a simple "Notes" application (sorry since I'm new here I can't post a link).

I am using Visual Studio 2019 Community Edition on Windows 10 professional. I have tried on two different computer, and have the same issue with both.

It compiles fine, but deploying to a device doesn't seem to work. I've tried two cases and wind up with the same result.
1) I used Android Device Manager to create a Pixel 2 Pie 9.0 x86 emulator, and the emulator successfully starts and boots up.
2) I enabled developer mode on my Galaxy S8 and connected it to the PC via USB.
In both of the cases above, the expected device shows up in the drop down next to the Start Debugging arrow. I choose the device, and press Start Debugging. After the application successfully compiles the output window says that Deployment was successful. However, the application never starts on the emulated device or the physical device. After a handful of seconds the Start Debugging arrow changes back to green and the IDE is no longer in debug mode. However, I get no error messages of any sort, and the output window just says Start debugging Android application ...

Is there something that I need to do to tell the device to launch the deployed application?

Here's the output from VS when I attempt to run:
1>------ Build started: Project: Notes.Android, Configuration: Debug Any CPU ------
1> Notes.Android -> C:\Users\ryan1\Documents\Visual Studio 2019\Learning\Notes\Notes.Android\bin\Debug\Notes.Android.dll
1> No way to resolve conflict between "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" and "mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e". Choosing "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" arbitrarily.
2>Starting deployment to pixel_2_pie_9_0_-api_28 ...
2>Deploying to pixel_2_pie_9_0
-_api_28 ...
Build started.
Project "Notes.Android.csproj" (Install target(s)):
Found Java SDK version 1.8.0.
Found Java SDK version 1.8.0.
Dex Fast Deployment Enabled: False
MonoAndroid Tools: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\
Android Platform API level: 28
TargetFrameworkVersion: v9.0
Android NDK:
Android SDK: C:\Program Files (x86)\Android\android-sdk\
Android SDK Build Tools: C:\Program Files (x86)\Android\android-sdk\build-tools\28.0.3\
Java SDK: C:\Program Files\Android\Jdk\microsoft_dist_openjdk_1.8.0.25\
Application Java class: android.app.Application
Project "Notes.csproj" (GetTargetFrameworks target(s)):
Done building project "Notes.csproj".
Project "Notes.csproj" (GetTargetPath target(s)):
Done building project "Notes.csproj".
Skipping target "_VerifyXamarinAndroidSupportVersions" because all output files are up-to-date with respect to the input files.
PackageName: com.companyname.notes
Skipping target "_ResolveLibraryProjectImports" because all output files are up-to-date with respect to the input files.
Skipping target "_BuildLibraryImportsCache" because all output files are up-to-date with respect to the input files.
Skipping target "_GenerateAndroidResourceDir" because all output files are up-to-date with respect to the input files.
Skipping target "_GenerateLayoutBindings" because it has no outputs.
Skipping target "_ConvertLibraryResourcesCases" because all output files are up-to-date with respect to the input files.
Skipping target "_CompileAndroidLibraryResources" because all output files are up-to-date with respect to the input files.
Skipping target "_ConvertResourcesCases" because all output files are up-to-date with respect to the input files.
Skipping target "_CompileResources" because all output files are up-to-date with respect to the input files.
Skipping target "_PrepareUpdateAndroidResgen" because all output files are up-to-date with respect to the input files.
Checking Android SDK Build-tools version...
Selected Android SDK Build Tools Path: C:\Program Files (x86)\Android\android-sdk\build-tools\28.0.3\
Selected Android SDK Build Tools Version: 28.0.3
Android SDK Build Tools Version: 28.0.3 meets minimum requirements for Vector Drawables. OK.
Finished Checking Android SDK Build-tools version.
Skipping target "_UpdateAndroidResgen" because all output files are up-to-date with respect to the input files.
Adding assembly reference for Notes.Android, recursively...
Adding assembly reference for FormsViewGroup, recursively...
Adding assembly reference for Java.Interop, recursively...
Adding assembly reference for Mono.Android, recursively...
Adding assembly reference for System.Net.Http, recursively...
Adding assembly reference for System.Drawing.Common, recursively...
Adding assembly reference for System.Runtime.Serialization, recursively...
Adding assembly reference for System.ServiceModel.Internals, recursively...
Adding assembly reference for mscorlib, recursively...
Adding assembly reference for Notes, recursively...
Adding assembly reference for netstandard, recursively...
Adding assembly reference for System.Data, recursively...
Adding assembly reference for System.Transactions, recursively...
Adding assembly reference for System.Data.DataSetExtensions, recursively...
Adding assembly reference for System.IO.Compression, recursively...
Adding assembly reference for System.IO.Compression.FileSystem, recursively...
Adding assembly reference for System.ComponentModel.Composition, recursively...
Adding assembly reference for System.Web.Services, recursively...
Adding assembly reference for System.Core, recursively...
Adding assembly reference for System, recursively...
Adding assembly reference for Mono.Security, recursively...
Adding assembly reference for System.Numerics, recursively...
Adding assembly reference for System.Numerics.Vectors, recursively...
Adding assembly reference for System.Runtime, recursively...
Adding assembly reference for System.Xml, recursively...
Adding assembly reference for System.Xml.Linq, recursively...
Adding assembly reference for Xamarin.Android.Arch.Core.Common, recursively...
Adding assembly reference for Xamarin.Android.Arch.Core.Runtime, recursively...
Adding assembly reference for Xamarin.Android.Arch.Lifecycle.Common, recursively...
Adding assembly reference for Xamarin.Android.Arch.Lifecycle.LiveData.Core, recursively...
Adding assembly reference for Xamarin.Android.Arch.Lifecycle.LiveData, recursively...
Adding assembly reference for Xamarin.Android.Arch.Lifecycle.Runtime, recursively...
Adding assembly reference for Xamarin.Android.Arch.Lifecycle.ViewModel, recursively...
Adding assembly reference for Xamarin.Android.Support.Animated.Vector.Drawable, recursively...
Adding assembly reference for Xamarin.Android.Support.Annotations, recursively...
Adding assembly reference for Xamarin.Android.Support.AsyncLayoutInflater, recursively...
Adding assembly reference for Xamarin.Android.Support.Collections, recursively...
Adding assembly reference for Xamarin.Android.Support.Compat, recursively...
Adding assembly reference for Xamarin.Android.Support.CoordinaterLayout, recursively...
Adding assembly reference for Xamarin.Android.Support.Core.UI, recursively...
Adding assembly reference for Xamarin.Android.Support.Core.Utils, recursively...
Adding assembly reference for Xamarin.Android.Support.CursorAdapter, recursively...
Adding assembly reference for Xamarin.Android.Support.CustomTabs, recursively...
Adding assembly reference for Xamarin.Android.Support.CustomView, recursively...
Adding assembly reference for Xamarin.Android.Support.Design, recursively...
Adding assembly reference for Xamarin.Android.Support.DocumentFile, recursively...
Adding assembly reference for Xamarin.Android.Support.DrawerLayout, recursively...
Adding assembly reference for Xamarin.Android.Support.Fragment, recursively...
Adding assembly reference for Xamarin.Android.Support.Interpolator, recursively...
Adding assembly reference for Xamarin.Android.Support.Loader, recursively...
Adding assembly reference for Xamarin.Android.Support.LocalBroadcastManager, recursively...
Adding assembly reference for Xamarin.Android.Support.Media.Compat, recursively...
Adding assembly reference for Xamarin.Android.Support.Print, recursively...
Adding assembly reference for Xamarin.Android.Support.SlidingPaneLayout, recursively...
Adding assembly reference for Xamarin.Android.Support.SwipeRefreshLayout, recursively...
Adding assembly reference for Xamarin.Android.Support.Transition, recursively...
Adding assembly reference for Xamarin.Android.Support.v4, recursively...
Adding assembly reference for Xamarin.Android.Support.v7.AppCompat, recursively...
Adding assembly reference for Xamarin.Android.Support.v7.CardView, recursively...
Adding assembly reference for Xamarin.Android.Support.v7.RecyclerView, recursively...
Adding assembly reference for Xamarin.Android.Support.Vector.Drawable, recursively...
Adding assembly reference for Xamarin.Android.Support.VersionedParcelable, recursively...
Adding assembly reference for Xamarin.Android.Support.ViewPager, recursively...
Adding assembly reference for Xamarin.Essentials, recursively...
Adding assembly reference for Xamarin.Forms.Core, recursively...
Adding assembly reference for Xamarin.Forms.Platform.Android, recursively...
Adding assembly reference for Xamarin.Forms.Platform, recursively...
Adding assembly reference for Xamarin.Forms.Xaml, recursively...
No way to resolve conflict between "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" and "mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e". Choosing "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" arbitrarily.
Skipping target "_CopyConfigFiles" because it has no inputs.
Skipping target "_ConvertPdbFiles" because it has no outputs.
Skipping target "_LinkAssembliesNoShrink" because all output files are up-to-date with respect to the input files.
Skipping target "_CopyConfigFiles" because it has no inputs.
Skipping target "_ConvertPdbFiles" because it has no outputs.
Skipping target "_GenerateJavaStubs" because all output files are up-to-date with respect to the input files.
Skipping target "_ConvertCustomView" because all output files are up-to-date with respect to the input files.
Skipping target "_AddStaticResources" because all output files are up-to-date with respect to the input files.
Skipping target "_GeneratePackageManagerJava" because all output files are up-to-date with respect to the input files.
Skipping target "_GenerateAndroidAssetsDir" because it has no outputs.
Skipping target "_PrepareCreateBaseApk" because all output files are up-to-date with respect to the input files.
Skipping target "_CreateBaseApk" because all output files are up-to-date with respect to the input files.
Skipping target "_CompileJava" because all output files are up-to-date with respect to the input files.
Skipping target "_CompileNativeAssemblySources" because all output files are up-to-date with respect to the input files.
Skipping target "_CreateApplicationSharedLibraries" because all output files are up-to-date with respect to the input files.
Skipping target "_CompileToDalvikWithD8" because all output files are up-to-date with respect to the input files.
Deleting file "bin\Debug\com.companyname.notes.apk".
Copying file from "C:\Users\ryan1\Documents\Visual Studio 2019\Learning\Notes\Notes.Android\obj\Debug\90\android\bin\com.companyname.notes.apk" to "C:\Users\ryan1\Documents\Visual Studio 2019\Learning\Notes\Notes.Android\bin\Debug\com.companyname.notes.apk".
Touching "obj\Debug\90\android_debug_keystore.flag".
C:\Program Files\Android\Jdk\microsoft_dist_openjdk_1.8.0.25\bin\keytool.exe -list -alias androiddebugkey -storepass android -keypass android -keystore "C:\Users\ryan1\AppData\Local\Xamarin\Mono for Android\debug.keystore"
Deleting file "C:\Users\ryan1\Documents\Visual Studio 2019\Learning\Notes\Notes.Android\bin\Debug\com.companyname.notes-Signed.apk".
C:\Program Files (x86)\Android\android-sdk\build-tools\28.0.3\zipalign.exe -p 4 "C:\Users\ryan1\Documents\Visual Studio 2019\Learning\Notes\Notes.Android\obj\Debug\90\android\bin\com.companyname.notes.apk" "bin\Debug\com.companyname.notes-Signed.apk"
C:\Program Files\Android\Jdk\microsoft_dist_openjdk_1.8.0.25\bin\java.exe -jar "C:\Program Files (x86)\Android\android-sdk\build-tools\28.0.3\lib\apksigner.jar" sign --ks "C:\Users\ryan1\AppData\Local\Xamarin\Mono for Android\debug.keystore" --ks-pass pass:android --ks-key-alias androiddebugkey --key-pass pass:android --min-sdk-version 21 --max-sdk-version 28 "C:\Users\ryan1\Documents\Visual Studio 2019\Learning\Notes\Notes.Android\bin\Debug\com.companyname.notes-Signed.apk"
Signed android package 'bin\Debug\com.companyname.notes-Signed.apk'
Deleting file "obj\Debug\90\upload.flag".
Removing previous version of application...
Copying application to device...
20% ... 1728kb of 8599kb copied
30% ... 2624kb of 8599kb copied
40% ... 3456kb of 8599kb copied
60% ... 5184kb of 8599kb copied
70% ... 6080kb of 8599kb copied
80% ... 6912kb of 8599kb copied
90% ... 7744kb of 8599kb copied
100% ... 8599kb of 8599kb copied
Getting installation path...
Using cached value for installation path: /storage/emulated/0/Android/data/com.companyname.notes/files/.override
Using cached value for package remote path: /data/app/com.companyname.notes-4-_nVbTm81xn0i6PrOl_nw==/base.apk

Using fast dev path: /storage/emulated/0/Android/data/com.companyname.notes/files/.__override__
Synchronizing assemblies...
0% ... 64kb of 12394kb copied
10% ... 1302kb of 12394kb copied
20% ... 2518kb of 12394kb copied
30% ... 3719kb of 12394kb copied
40% ... 4997kb of 12394kb copied
50% ... 6226kb of 12394kb copied
60% ... 7468kb of 12394kb copied
70% ... 8684kb of 12394kb copied
80% ... 9935kb of 12394kb copied
90% ... 11210kb of 12394kb copied
100% ... 12394kb of 12394kb copied
Skipping native libs, not configured...
Skipping dexes, not configured...
Skipping resources, not configured...
Skipping typemaps, not configured...
Creating "obj\Debug\90\upload.flag" because "AlwaysCreate" was specified.
Done building project "Notes.Android.csproj".
Build succeeded.
2>Deployment was successful to pixel_2_pie_9_0_-_api_28.
========== Build: 1 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========
========== Deploy: 1 succeeded, 0 failed, 0 skipped ==========

Answers

  • JarvanJarvan Member, Xamarin Team Xamurai
    edited April 9

    Try the following tips:
    1.Android platform project -> Properties -> Android Options -> Andvanced: Supported adrchitectures make all the options checked.
    2.Please check if the sdk path is correct: Tools->Options->Xamarin->Android Settings->Android SDK Location
    3.Make sure the MainLauncher of MainActivity class is set to value.

    [Activity(Label = "@string/app_name", Theme = "@style/AppTheme", MainLauncher = true)]
    public class MainActivity : AppCompatActivity
    {
        ...
    }
    

    Related tutorials:
    https://docs.microsoft.com/en-us/xamarin/android/get-started/installation/android-sdk?tabs=windows
    https://docs.microsoft.com/en-us/xamarin/android/get-started/installation/android-emulator/

  • patterrrpatterrr Member ✭✭

    Thank you for the response. I tried your suggestions, but unfortunately the options were already checked, path is correct, and MainLauncher was set to true.

    I did originally read and followed all the steps for setting up the emulator in the Android -> Get Started tutorial pages. However after reading your post I went through them again but can't find that I missed anything.

    I was thinking that maybe I screwed something up when creating the Notes application, so instead I downloaded the source of the Phoneword application under Part 1: Quickstart. It compiled with no errors or warnings, but still can't deploy it. When I try to deploy to my phone I get the same thing as the Notes application where it says Start debugging android application ... but then nothing ever launches on my phone and Visual Studio exits debug mode. However, when I try to run it to the Nexus 5x Android 9.0 x86 emulator, I get an error. Here's the exact output:

    1>------ Build started: Project: Phoneword, Configuration: Debug Any CPU ------
    1>  Phoneword -> D:\Documents\Visual Studio 2019\Learning\PhoneWord\Phoneword\bin\Debug\Phoneword.dll
    2>Starting deployment to nexus_5x_pie_9_0_api_28 ...
    2>Starting emulator nexus_5x_pie_9_0_api_28 ...
    2>C:\Program Files (x86)\Android\android-sdk\emulator\emulator.EXE -no-boot-anim -avd nexus_5x_pie_9_0_api_28 -prop monodroid.avdname=nexus_5x_pie_9_0_api_28
    2>Windows Hypervisor Platform accelerator is operational
    2>WARNING: change of renderer detected.
    2>Your emulator is out of date, please update by launching Android Studio:
    2> - Start Android Studio
    2> - Select menu "Tools > Android > SDK Manager"
    2> - Click "SDK Tools" tab
    2> - Check "Android Emulator" checkbox
    2> - Click "OK"
    2>Emulator nexus_5x_pie_9_0_api_28 is running.
    2>Deploying to nexus_5x_pie_9_0_api_28 ...
    Build started.
    Project "Phoneword.csproj" (Install target(s)):
    Found Java SDK version 1.8.0.
    Found Java SDK version 1.8.0.
    Dex Fast Deployment Enabled: False
    MonoAndroid Tools: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\
    Android Platform API level: 28
    TargetFrameworkVersion: v9.0
    Android NDK: C:\ProgramData\Microsoft\AndroidNDK\android-ndk-r10e\
    Android SDK: C:\Program Files (x86)\Android\android-sdk\
    Android SDK Build Tools: C:\Program Files (x86)\Android\android-sdk\build-tools\28.0.3\
    Java SDK: C:\Program Files\Android\Jdk\microsoft_dist_openjdk_1.8.0.25\
    Application Java class: android.app.Application
      PackageName: Phoneword.Phoneword
    Skipping target "_ResolveLibraryProjectImports" because all output files are up-to-date with respect to the input files.
    Skipping target "_BuildLibraryImportsCache" because all output files are up-to-date with respect to the input files.
    Skipping target "_BuildAdditionalResourcesCache" because all output files are up-to-date with respect to the input files.
    Skipping target "_CreateAdditionalResourceCache" because it has no outputs.
    Skipping target "_GenerateAndroidResourceDir" because all output files are up-to-date with respect to the input files.
    Skipping target "_GenerateLayoutBindings" because it has no outputs.
    Skipping target "_ConvertLibraryResourcesCases" because it has no inputs.
    Skipping target "_CompileAndroidLibraryResources" because it has no outputs.
    Skipping target "_ConvertResourcesCases" because all output files are up-to-date with respect to the input files.
    Skipping target "_CompileResources" because all output files are up-to-date with respect to the input files.
    Skipping target "_UpdateAndroidResgen" because all output files are up-to-date with respect to the input files.
      Adding assembly reference for Phoneword, recursively...
      Adding assembly reference for Java.Interop, recursively...
      Adding assembly reference for Mono.Android, recursively...
        Adding assembly reference for System.Net.Http, recursively...
        Adding assembly reference for System.Drawing.Common, recursively...
        Adding assembly reference for System.Runtime.Serialization, recursively...
          Adding assembly reference for System.ServiceModel.Internals, recursively...
      Adding assembly reference for mscorlib, recursively...
      Adding assembly reference for System.Core, recursively...
      Adding assembly reference for System, recursively...
        Adding assembly reference for Mono.Security, recursively...
        Adding assembly reference for System.Numerics, recursively...
      Adding assembly reference for System.Runtime, recursively...
        Adding assembly reference for System.ComponentModel.Composition, recursively...
      Adding assembly reference for System.Xml, recursively...
    Skipping target "_CopyConfigFiles" because it has no inputs.
    Skipping target "_CopyIntermediateAssemblies" because all output files are up-to-date with respect to the input files.
    Skipping target "_ConvertPdbFiles" because all output files are up-to-date with respect to the input files.
    Skipping target "_CopyPdbFiles" because all output files are up-to-date with respect to the input files.
    Skipping target "_CopyMdbFiles" because all output files are up-to-date with respect to the input files.
    Skipping target "_LinkAssembliesNoShrink" because all output files are up-to-date with respect to the input files.
    Skipping target "_GenerateJavaStubs" because all output files are up-to-date with respect to the input files.
    Skipping target "_ConvertCustomView" because all output files are up-to-date with respect to the input files.
    Skipping target "_AddStaticResources" because all output files are up-to-date with respect to the input files.
    Skipping target "_GeneratePackageManagerJava" because all output files are up-to-date with respect to the input files.
    Skipping target "_CreateAdditionalResourceCache" because it has no outputs.
    Skipping target "_GenerateAndroidAssetsDir" because it has no outputs.
    Skipping target "_CreateBaseApk" because all output files are up-to-date with respect to the input files.
    Skipping target "_CreateAdditionalResourceCache" because it has no outputs.
    Skipping target "_CompileJava" because all output files are up-to-date with respect to the input files.
    Skipping target "_CreateAdditionalResourceCache" because it has no outputs.
    Skipping target "_CompileToDalvikWithDx" because all output files are up-to-date with respect to the input files.
    Copying file from "D:\Documents\Visual Studio 2019\Learning\PhoneWord\Phoneword\obj\Debug\90\android\bin\Phoneword.Phoneword.apk" to "D:\Documents\Visual Studio 2019\Learning\PhoneWord\Phoneword\bin\Debug\Phoneword.Phoneword.apk".
    Creating "obj\Debug\90\android_debug_keystore.flag" because "AlwaysCreate" was specified.
    C:\Program Files\Android\Jdk\microsoft_dist_openjdk_1.8.0.25\bin\keytool.exe -list -alias androiddebugkey -storepass android -keypass android -keystore "C:\Users\Ryan Patterson\AppData\Local\Xamarin\Mono for Android\debug.keystore" 
    C:\Program Files (x86)\Android\android-sdk\build-tools\28.0.3\zipalign.exe -p 4 "D:\Documents\Visual Studio 2019\Learning\PhoneWord\Phoneword\obj\Debug\90\android\bin\Phoneword.Phoneword.apk" "bin\Debug\\Phoneword.Phoneword-Signed.apk" 
    C:\Program Files\Android\Jdk\microsoft_dist_openjdk_1.8.0.25\bin\java.exe -jar "C:\Program Files (x86)\Android\android-sdk\build-tools\28.0.3\lib\apksigner.jar" sign --ks "C:\Users\Ryan Patterson\AppData\Local\Xamarin\Mono for Android\debug.keystore" --ks-pass pass:android --ks-key-alias androiddebugkey --key-pass pass:android --min-sdk-version 21 --max-sdk-version 28  "D:\Documents\Visual Studio 2019\Learning\PhoneWord\Phoneword\bin\Debug\Phoneword.Phoneword-Signed.apk" 
    Signed android package 'bin\Debug\Phoneword.Phoneword-Signed.apk'
    Detecting installed packages...
    Removing old runtime: Mono.Android.DebugRuntime...
    Target device is x86.
    Installing the Mono shared runtime (debug - 1565368993)...
    10% ... 3200kb of 31991kb copied
    20% ... 6400kb of 31991kb copied
    30% ... 9600kb of 31991kb copied
    40% ... 12800kb of 31991kb copied
    50% ... 16000kb of 31991kb copied
    60% ... 19200kb of 31991kb copied
    70% ... 22400kb of 31991kb copied
    80% ... 25600kb of 31991kb copied
    90% ... 28800kb of 31991kb copied
    100% ... 31991kb of 31991kb copied
    ADB0000:  Deployment failed
    Mono.AndroidTools.InstallFailedException: Unexpected install output: 
    Exception occurred while executing:
    java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.List android.os.storage.StorageManager.getVolumes()' on a null object reference
        at com.android.internal.content.PackageHelper.resolveInstallVolume(PackageHelper.java:184)
        at com.android.internal.content.PackageHelper.resolveInstallVolume(PackageHelper.java:148)
        at com.android.internal.content.PackageHelper.resolveInstallVolume(PackageHelper.java:163)
        at com.android.server.pm.PackageInstallerService.createSessionInternal(PackageInstallerService.java:501)
        at com.android.server.pm.PackageInstallerService.createSession(PackageInstallerService.java:404)
        at com.android.server.pm.PackageManagerShellCommand.doCreateSession(PackageManagerShellCommand.java:2415)
        at com.android.server.pm.PackageManagerShellCommand.runInstall(PackageManagerShellCommand.java:907)
        at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:158)
        at android.os.ShellCommand.exec(ShellCommand.java:103)
        at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:21328)
        at android.os.Binder.shellCommand(Binder.java:634)
        at android.os.Binder.onTransact(Binder.java:532)
        at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:2821)
        at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:3856)
        at android.os.Binder.execTransact(Binder.java:731)
    
       at Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess(String output, String packageName) in E:\A\_work\275\s\External\androidtools\Mono.AndroidTools\Internal\AdbOutputParsing.cs:line 345
       at Mono.AndroidTools.AndroidDevice.<>c__DisplayClass95_0.<InstallPackage>b__0(Task`1 t) in E:\A\_work\275\s\External\androidtools\Mono.AndroidTools\AndroidDevice.cs:line 753
       at System.Threading.Tasks.ContinuationTaskFromResultTask`1.InnerInvoke()
       at System.Threading.Tasks.Task.Execute()
    ADB0010: Unexpected install output: 
    Exception occurred while executing:
    java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.List android.os.storage.StorageManager.getVolumes()' on a null object reference
        at com.android.internal.content.PackageHelper.resolveInstallVolume(PackageHelper.java:184)
        at com.android.internal.content.PackageHelper.resolveInstallVolume(PackageHelper.java:148)
        at com.android.internal.content.PackageHelper.resolveInstallVolume(PackageHelper.java:163)
        at com.android.server.pm.PackageInstallerService.createSessionInternal(PackageInstallerService.java:501)
        at com.android.server.pm.PackageInstallerService.createSession(PackageInstallerService.java:404)
        at com.android.server.pm.PackageManagerShellCommand.doCreateSession(PackageManagerShellCommand.java:2415)
        at com.android.server.pm.PackageManagerShellCommand.runInstall(PackageManagerShellCommand.java:907)
        at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:158)
        at android.os.ShellCommand.exec(ShellCommand.java:103)
        at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:21328)
        at android.os.Binder.shellCommand(Binder.java:634)
        at android.os.Binder.onTransact(Binder.java:532)
        at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:2821)
        at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:3856)
        at android.os.Binder.execTransact(Binder.java:731)
    
       at Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess(String output, String packageName) in E:\A\_work\275\s\External\androidtools\Mono.AndroidTools\Internal\AdbOutputParsing.cs:line 345
       at Mono.AndroidTools.AndroidDevice.<>c__DisplayClass95_0.<InstallPackage>b__0(Task`1 t) in E:\A\_work\275\s\External\androidtools\Mono.AndroidTools\AndroidDevice.cs:line 753
       at System.Threading.Tasks.ContinuationTaskFromResultTask`1.InnerInvoke()
       at System.Threading.Tasks.Task.Execute()
    Done building project "Phoneword.csproj" -- FAILED.
    Build FAILED.
    2>Deployment failed to nexus_5x_pie_9_0_api_28.
    ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
    ========== Deploy: 0 succeeded, 1 failed, 0 skipped ==========
    

    Any other ideas of what could be going on here?

  • patterrrpatterrr Member ✭✭

    Thank you for your reply, and sorry about the delay; I’ve tried replying several times but my reply doesn’t show up. Fingers crossed it will this time. I checked each of your tips, but unfortunately all the options were checked, the sdk path is correct, and MainLaunches is set to true.

    I did read and follow each page of the Xamarin.Android -> Get Started tutorial for setting up the emulator and the first getting started project, and just went through it all again but still didn't find anything that I did wrong.

    Wondering if I messed up something on the Notes project, so I downloaded the Hello, Android Phoneword sample and ran it as-is. It compiled fine, but when when I try to deploy to my physical phone the output window says "Start debugging Android application ...", but then the VS IDE exits debug mode immediately and nothing launches on the phone, nor is there any sort of error message.

    When I try to deploy to the emulator (nexus 5x Android 9.0 API 28 x86), this is the output, this time with an error:

    1>------ Build started: Project: Phoneword, Configuration: Debug Any CPU ------
    1>  Phoneword -> D:\Documents\Visual Studio 2019\Learning\PhoneWord\Phoneword\bin\Debug\Phoneword.dll
    2>Starting deployment to nexus_5x_pie_9_0_api_28 ...
    2>Starting emulator nexus_5x_pie_9_0_api_28 ...
    2>C:\Program Files (x86)\Android\android-sdk\emulator\emulator.EXE -no-boot-anim -avd nexus_5x_pie_9_0_api_28 -prop monodroid.avdname=nexus_5x_pie_9_0_api_28
    2>Windows Hypervisor Platform accelerator is operational
    2>emulator: emulator window was out of view and was recentered
    2>Emulator nexus_5x_pie_9_0_api_28 is running.
    2>Deploying to nexus_5x_pie_9_0_api_28 ...
    Build started.
    Project "Phoneword.csproj" (Install target(s)):
    Found Java SDK version 1.8.0.
    Found Java SDK version 1.8.0.
    Dex Fast Deployment Enabled: False
    MonoAndroid Tools: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\
    Android Platform API level: 28
    TargetFrameworkVersion: v9.0
    Android NDK: C:\ProgramData\Microsoft\AndroidNDK\android-ndk-r10e\
    Android SDK: C:\Program Files (x86)\Android\android-sdk\
    Android SDK Build Tools: C:\Program Files (x86)\Android\android-sdk\build-tools\28.0.3\
    Java SDK: C:\Program Files\Android\Jdk\microsoft_dist_openjdk_1.8.0.25\
    Application Java class: android.app.Application
      PackageName: Phoneword.Phoneword
    Skipping target "_ResolveLibraryProjectImports" because all output files are up-to-date with respect to the input files.
    Skipping target "_BuildLibraryImportsCache" because all output files are up-to-date with respect to the input files.
    Skipping target "_BuildAdditionalResourcesCache" because all output files are up-to-date with respect to the input files.
    Skipping target "_CreateAdditionalResourceCache" because it has no outputs.
    Skipping target "_GenerateAndroidResourceDir" because all output files are up-to-date with respect to the input files.
    Skipping target "_GenerateLayoutBindings" because it has no outputs.
    Skipping target "_ConvertLibraryResourcesCases" because it has no inputs.
    Skipping target "_CompileAndroidLibraryResources" because it has no outputs.
    Skipping target "_ConvertResourcesCases" because all output files are up-to-date with respect to the input files.
    Skipping target "_CompileResources" because all output files are up-to-date with respect to the input files.
    Skipping target "_UpdateAndroidResgen" because all output files are up-to-date with respect to the input files.
      Adding assembly reference for Phoneword, recursively...
      Adding assembly reference for Java.Interop, recursively...
      Adding assembly reference for Mono.Android, recursively...
        Adding assembly reference for System.Net.Http, recursively...
        Adding assembly reference for System.Drawing.Common, recursively...
        Adding assembly reference for System.Runtime.Serialization, recursively...
          Adding assembly reference for System.ServiceModel.Internals, recursively...
      Adding assembly reference for mscorlib, recursively...
      Adding assembly reference for System.Core, recursively...
      Adding assembly reference for System, recursively...
        Adding assembly reference for Mono.Security, recursively...
        Adding assembly reference for System.Numerics, recursively...
      Adding assembly reference for System.Runtime, recursively...
        Adding assembly reference for System.ComponentModel.Composition, recursively...
      Adding assembly reference for System.Xml, recursively...
    Skipping target "_CopyConfigFiles" because it has no inputs.
    Skipping target "_CopyIntermediateAssemblies" because all output files are up-to-date with respect to the input files.
    Skipping target "_ConvertPdbFiles" because all output files are up-to-date with respect to the input files.
    Skipping target "_CopyPdbFiles" because all output files are up-to-date with respect to the input files.
    Skipping target "_CopyMdbFiles" because all output files are up-to-date with respect to the input files.
    Skipping target "_LinkAssembliesNoShrink" because all output files are up-to-date with respect to the input files.
    Skipping target "_GenerateJavaStubs" because all output files are up-to-date with respect to the input files.
    Skipping target "_ConvertCustomView" because all output files are up-to-date with respect to the input files.
    Skipping target "_AddStaticResources" because all output files are up-to-date with respect to the input files.
    Skipping target "_GeneratePackageManagerJava" because all output files are up-to-date with respect to the input files.
    Skipping target "_CreateAdditionalResourceCache" because it has no outputs.
    Skipping target "_GenerateAndroidAssetsDir" because it has no outputs.
    Skipping target "_CreateBaseApk" because all output files are up-to-date with respect to the input files.
    Skipping target "_CreateAdditionalResourceCache" because it has no outputs.
    Skipping target "_CompileJava" because all output files are up-to-date with respect to the input files.
    Skipping target "_CreateAdditionalResourceCache" because it has no outputs.
    Skipping target "_CompileToDalvikWithDx" because all output files are up-to-date with respect to the input files.
    Skipping target "_CompileNativeAssemblySources" because all output files are up-to-date with respect to the input files.
    Skipping target "_CreateApplicationSharedLibraries" because all output files are up-to-date with respect to the input files.
    Skipping target "_BuildApkEmbed" because all output files are up-to-date with respect to the input files.
    Skipping target "_CopyPackage" because all output files are up-to-date with respect to the input files.
    Touching "obj\Debug\90\android_debug_keystore.flag".
    Skipping target "_Sign" because all output files are up-to-date with respect to the input files.
    Deleting file "obj\Debug\90\upload.flag".
    Detecting installed packages...
    Removing old runtime: Mono.Android.DebugRuntime...
    Target device is x86.
    Installing the Mono shared runtime (debug - 1565368993)...
    10% ... 3200kb of 31991kb copied
    20% ... 6400kb of 31991kb copied
    30% ... 9600kb of 31991kb copied
    40% ... 12800kb of 31991kb copied
    50% ... 16000kb of 31991kb copied
    60% ... 19200kb of 31991kb copied
    70% ... 22400kb of 31991kb copied
    80% ... 25600kb of 31991kb copied
    90% ... 28800kb of 31991kb copied
    100% ... 31991kb of 31991kb copied
    ADB0000:  Deployment failed
    Mono.AndroidTools.InstallFailedException: Unexpected install output: cmd: Can't find service: package
    
       at Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess(String output, String packageName) in E:\A\_work\275\s\External\androidtools\Mono.AndroidTools\Internal\AdbOutputParsing.cs:line 345
       at Mono.AndroidTools.AndroidDevice.<>c__DisplayClass95_0.<InstallPackage>b__0(Task`1 t) in E:\A\_work\275\s\External\androidtools\Mono.AndroidTools\AndroidDevice.cs:line 753
       at System.Threading.Tasks.ContinuationTaskFromResultTask`1.InnerInvoke()
       at System.Threading.Tasks.Task.Execute()
    ADB0010: Unexpected install output: cmd: Can't find service: package
    
       at Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess(String output, String packageName) in E:\A\_work\275\s\External\androidtools\Mono.AndroidTools\Internal\AdbOutputParsing.cs:line 345
       at Mono.AndroidTools.AndroidDevice.<>c__DisplayClass95_0.<InstallPackage>b__0(Task`1 t) in E:\A\_work\275\s\External\androidtools\Mono.AndroidTools\AndroidDevice.cs:line 753
       at System.Threading.Tasks.ContinuationTaskFromResultTask`1.InnerInvoke()
       at System.Threading.Tasks.Task.Execute()
    Done building project "Phoneword.csproj" -- FAILED.
    Build FAILED.
    2>Deployment failed to nexus_5x_pie_9_0_api_28.
    ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
    ========== Deploy: 0 succeeded, 1 failed, 0 skipped ==========
    

    Any further thoughts on what could be going on?

  • JarvanJarvan Member, Xamarin Team Xamurai
    edited April 16

    You can try to reset the emulator cache:

    Tools -> Android -> Device Manager -> select the emulator Factory Reset.

    Refer to: https://stackoverflow.com/a/57353168/11083277

  • patterrrpatterrr Member ✭✭

    Doing the Emulator Factory Reset didn't make a difference, the application still never launches. This also doesn't impact the fact that it never launches when using a physical Android device connected via USB.

    Just so I understand correctly, I should see the app launch on the device when I run in Visual Studio, right? Or do I need to do something on the device that I'm missing?

  • JarvanJarvan Member, Xamarin Team Xamurai
    edited April 16

    I used Android Device Manager to create a Pixel 2 Pie 9.0 x86 emulator

    Have you tested the project on an other emulator or other sdks? The same result? Try to download an official sample to test the issue, such as the link below.
    https://docs.microsoft.com/samples/xamarin/monodroid-samples/phoneword

  • patterrrpatterrr Member ✭✭

    I've tried two emulators as well as my physical phone and the app doesn't start when I press debug on any of them. The post above was using the Phone Word application as downloaded from Microsoft's website.

    What confuses me is I can do a fresh install of VS 2019 Community, run the Phone Word app as downloaded so everything is in default configuration but yet the app doesn't launch on the device. The emulator does start up and boot, but the app doesn't launch on it or my physical phone. This makes me wonder if I'm doing something wrong rather than a configuration issue. Do I need to do anything other than click "Start Debugging"?

  • patterrrpatterrr Member ✭✭

    By the way, I do notice that the app (in this case PhoneWord) does get deployed and installed in the device; it shows up under apps. I can launch it from the emulator. So the question is 1) Why isn't Visual Studio launching it? 2) I can launch it manually, so is there a way to attach the debugger?

  • patterrrpatterrr Member ✭✭

    Thank you for your reply. I checked each of your tips, but unfortunately all the options were checked, the sdk path is correct, and MainLaunches is set to true.

    I did read and follow each page of the Xamarin.Android -> Get Started tutorial for setting up the emulator and the first getting started project, and just went through it all again but still didn't find anything that I did wrong.

    Wondering if I messed up something on the Notes project, so I downloaded the Hello, Android Phoneword sample and ran it as-is. It compiled fine, but when when I try to deploy to my physical phone the output window says "Start debugging Android application ...", but then the VS IDE exits debug mode immediately and nothing launches on the phone, nor is there any sort of error message.

    When I try to deploy to the emulator (nexus 5x Android 9.0 API 28 x86), an error occurs upon deployment. Here's the full output.

    1>------ Build started: Project: Phoneword, Configuration: Debug Any CPU ------
    1>  Phoneword -> D:\Documents\Visual Studio 2019\Learning\PhoneWord\Phoneword\bin\Debug\Phoneword.dll
    2>Starting deployment to nexus_5x_pie_9_0_api_28 ...
    2>Starting emulator nexus_5x_pie_9_0_api_28 ...
    2>C:\Program Files (x86)\Android\android-sdk\emulator\emulator.EXE -no-boot-anim -avd nexus_5x_pie_9_0_api_28 -prop monodroid.avdname=nexus_5x_pie_9_0_api_28
    2>Windows Hypervisor Platform accelerator is operational
    2>WARNING: change of renderer detected.
    2>Your emulator is out of date, please update by launching Android Studio:
    2> - Start Android Studio
    2> - Select menu "Tools > Android > SDK Manager"
    2> - Click "SDK Tools" tab
    2> - Check "Android Emulator" checkbox
    2> - Click "OK"
    2>Emulator nexus_5x_pie_9_0_api_28 is running.
    2>Deploying to nexus_5x_pie_9_0_api_28 ...
    Build started.
    Project "Phoneword.csproj" (Install target(s)):
    Found Java SDK version 1.8.0.
    Found Java SDK version 1.8.0.
    Dex Fast Deployment Enabled: False
    MonoAndroid Tools: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\
    Android Platform API level: 28
    TargetFrameworkVersion: v9.0
    Android NDK: C:\ProgramData\Microsoft\AndroidNDK\android-ndk-r10e\
    Android SDK: C:\Program Files (x86)\Android\android-sdk\
    Android SDK Build Tools: C:\Program Files (x86)\Android\android-sdk\build-tools\28.0.3\
    Java SDK: C:\Program Files\Android\Jdk\microsoft_dist_openjdk_1.8.0.25\
    Application Java class: android.app.Application
      PackageName: Phoneword.Phoneword
    Skipping target "_ResolveLibraryProjectImports" because all output files are up-to-date with respect to the input files.
    Skipping target "_BuildLibraryImportsCache" because all output files are up-to-date with respect to the input files.
    Skipping target "_BuildAdditionalResourcesCache" because all output files are up-to-date with respect to the input files.
    Skipping target "_CreateAdditionalResourceCache" because it has no outputs.
    Skipping target "_GenerateAndroidResourceDir" because all output files are up-to-date with respect to the input files.
    Skipping target "_GenerateLayoutBindings" because it has no outputs.
    Skipping target "_ConvertLibraryResourcesCases" because it has no inputs.
    Skipping target "_CompileAndroidLibraryResources" because it has no outputs.
    Skipping target "_ConvertResourcesCases" because all output files are up-to-date with respect to the input files.
    Skipping target "_CompileResources" because all output files are up-to-date with respect to the input files.
    Skipping target "_UpdateAndroidResgen" because all output files are up-to-date with respect to the input files.
      Adding assembly reference for Phoneword, recursively...
      Adding assembly reference for Java.Interop, recursively...
      Adding assembly reference for Mono.Android, recursively...
        Adding assembly reference for System.Net.Http, recursively...
        Adding assembly reference for System.Drawing.Common, recursively...
        Adding assembly reference for System.Runtime.Serialization, recursively...
          Adding assembly reference for System.ServiceModel.Internals, recursively...
      Adding assembly reference for mscorlib, recursively...
      Adding assembly reference for System.Core, recursively...
      Adding assembly reference for System, recursively...
        Adding assembly reference for Mono.Security, recursively...
        Adding assembly reference for System.Numerics, recursively...
      Adding assembly reference for System.Runtime, recursively...
        Adding assembly reference for System.ComponentModel.Composition, recursively...
      Adding assembly reference for System.Xml, recursively...
    Skipping target "_CopyConfigFiles" because it has no inputs.
    Skipping target "_CopyIntermediateAssemblies" because all output files are up-to-date with respect to the input files.
    Skipping target "_ConvertPdbFiles" because all output files are up-to-date with respect to the input files.
    Skipping target "_CopyPdbFiles" because all output files are up-to-date with respect to the input files.
    Skipping target "_CopyMdbFiles" because all output files are up-to-date with respect to the input files.
    Skipping target "_LinkAssembliesNoShrink" because all output files are up-to-date with respect to the input files.
    Skipping target "_GenerateJavaStubs" because all output files are up-to-date with respect to the input files.
    Skipping target "_ConvertCustomView" because all output files are up-to-date with respect to the input files.
    Skipping target "_AddStaticResources" because all output files are up-to-date with respect to the input files.
    Skipping target "_GeneratePackageManagerJava" because all output files are up-to-date with respect to the input files.
    Skipping target "_CreateAdditionalResourceCache" because it has no outputs.
    Skipping target "_GenerateAndroidAssetsDir" because it has no outputs.
    Skipping target "_CreateBaseApk" because all output files are up-to-date with respect to the input files.
    Skipping target "_CreateAdditionalResourceCache" because it has no outputs.
    Skipping target "_CompileJava" because all output files are up-to-date with respect to the input files.
    Skipping target "_CreateAdditionalResourceCache" because it has no outputs.
    Skipping target "_CompileToDalvikWithDx" because all output files are up-to-date with respect to the input files.
    Copying file from "D:\Documents\Visual Studio 2019\Learning\PhoneWord\Phoneword\obj\Debug\90\android\bin\Phoneword.Phoneword.apk" to "D:\Documents\Visual Studio 2019\Learning\PhoneWord\Phoneword\bin\Debug\Phoneword.Phoneword.apk".
    Creating "obj\Debug\90\android_debug_keystore.flag" because "AlwaysCreate" was specified.
    C:\Program Files\Android\Jdk\microsoft_dist_openjdk_1.8.0.25\bin\keytool.exe -list -alias androiddebugkey -storepass android -keypass android -keystore "C:\Users\Ryan Patterson\AppData\Local\Xamarin\Mono for Android\debug.keystore" 
    C:\Program Files (x86)\Android\android-sdk\build-tools\28.0.3\zipalign.exe -p 4 "D:\Documents\Visual Studio 2019\Learning\PhoneWord\Phoneword\obj\Debug\90\android\bin\Phoneword.Phoneword.apk" "bin\Debug\\Phoneword.Phoneword-Signed.apk" 
    C:\Program Files\Android\Jdk\microsoft_dist_openjdk_1.8.0.25\bin\java.exe -jar "C:\Program Files (x86)\Android\android-sdk\build-tools\28.0.3\lib\apksigner.jar" sign --ks "C:\Users\Ryan Patterson\AppData\Local\Xamarin\Mono for Android\debug.keystore" --ks-pass pass:android --ks-key-alias androiddebugkey --key-pass pass:android --min-sdk-version 21 --max-sdk-version 28  "D:\Documents\Visual Studio 2019\Learning\PhoneWord\Phoneword\bin\Debug\Phoneword.Phoneword-Signed.apk" 
    Signed android package 'bin\Debug\Phoneword.Phoneword-Signed.apk'
    Detecting installed packages...
    Removing old runtime: Mono.Android.DebugRuntime...
    Target device is x86.
    Installing the Mono shared runtime (debug - 1565368993)...
    10% ... 3200kb of 31991kb copied
    20% ... 6400kb of 31991kb copied
    30% ... 9600kb of 31991kb copied
    40% ... 12800kb of 31991kb copied
    50% ... 16000kb of 31991kb copied
    60% ... 19200kb of 31991kb copied
    70% ... 22400kb of 31991kb copied
    80% ... 25600kb of 31991kb copied
    90% ... 28800kb of 31991kb copied
    100% ... 31991kb of 31991kb copied
    ADB0000:  Deployment failed
    Mono.AndroidTools.InstallFailedException: Unexpected install output: 
    Exception occurred while executing:
    java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.List android.os.storage.StorageManager.getVolumes()' on a null object reference
        at com.android.internal.content.PackageHelper.resolveInstallVolume(PackageHelper.java:184)
        at com.android.internal.content.PackageHelper.resolveInstallVolume(PackageHelper.java:148)
        at com.android.internal.content.PackageHelper.resolveInstallVolume(PackageHelper.java:163)
        at com.android.server.pm.PackageInstallerService.createSessionInternal(PackageInstallerService.java:501)
        at com.android.server.pm.PackageInstallerService.createSession(PackageInstallerService.java:404)
        at com.android.server.pm.PackageManagerShellCommand.doCreateSession(PackageManagerShellCommand.java:2415)
        at com.android.server.pm.PackageManagerShellCommand.runInstall(PackageManagerShellCommand.java:907)
        at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:158)
        at android.os.ShellCommand.exec(ShellCommand.java:103)
        at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:21328)
        at android.os.Binder.shellCommand(Binder.java:634)
        at android.os.Binder.onTransact(Binder.java:532)
        at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:2821)
        at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:3856)
        at android.os.Binder.execTransact(Binder.java:731)
    
       at Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess(String output, String packageName) in E:\A\_work\275\s\External\androidtools\Mono.AndroidTools\Internal\AdbOutputParsing.cs:line 345
       at Mono.AndroidTools.AndroidDevice.<>c__DisplayClass95_0.<InstallPackage>b__0(Task`1 t) in E:\A\_work\275\s\External\androidtools\Mono.AndroidTools\AndroidDevice.cs:line 753
       at System.Threading.Tasks.ContinuationTaskFromResultTask`1.InnerInvoke()
       at System.Threading.Tasks.Task.Execute()
    ADB0010: Unexpected install output: 
    Exception occurred while executing:
    java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.List android.os.storage.StorageManager.getVolumes()' on a null object reference
        at com.android.internal.content.PackageHelper.resolveInstallVolume(PackageHelper.java:184)
        at com.android.internal.content.PackageHelper.resolveInstallVolume(PackageHelper.java:148)
        at com.android.internal.content.PackageHelper.resolveInstallVolume(PackageHelper.java:163)
        at com.android.server.pm.PackageInstallerService.createSessionInternal(PackageInstallerService.java:501)
        at com.android.server.pm.PackageInstallerService.createSession(PackageInstallerService.java:404)
        at com.android.server.pm.PackageManagerShellCommand.doCreateSession(PackageManagerShellCommand.java:2415)
        at com.android.server.pm.PackageManagerShellCommand.runInstall(PackageManagerShellCommand.java:907)
        at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:158)
        at android.os.ShellCommand.exec(ShellCommand.java:103)
        at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:21328)
        at android.os.Binder.shellCommand(Binder.java:634)
        at android.os.Binder.onTransact(Binder.java:532)
        at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:2821)
        at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:3856)
        at android.os.Binder.execTransact(Binder.java:731)
    
       at Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess(String output, String packageName) in E:\A\_work\275\s\External\androidtools\Mono.AndroidTools\Internal\AdbOutputParsing.cs:line 345
       at Mono.AndroidTools.AndroidDevice.<>c__DisplayClass95_0.<InstallPackage>b__0(Task`1 t) in E:\A\_work\275\s\External\androidtools\Mono.AndroidTools\AndroidDevice.cs:line 753
       at System.Threading.Tasks.ContinuationTaskFromResultTask`1.InnerInvoke()
       at System.Threading.Tasks.Task.Execute()
    Done building project "Phoneword.csproj" -- FAILED.
    Build FAILED.
    2>Deployment failed to nexus_5x_pie_9_0_api_28.
    ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
    ========== Deploy: 0 succeeded, 1 failed, 0 skipped ==========
    

    Any other thoughts on what could be going on?

  • patterrrpatterrr Member ✭✭

    Thank you for your reply. I checked each of your tips, but unfortunately all the options were checked, the sdk path is correct, and MainLaunches is set to true.

    I did read and follow each page of the Xamarin.Android -> Get Started tutorial for setting up the emulator and the first getting started project, and just went through it all again but still didn't find anything that I did wrong.

    Wondering if I messed up something on the Notes project, so I downloaded the Hello, Android Phoneword sample and ran it as-is. It compiled fine, but when when I try to deploy to my physical phone the output window says "Start debugging Android application ...", but then the VS IDE exits debug mode immediately and nothing launches on the phone, nor is there any sort of error message.

    When I try to deploy to the emulator (nexus 5x Android 9.0 API 28 x86), an error occurs upon deployment. Here's the full output.

    1>------ Build started: Project: Phoneword, Configuration: Debug Any CPU ------
    1>  Phoneword -> D:\Documents\Visual Studio 2019\Learning\PhoneWord\Phoneword\bin\Debug\Phoneword.dll
    2>Starting deployment to nexus_5x_pie_9_0_api_28 ...
    2>Starting emulator nexus_5x_pie_9_0_api_28 ...
    2>C:\Program Files (x86)\Android\android-sdk\emulator\emulator.EXE -no-boot-anim -avd nexus_5x_pie_9_0_api_28 -prop monodroid.avdname=nexus_5x_pie_9_0_api_28
    2>Windows Hypervisor Platform accelerator is operational
    2>WARNING: change of renderer detected.
    2>Your emulator is out of date, please update by launching Android Studio:
    2> - Start Android Studio
    2> - Select menu "Tools > Android > SDK Manager"
    2> - Click "SDK Tools" tab
    2> - Check "Android Emulator" checkbox
    2> - Click "OK"
    2>Emulator nexus_5x_pie_9_0_api_28 is running.
    2>Deploying to nexus_5x_pie_9_0_api_28 ...
    Build started.
    Project "Phoneword.csproj" (Install target(s)):
    Found Java SDK version 1.8.0.
    Found Java SDK version 1.8.0.
    Dex Fast Deployment Enabled: False
    MonoAndroid Tools: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\
    Android Platform API level: 28
    TargetFrameworkVersion: v9.0
    Android NDK: C:\ProgramData\Microsoft\AndroidNDK\android-ndk-r10e\
    Android SDK: C:\Program Files (x86)\Android\android-sdk\
    Android SDK Build Tools: C:\Program Files (x86)\Android\android-sdk\build-tools\28.0.3\
    Java SDK: C:\Program Files\Android\Jdk\microsoft_dist_openjdk_1.8.0.25\
    Application Java class: android.app.Application
      PackageName: Phoneword.Phoneword
    Skipping target "_ResolveLibraryProjectImports" because all output files are up-to-date with respect to the input files.
    Skipping target "_BuildLibraryImportsCache" because all output files are up-to-date with respect to the input files.
    Skipping target "_BuildAdditionalResourcesCache" because all output files are up-to-date with respect to the input files.
    Skipping target "_CreateAdditionalResourceCache" because it has no outputs.
    Skipping target "_GenerateAndroidResourceDir" because all output files are up-to-date with respect to the input files.
    Skipping target "_GenerateLayoutBindings" because it has no outputs.
    Skipping target "_ConvertLibraryResourcesCases" because it has no inputs.
    Skipping target "_CompileAndroidLibraryResources" because it has no outputs.
    Skipping target "_ConvertResourcesCases" because all output files are up-to-date with respect to the input files.
    Skipping target "_CompileResources" because all output files are up-to-date with respect to the input files.
    Skipping target "_UpdateAndroidResgen" because all output files are up-to-date with respect to the input files.
      Adding assembly reference for Phoneword, recursively...
      Adding assembly reference for Java.Interop, recursively...
      Adding assembly reference for Mono.Android, recursively...
        Adding assembly reference for System.Net.Http, recursively...
        Adding assembly reference for System.Drawing.Common, recursively...
        Adding assembly reference for System.Runtime.Serialization, recursively...
          Adding assembly reference for System.ServiceModel.Internals, recursively...
      Adding assembly reference for mscorlib, recursively...
      Adding assembly reference for System.Core, recursively...
      Adding assembly reference for System, recursively...
        Adding assembly reference for Mono.Security, recursively...
        Adding assembly reference for System.Numerics, recursively...
      Adding assembly reference for System.Runtime, recursively...
        Adding assembly reference for System.ComponentModel.Composition, recursively...
      Adding assembly reference for System.Xml, recursively...
    Skipping target "_CopyConfigFiles" because it has no inputs.
    Skipping target "_CopyIntermediateAssemblies" because all output files are up-to-date with respect to the input files.
    Skipping target "_ConvertPdbFiles" because all output files are up-to-date with respect to the input files.
    Skipping target "_CopyPdbFiles" because all output files are up-to-date with respect to the input files.
    Skipping target "_CopyMdbFiles" because all output files are up-to-date with respect to the input files.
    Skipping target "_LinkAssembliesNoShrink" because all output files are up-to-date with respect to the input files.
    Skipping target "_GenerateJavaStubs" because all output files are up-to-date with respect to the input files.
    Skipping target "_ConvertCustomView" because all output files are up-to-date with respect to the input files.
    Skipping target "_AddStaticResources" because all output files are up-to-date with respect to the input files.
    Skipping target "_GeneratePackageManagerJava" because all output files are up-to-date with respect to the input files.
    Skipping target "_CreateAdditionalResourceCache" because it has no outputs.
    Skipping target "_GenerateAndroidAssetsDir" because it has no outputs.
    Skipping target "_CreateBaseApk" because all output files are up-to-date with respect to the input files.
    Skipping target "_CreateAdditionalResourceCache" because it has no outputs.
    Skipping target "_CompileJava" because all output files are up-to-date with respect to the input files.
    Skipping target "_CreateAdditionalResourceCache" because it has no outputs.
    Skipping target "_CompileToDalvikWithDx" because all output files are up-to-date with respect to the input files.
    Copying file from "D:\Documents\Visual Studio 2019\Learning\PhoneWord\Phoneword\obj\Debug\90\android\bin\Phoneword.Phoneword.apk" to "D:\Documents\Visual Studio 2019\Learning\PhoneWord\Phoneword\bin\Debug\Phoneword.Phoneword.apk".
    Creating "obj\Debug\90\android_debug_keystore.flag" because "AlwaysCreate" was specified.
    C:\Program Files\Android\Jdk\microsoft_dist_openjdk_1.8.0.25\bin\keytool.exe -list -alias androiddebugkey -storepass android -keypass android -keystore "C:\Users\Ryan Patterson\AppData\Local\Xamarin\Mono for Android\debug.keystore" 
    C:\Program Files (x86)\Android\android-sdk\build-tools\28.0.3\zipalign.exe -p 4 "D:\Documents\Visual Studio 2019\Learning\PhoneWord\Phoneword\obj\Debug\90\android\bin\Phoneword.Phoneword.apk" "bin\Debug\\Phoneword.Phoneword-Signed.apk" 
    C:\Program Files\Android\Jdk\microsoft_dist_openjdk_1.8.0.25\bin\java.exe -jar "C:\Program Files (x86)\Android\android-sdk\build-tools\28.0.3\lib\apksigner.jar" sign --ks "C:\Users\Ryan Patterson\AppData\Local\Xamarin\Mono for Android\debug.keystore" --ks-pass pass:android --ks-key-alias androiddebugkey --key-pass pass:android --min-sdk-version 21 --max-sdk-version 28  "D:\Documents\Visual Studio 2019\Learning\PhoneWord\Phoneword\bin\Debug\Phoneword.Phoneword-Signed.apk" 
    Signed android package 'bin\Debug\Phoneword.Phoneword-Signed.apk'
    Detecting installed packages...
    Removing old runtime: Mono.Android.DebugRuntime...
    Target device is x86.
    Installing the Mono shared runtime (debug - 1565368993)...
    10% ... 3200kb of 31991kb copied
    20% ... 6400kb of 31991kb copied
    30% ... 9600kb of 31991kb copied
    40% ... 12800kb of 31991kb copied
    50% ... 16000kb of 31991kb copied
    60% ... 19200kb of 31991kb copied
    70% ... 22400kb of 31991kb copied
    80% ... 25600kb of 31991kb copied
    90% ... 28800kb of 31991kb copied
    100% ... 31991kb of 31991kb copied
    ADB0000:  Deployment failed
    Mono.AndroidTools.InstallFailedException: Unexpected install output: 
    Exception occurred while executing:
    java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.List android.os.storage.StorageManager.getVolumes()' on a null object reference
        at com.android.internal.content.PackageHelper.resolveInstallVolume(PackageHelper.java:184)
        at com.android.internal.content.PackageHelper.resolveInstallVolume(PackageHelper.java:148)
        at com.android.internal.content.PackageHelper.resolveInstallVolume(PackageHelper.java:163)
        at com.android.server.pm.PackageInstallerService.createSessionInternal(PackageInstallerService.java:501)
        at com.android.server.pm.PackageInstallerService.createSession(PackageInstallerService.java:404)
        at com.android.server.pm.PackageManagerShellCommand.doCreateSession(PackageManagerShellCommand.java:2415)
        at com.android.server.pm.PackageManagerShellCommand.runInstall(PackageManagerShellCommand.java:907)
        at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:158)
        at android.os.ShellCommand.exec(ShellCommand.java:103)
        at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:21328)
        at android.os.Binder.shellCommand(Binder.java:634)
        at android.os.Binder.onTransact(Binder.java:532)
        at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:2821)
        at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:3856)
        at android.os.Binder.execTransact(Binder.java:731)
    
       at Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess(String output, String packageName) in E:\A\_work\275\s\External\androidtools\Mono.AndroidTools\Internal\AdbOutputParsing.cs:line 345
       at Mono.AndroidTools.AndroidDevice.<>c__DisplayClass95_0.<InstallPackage>b__0(Task`1 t) in E:\A\_work\275\s\External\androidtools\Mono.AndroidTools\AndroidDevice.cs:line 753
       at System.Threading.Tasks.ContinuationTaskFromResultTask`1.InnerInvoke()
       at System.Threading.Tasks.Task.Execute()
    ADB0010: Unexpected install output: 
    Exception occurred while executing:
    java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.List android.os.storage.StorageManager.getVolumes()' on a null object reference
        at com.android.internal.content.PackageHelper.resolveInstallVolume(PackageHelper.java:184)
        at com.android.internal.content.PackageHelper.resolveInstallVolume(PackageHelper.java:148)
        at com.android.internal.content.PackageHelper.resolveInstallVolume(PackageHelper.java:163)
        at com.android.server.pm.PackageInstallerService.createSessionInternal(PackageInstallerService.java:501)
        at com.android.server.pm.PackageInstallerService.createSession(PackageInstallerService.java:404)
        at com.android.server.pm.PackageManagerShellCommand.doCreateSession(PackageManagerShellCommand.java:2415)
        at com.android.server.pm.PackageManagerShellCommand.runInstall(PackageManagerShellCommand.java:907)
        at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:158)
        at android.os.ShellCommand.exec(ShellCommand.java:103)
        at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:21328)
        at android.os.Binder.shellCommand(Binder.java:634)
        at android.os.Binder.onTransact(Binder.java:532)
        at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:2821)
        at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:3856)
        at android.os.Binder.execTransact(Binder.java:731)
    
       at Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess(String output, String packageName) in E:\A\_work\275\s\External\androidtools\Mono.AndroidTools\Internal\AdbOutputParsing.cs:line 345
       at Mono.AndroidTools.AndroidDevice.<>c__DisplayClass95_0.<InstallPackage>b__0(Task`1 t) in E:\A\_work\275\s\External\androidtools\Mono.AndroidTools\AndroidDevice.cs:line 753
       at System.Threading.Tasks.ContinuationTaskFromResultTask`1.InnerInvoke()
       at System.Threading.Tasks.Task.Execute()
    Done building project "Phoneword.csproj" -- FAILED.
    Build FAILED.
    2>Deployment failed to nexus_5x_pie_9_0_api_28.
    ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
    ========== Deploy: 0 succeeded, 1 failed, 0 skipped ==========
    

    Any other thoughts on what could be going on?

Sign In or Register to comment.