VS 2019 Version 16.7.1, Xamarin Forms v4.8.0.1269
Worked previously, but archiving the Android App now fails (iOS OK). I have updated the Android SDK.
The error is (logging set to diagnostic):
XABLD7019: System.UnauthorizedAccessException: Access to the path 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0\Java.Interop.dll.lz4' is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
at Xamarin.Android.Tasks.AssemblyCompression.Compress(AssemblyData data)
at Xamarin.Android.Tasks.BuildApk.<AddAssemblies>g__CompressAssembly|138_1(ITaskItem assembly, <>c__DisplayClass138_0& )
at Xamarin.Android.Tasks.BuildApk.AddAssemblies(ZipArchiveEx apk, Boolean debug, Boolean compress, IDictionary`2 compressedAssembliesInfo)
at Xamarin.Android.Tasks.BuildApk.ExecuteWithAbi(String[] supportedAbis, String apkInputPath, String apkOutputPath, Boolean debug, Boolean compress, IDictionary`2 compressedAssembliesInfo)
at Xamarin.Android.Tasks.BuildApk.RunTask()
at Xamarin.Android.Tasks.AndroidTask.Execute()
There is a file in that folder called 'Java.Interop.dll', but not one called 'Java.Interop.dll.lz4'.
Does anyone have any ideas as to what may be causing this?
UPDATE: upgrading to visual studio 16.7.5 fixes this.
Updating to Visual Studio "16.8.0 Preview 1" doesn't fix this bug.
Workarounds:
add <AndroidEnableAssemblyCompression>false</AndroidEnableAssemblyCompression>
to the release section of your csproj. (I've confirmed this one works) But it may result in increased apk sizes. (UPDATE: doesn't appear to increase the apk size)
Enable project Linking. (unfortunately for some projects this is very hard to get working)
Run Visual Studio as admin. (I've confirmed this works on the Preview install, but wasn't prepared to do this on normal install)
Add user modify priviligies to
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\
(This is kind of like (3) but less extreme. (I've confirmed this works))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With