Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Archiving Xamarin Android App gives error XABLD7019

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?

like image 651
Rob L Avatar asked Aug 18 '20 05:08

Rob L


1 Answers

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:

  1. 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)

  2. Enable project Linking. (unfortunately for some projects this is very hard to get working)

  3. Run Visual Studio as admin. (I've confirmed this works on the Preview install, but wasn't prepared to do this on normal install)

  4. 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))

enter image description here

like image 188
Tom Avatar answered Nov 16 '22 12:11

Tom