android: [Bug] application deploy on Android 11 emulator fails with Mono.AndroidTools.AdbException: secure_mkdirs failed: Permission denied
Description
Last week upgraded Visual Studio 2019(Professional) which shipped Android 11 SDK updates I changed the target SDK in both manifest and project application properties. When I try to deploy the app I get the error. This error doesnt show up for Android Pie and Q emulators
Steps to Reproduce
- Update Visual Studio 2019 to 16.7
- Update all android SDKs
- Create an x86 emulator with Android 11®
- Build and Run Android app selecting Android 11 emulator
Expected Behavior
App should deploy and run successfully.
Actual Behavior
Severity Code Description Project File Line Suppression State
Error ADB1000: Deployment failed
Xamarin.AndroidTools.AndroidDeploymentException: FailedToSynchronizeFastDevAssemblies ---> Mono.AndroidTools.AdbException: secure_mkdirs failed: Permission denied
at Mono.AndroidTools.Util.AggregateAsyncResult.CheckError(CancellationToken token)
at Mono.AndroidTools.Adb.AdbSyncClient.EndPushSyncItems(IAsyncResult result)
at Mono.AndroidTools.Internal.AdbClientTaskExtensions.InnerInvoke(TaskCompletionSource`1 tcs, Func`2 endMethod, IAsyncResult l)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Xamarin.AndroidTools.AndroidDeploySession.<InstallAssemblies>d__121.MoveNext()
--- End of inner exception stack trace ---
at Xamarin.AndroidTools.AndroidDeploySession.<InstallAssemblies>d__121.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Xamarin.AndroidTools.AndroidDeploySession.<FastDevAsync>d__118.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Xamarin.AndroidTools.AndroidDeploySession.<RunAsync>d__110.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Xamarin.AndroidTools.AndroidDeploySession.<RunLoggedAsync>d__108.MoveNext() 0
Basic Information
- Version with issue: Xamarin Forms 4.8.0.XXXX
- Last known good version: Not sure
- IDE: Visual Studio 2019 Professional
- Platform Target Frameworks:
- iOS: N/A
- Android: Android 11
- UWP: N/A
- Android Support Library Version:
- Nuget Packages: Xamarin Forms 4.8.0.XXXX Xamarin.Android.Support 28.0.0.3
- Affected Devices:
Screenshots
Reproduction Link
Workaround
Turn Use Fast Deployment Off Reference : https://forums.xamarin.com/discussion/11383/deployment-failed-due-to-an-error-in-fastdev-assembly-synchronization
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 27
- Comments: 32 (14 by maintainers)
Commits related to this issue
- Bump to xamarin/monodroid/master@a9ae74d4 Fixes: https://github.com/xamarin/xamarin-android/issues/4996 Changes: https://github.com/xamarin/monodroid/compare/92b9cce8dacad8b7ce48ddbcf9e5247598cd2ccd... — committed to jonpryor/xamarin-android by jonpryor 6 years ago
- Bump to xamarin/monodroid/master@a9ae74d4 Fixes: https://github.com/xamarin/xamarin-android/issues/4996 Changes: https://github.com/xamarin/monodroid/compare/92b9cce8dacad8b7ce48ddbcf9e5247598cd2ccd... — committed to jonpryor/xamarin-android by jonpryor 6 years ago
- Bump to xamarin/monodroid/master@a9ae74d4 (#5112) Fixes: https://github.com/xamarin/xamarin-android/issues/4996 Changes: https://github.com/xamarin/monodroid/compare/92b9cce8dacad8b7ce48ddbcf9e524... — committed to dotnet/android by jonpryor 6 years ago
- [Xamarin.Android.Build.Tasks] Fast Deployment v2.0 Fixes #5009 Fixes #5147 Fixes #4996 The Fast Deployment system used for debugging Xamarin.Android apps has been completely re-written. This is most... — committed to dellis1972/xamarin-android by dellis1972 7 years ago
- [Xamarin.Android.Build.Tasks] Fast Deployment v2.0 Fixes #5009 Fixes #5147 Fixes #4996 The Fast Deployment system used for debugging Xamarin.Android apps has been completely re-written. This is most... — committed to dellis1972/xamarin-android by dellis1972 7 years ago
- [Xamarin.Android.Build.Tasks] Fast Deployment v2.0 Fixes #5009 Fixes #5147 Fixes #4996 The Fast Deployment system used for debugging Xamarin.Android apps has been completely re-written. This is most... — committed to dellis1972/xamarin-android by dellis1972 7 years ago
- [Xamarin.Android.Build.Tasks] Fast Deployment v2.0 Fixes #5009 Fixes #5147 Fixes #4996 The Fast Deployment system used for debugging Xamarin.Android apps has been completely re-written. This is most... — committed to dellis1972/xamarin-android by dellis1972 7 years ago
- [Xamarin.Android.Build.Tasks] Fast Deployment v2.0 Fixes #5009 Fixes #5147 Fixes #4996 The Fast Deployment system used for debugging Xamarin.Android apps has been completely re-written. This is most... — committed to dellis1972/xamarin-android by dellis1972 7 years ago
- [Xamarin.Android.Build.Tasks] Fast Deployment v2.0 (#4690) Fixes: https://github.com/xamarin/xamarin-android/issues/4996 Fixes: https://github.com/xamarin/xamarin-android/issues/5009 Fixes: https:/... — committed to dotnet/android by dellis1972 6 years ago
Update
I noticed this exception goes away if we turn Use Fast Deployment off
So this can be thought as a workaround
Release status update
A new Preview version of Xamarin.Android has now been published that includes the fix for this item. The fix is not yet included in a Release version. I will update this item again when a Release version is available that includes the fix.
Fix included in Xamarin.Android SDK version 11.1.0.3.
Fix included on Windows in Visual Studio 2019 version 16.8 Preview 3. To try the Preview version that includes the fix, check for the latest updates in Visual Studio Preview.
Fix included on macOS in Visual Studio 2019 for Mac version 8.8 Preview 3. To try the Preview version that includes the fix, check for the latest updates on the Preview updater channel.
More investigation https://developer.android.com/reference/android/os/Environment#getExternalStorageDirectory().
So when targeting Q, the external storage directory will not work.
This will be addressed in PR https://github.com/xamarin/xamarin-android/pull/4690 with the new Fast Deployment system which does not use the external storage directory.
The best thing to do at this time is to disable Fast Deployment when targeting Android Q 😦.
Having the same problem with VS19 Enterprise (Version 16.8.4). Turning off fast debugging worked for me.
Build details:
Did that and my localization logic broke. https://github.com/xamarin/xamarin-android/issues/5659 Looks like it’s in preview for a reason 😄
Release status update
A new Preview version of Xamarin.Android has now been published that includes the fix for this item.
Fix included in Xamarin.Android SDK version 11.1.99.168.
Fix included on Windows in Visual Studio 2019 version 16.9 Preview 1. To try the Preview version that includes the fix, check for the latest updates in Visual Studio Preview.
Fix included on macOS in Visual Studio 2019 for Mac version 8.9 Preview 1. To try the Preview version that includes the fix, check for the latest updates on the Preview updater channel.
@brendanzagaeski @pmahend1 I’ve just tested with VS 2019 16.8 pre3. It looks like the issue is still here. Could you please confirm if this works for you ?
@pmahend1 ok that’s good to hear. I’ll sort out a PR. I suspect however that we have missed the next Preview cut off I’m afraid. But I will try to get this on the next available release.
This issue does only effect debug and has no effect on release.
@Paul-DotNET Try 16.9.4 we completely re-wrote the Fast Deployment system for that release.
A Summary for anyone interested:
Even though changes to this were made and merged into master in October 2020, they didn’t make it to the November Production release, and so they are still in Preview. You don’t need to switch update channels to preview in your Visual Studio, just go to the Xamarin.Android Github, and tap on the “Commercial Xamarin.Android 11.2 (d16-9) Preview for …” link to download the package to install the version with the amazing changes made, and your app should just start building (super fast) with no changes!
We are going to re-open this issue. The fix will be the new fast deployment system on #4690. The work around for now is to not use the shared runtime or fast deployment.
@tranb3r we “thought” that updating the shared runtime to not use deprecated API’s to access the external storage would get rid of this particular error. Apparently this was not the case. It might also be device/emulator related as well since I never managed to repo the issue reliably.
The best option moving forward is to not rely on the use of external storage, which is what PR #4690 will do.
@dellis1972 Thanks for the clarification. Although I’m still confused about what’s in the “fix” if this issue cannot be fixed…
@pmahend1 @brendanzagaeski I’m having the exact same error as described originally in this issue (using VS 2019 16.8-pre3) :
Xamarin.AndroidTools.AndroidDeploymentException: FailedToSynchronizeFastDevAssemblies ---> Mono.AndroidTools.AdbException: secure_mkdirs failed: Permission deniedI don’t see any reason to open a new ticket. Could you please re-open this one, as the issue is obviously not fixed.
I can help answer the question of whether the specific fix that was provided in a test build earlier has been published. The answer to that is yes, the specific fix from that earlier test build is indeed included in Xamarin.Android SDK version 11.1.0.3 Preview, which is part of Visual Studio 2019 version 16.8 Preview 3 and Visual Studio 2019 for Mac version 8.8 Preview 3. The commit on the d16-8 development branch that provides that fix is https://github.com/xamarin/xamarin-android/commit/ff57bc83b1c2d5e74dc13ac8f192bbbbba079dc9.
This issue (#4996) is accordingly listed under the Issues fixed section in the Xamarin.Android 11.1 Preview release notes on docs.microsoft.com and on GitHub
Next steps
It sounds like the particular fix provided in this issue might not have resolved the problem for all devices. If any users are still seeing the problem when using Visual Studio 2019 version 16.8 Preview 3 or higher or Visual Studio 2019 for Mac version 8.8 Preview 3 or higher, then the next best step would be to submit a new issue and attach or send the diagnostic deployment log to dellis1972 as mentioned in https://github.com/xamarin/xamarin-android/issues/4996#issuecomment-672766328. Thanks in advance!