android: Fast deployment not working / very slow

Happens since VS 16.9 and the changes to the Fast deployment

Steps to Reproduce

  1. Create standard Android app in VS
  2. Build & deploy
  3. Make C# code change
  4. Redeploy

App1.zip

Expected Behavior

Fast build & deploy

Actual Behavior

Slow deploy. The attached demo app takes a whopping 40 secs to recompile, apply the change and launch this barebone app in the simulator

Version Information

VS 16.9.0 Xamarin.Android 11.2.0.21

Log File

Build started...
1>------ Build started: Project: App1, Configuration: Debug Any CPU ------
1>  App1 -> C:\Users\***\Desktop\App1\bin\Debug\App1.dll
2>Starting deployment to Pixel_4_API_29 ...
2>Deploying to Pixel_4_API_29 ...
Build started.
Project "App1.csproj" (Install target(s)):
Found Java SDK version 1.8.0.
Found Java SDK version 1.8.0.
  PackageName: com.companyname.app1
Dex Fast Deployment Enabled: False
MonoAndroid Tools: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\
Android Platform API level: 30
TargetFrameworkVersion: v11.0
Android NDK: E:\android-sdk
dk-bundle\
Android SDK: E:\android-sdk\
Android SDK Build Tools: E:\android-sdk\build-tools\30.0.2\
Java SDK: C:\Program Files\Android\jdk\microsoft_dist_openjdk_1.8.0.25\
Application Java class: android.app.Application
Touching "obj\Debug\110\stamp\_ResolveLibraryProjectImports.stamp".
Skipping target "_BuildLibraryImportsCache" because all output files are up-to-date with respect to the input files.
Skipping target "_GenerateLayoutBindings" because it has no outputs.
Touching "obj\Debug\110\stamp\_ConvertResourcesCases.stamp".
Touching "obj\Debug\110\R.cs.flag".
  Adding assembly reference for App1, 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.Numerics.Vectors, recursively...
  Adding assembly reference for System.Runtime, recursively...
    Adding assembly reference for System.ComponentModel.Composition, recursively...
  Adding assembly reference for System.Xml, recursively...
  Adding assembly reference for Xamarin.AndroidX.Activity, recursively...
  Adding assembly reference for Xamarin.AndroidX.Annotation, recursively...
  Adding assembly reference for Xamarin.AndroidX.AppCompat.AppCompatResources, recursively...
  Adding assembly reference for Xamarin.AndroidX.AppCompat, recursively...
  Adding assembly reference for Xamarin.AndroidX.Arch.Core.Common, recursively...
  Adding assembly reference for Xamarin.AndroidX.Arch.Core.Runtime, recursively...
  Adding assembly reference for Xamarin.AndroidX.AsyncLayoutInflater, recursively...
  Adding assembly reference for Xamarin.AndroidX.Browser, recursively...
  Adding assembly reference for Xamarin.AndroidX.CardView, recursively...
  Adding assembly reference for Xamarin.AndroidX.Collection, recursively...
  Adding assembly reference for Xamarin.AndroidX.CoordinatorLayout, recursively...
  Adding assembly reference for Xamarin.AndroidX.Core, recursively...
  Adding assembly reference for Xamarin.AndroidX.CursorAdapter, recursively...
  Adding assembly reference for Xamarin.AndroidX.CustomView, recursively...
  Adding assembly reference for Xamarin.AndroidX.DocumentFile, recursively...
  Adding assembly reference for Xamarin.AndroidX.DrawerLayout, recursively...
  Adding assembly reference for Xamarin.AndroidX.Fragment, recursively...
  Adding assembly reference for Xamarin.AndroidX.Interpolator, recursively...
  Adding assembly reference for Xamarin.AndroidX.Legacy.Support.Core.UI, recursively...
  Adding assembly reference for Xamarin.AndroidX.Legacy.Support.Core.Utils, recursively...
  Adding assembly reference for Xamarin.AndroidX.Lifecycle.Common, recursively...
  Adding assembly reference for Xamarin.AndroidX.Lifecycle.LiveData.Core, recursively...
  Adding assembly reference for Xamarin.AndroidX.Lifecycle.Runtime, recursively...
  Adding assembly reference for Xamarin.AndroidX.Lifecycle.ViewModel, recursively...
  Adding assembly reference for Xamarin.AndroidX.Lifecycle.ViewModelSavedState, recursively...
  Adding assembly reference for Xamarin.AndroidX.Loader, recursively...
  Adding assembly reference for Xamarin.AndroidX.LocalBroadcastManager, recursively...
  Adding assembly reference for Xamarin.AndroidX.MultiDex, recursively...
  Adding assembly reference for Xamarin.AndroidX.Print, recursively...
  Adding assembly reference for Xamarin.AndroidX.RecyclerView, recursively...
  Adding assembly reference for Xamarin.AndroidX.SavedState, recursively...
  Adding assembly reference for Xamarin.AndroidX.SlidingPaneLayout, recursively...
  Adding assembly reference for Xamarin.AndroidX.SwipeRefreshLayout, recursively...
  Adding assembly reference for Xamarin.AndroidX.Transition, recursively...
  Adding assembly reference for Xamarin.AndroidX.VectorDrawable.Animated, recursively...
  Adding assembly reference for Xamarin.AndroidX.VectorDrawable, recursively...
  Adding assembly reference for Xamarin.AndroidX.VersionedParcelable, recursively...
  Adding assembly reference for Xamarin.AndroidX.ViewPager, recursively...
  Adding assembly reference for Xamarin.Essentials, recursively...
  Adding assembly reference for Xamarin.Google.Android.Material, recursively...
  Adding assembly reference for Xamarin.Google.Guava.ListenableFuture, recursively...
Skipping target "_CopyConfigFiles" because it has no inputs.
Skipping target "_ConvertPdbFiles" because it has no outputs.
Skipping target "_CopyConfigFiles" because it has no inputs.
Skipping target "_ConvertPdbFiles" because it has no outputs.
Touching "obj\Debug\110\stamp\_GenerateJavaStubs.stamp".
C:\Program Files\Android\jdk\microsoft_dist_openjdk_1.8.0.25\bin\java.exe -cp "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\manifestmerger.jar" com.xamarin.manifestmerger.Main obj\Debug\110\android\manifestmerger.rsp 
Skipping target "_ConvertCustomView" because all output files are up-to-date with respect to the input files.
Copying file from "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v11.0\mono.android.jar" to "C:\Users\***\Desktop\App1\obj\Debug\110\android\bin\mono.android.jar".
Touching "obj\Debug\110\android\bin\mono.android.jar".
Touching "obj\Debug\110\static.flag".
Touching "obj\Debug\110\stamp\_GeneratePackageManagerJava.stamp".
Skipping target "_GenerateAndroidAssetsDir" because it has no outputs.
Touching "obj\Debug\110\android\bin\packaged_resources".
Skipping target "_CompileJava" because all output files are up-to-date with respect to the input files.
Deleting file "obj\Debug\110\android\bin\classes.dex".
C:\Program Files\Android\jdk\microsoft_dist_openjdk_1.8.0.25\bin\java.exe -Xmx1G -classpath "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\r8.jar" com.android.tools.r8.D8 --debug --min-api 23 --output obj\Debug\110\android\bin\ --lib E:\android-sdk\platforms\android-30\android.jar obj\Debug\110\android\bin\classes.zip "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v11.0\mono.android.jar" "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\\java_runtime.jar" C:\Users\***\.nuget\packages\xamarin.google.guava.listenablefuture\1.0.0.2\buildTransitive\monoandroid50\guava-listenablefuture.jar C:\Users\***\.nuget\packages\xamarin.androidx.annotation\1.1.0.7\buildTransitive\monoandroid90\..\..\jar\androidx.annotation.annotation.jar C:\Users\***\.nuget\packages\xamarin.androidx.collection\1.1.0.5\buildTransitive\monoandroid90\..\..\jar\androidx.collection.collection.jar C:\Users\***\.nuget\packages\xamarin.androidx.lifecycle.common\2.2.0.3\buildTransitive\monoandroid90\..\..\jar\androidx.lifecycle.lifecycle-common.jar C:\Users\***\.nuget\packages\xamarin.androidx.arch.core.common\2.1.0.6\buildTransitive\monoandroid90\..\..\jar\androidx.arch.core.core-common.jar obj\Debug\110\lp\41\jl\classes.jar obj\Debug\110\lp\42\jl\classes.jar obj\Debug\110\lp\43\jl\classes.jar obj\Debug\110\lp\44\jl\classes.jar obj\Debug\110\lp\45\jl\classes.jar obj\Debug\110\lp\46\jl\classes.jar obj\Debug\110\lp\47\jl\classes.jar obj\Debug\110\lp\48\jl\classes.jar obj\Debug\110\lp\49\jl\classes.jar obj\Debug\110\lp\50\jl\classes.jar obj\Debug\110\lp\51\jl\classes.jar obj\Debug\110\lp\52\jl\classes.jar obj\Debug\110\lp\53\jl\classes.jar obj\Debug\110\lp\54\jl\classes.jar obj\Debug\110\lp\55\jl\classes.jar obj\Debug\110\lp\56\jl\classes.jar obj\Debug\110\lp\57\jl\classes.jar obj\Debug\110\lp\58\jl\classes.jar obj\Debug\110\lp\59\jl\classes.jar obj\Debug\110\lp\60\jl\classes.jar obj\Debug\110\lp\61\jl\classes.jar obj\Debug\110\lp\62\jl\classes.jar obj\Debug\110\lp\63\jl\classes.jar obj\Debug\110\lp\64\jl\classes.jar obj\Debug\110\lp\65\jl\classes.jar obj\Debug\110\lp\66\jl\classes.jar obj\Debug\110\lp\67\jl\classes.jar obj\Debug\110\lp\68\jl\classes.jar obj\Debug\110\lp\69\jl\classes.jar obj\Debug\110\lp\70\jl\classes.jar obj\Debug\110\lp\71\jl\classes.jar obj\Debug\110\lp\72\jl\classes.jar obj\Debug\110\lp\73\jl\classes.jar obj\Debug\110\lp\74\jl\classes.jar 
Warning in obj\Debug\110\lp\74\jl\classes.jar:androidx/browser/browseractions/BrowserServiceFileProvider.class:
  Type `androidx.concurrent.futures.ResolvableFuture` was not found, it is required for default or static interface methods desugaring of `Landroidx/browser/browseractions/BrowserServiceFileProvider;saveBitmap(Landroid/content/Context;Landroid/graphics/Bitmap;Ljava/lang/String;I)Landroidx/concurrent/futures/ResolvableFuture;`
Warning in obj\Debug\110\lp\74\jl\classes.jar:androidx/browser/trusted/ConnectionHolder.class:
  Type `androidx.concurrent.futures.CallbackToFutureAdapter` was not found, it is required for default or static interface methods desugaring of `Landroidx/browser/trusted/ConnectionHolder;getServiceWrapper()Lcom/google/common/util/concurrent/ListenableFuture;`
Warning in synthesized for lambda desugaring:
  Type `androidx.concurrent.futures.CallbackToFutureAdapter$Resolver` was not found, it is required for default or static interface methods desugaring of `androidx.browser.trusted.-$$Lambda$ConnectionHolder$Rp3Hxy1AUk9cWatAvfzHyT3B2KI`
Touching "obj\Debug\110\stamp\_CompileToDalvik.stamp".
Deleting file "bin\Debug\com.companyname.app1.apk".
Copying file from "C:\Users\***\Desktop\App1\obj\Debug\110\android\bin\com.companyname.app1.apk" to "C:\Users\***\Desktop\App1\bin\Debug\com.companyname.app1.apk".
Creating "obj\Debug\110\android_debug_keystore.flag" because "AlwaysCreate" was specified.
Deleting file "C:\Users\***\Desktop\App1\bin\Debug\com.companyname.app1-Signed.apk".
E:\android-sdk\build-tools\30.0.2\zipalign.exe -p 4 "C:\Users\***\Desktop\App1\obj\Debug\110\android\bin\com.companyname.app1.apk" "bin\Debug\\com.companyname.app1-Signed.apk" 
C:\Program Files\Android\jdk\microsoft_dist_openjdk_1.8.0.25\bin\java.exe -jar "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\apksigner.jar" sign --ks "C:\Users\***\AppData\Local\Xamarin\Mono for Android\debug.keystore" --ks-pass pass:android --ks-key-alias androiddebugkey --key-pass pass:android --min-sdk-version 23 --max-sdk-version 30  C:\Users\***\Desktop\App1\bin\Debug\com.companyname.app1-Signed.apk 
Signed android package 'bin\Debug\com.companyname.app1-Signed.apk'
Using cached value from RegisterTaskObject
Found device: emulator-5554
Creating "obj\Debug\110\upload.flag" because "AlwaysCreate" was specified.
Done building project "App1.csproj".
Build succeeded.
2>Deployment was successful to Pixel_4_API_29.
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Deploy: 1 succeeded, 0 failed, 0 skipped ==========

Also, 2 questions:

  • It seems like the Shared Runtime and Xamarin.Android API-XX Support packages are no longer installed onto the device. I’ve seen in this PR that this is expected behavior for the Shared Runtime. Is it also for the Xamarin.Android API-XX Support packages?
  • I’ve seen that the Visual Studio UI doesn’t offer a toggle for the “Use shared runtime” settings which toggles the AndroidUseSharedRuntime property in the csproj. Is this property now obsolete and can be removed? The default template still includes it

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 65 (40 by maintainers)

Most upvoted comments

You should be able to use a different Android SDK path. The only issue would be if you use Android Studio to update it – it’s possible a newer version of something (like Build Tools) might break Xamarin.Android. The SDK manager in Visual Studio should hopefully only offer known working versions of things.

I think we can close this for now, thanks!

I filed an internal issue, so we could get the Install target showing up again in Project System Tools. I’ll ping them again.

Without that, I’m not sure I can figure out what is going wrong here.

@tipa glad you are finally getting the build/deploy experience you were supposed to 😃

You should be able to use a different sdk, there is a us case where we have a problem with though. As @jonathanpeppers said there is a bug in there somewhere which we will look at and fix.

@tipa

OK looks like what is happening is the _CleanIntermediateIfNeeded target is running. This is only normally run if something in the build settings change, such as the device or the supported abi’s or things like EmbedAssembliesIntoApk. So it looks like our _CreatePropertiesCache target thinks the build.props file changes which kicks all this stuff off. I’m not sure why unless the WriteLinesToFile task suddenly became case sensitive…

I’ll dig into it a bit more, but I think we are on track now.

Happy to hear there was some useful info in there! It should have been an incremental build, but maybe it didn’t work because I changed the csproj and added the property, so I did the test again:

  • First I hit the deploy button, to make sure the app is installed and app launched immediately in the simulator: image
  • Then I did a code change and saved the source file
  • Then I started logging in the extension: image
  • Then I clicked the deploy button (see above) again.
  • … long time waiting … (after 30min I went for a walk and when I came back 20min later, the app was finally deployed)
  • stopped build logging and collected all the logs: output window.zip build logging.zip

Thanks for reassuring me 😃 I now was really patient during VS (seemed to) hang and after 10-15 min the build actually finished, with these settings:

image image

Attached the output from the VS extension: App1_Debug_AnyCPU_Build_2021-03-16T13_55_23.5939075+01_00.zip RoslynLog-61eb397e-28fa-459b-a57d-8ff9fecc4081.txt

Also copy-pasted the output from all the tabs (that had any content) of the Output Window: Output Window.zip

I hope this contains any useful information. I did not wait for an hour like you suggested but I can try to go through the procedure again if your ask me to.

Right Click on the XamarinAndroidDebuggerHangPatch.zip file you downloaded. Go to Properties and right at the bottom of that Properties window is a little checkbox called “Unblock” , check it then click ok.

Its a safety measure windows has to stop unknown executables running. That might be causing the problem.

Once you’ve done that reextract the files and then copy them into place.