Reputation: 11
I have a Xamarin Forms app that I've upgraded to Android 14 which builds fine but it fails when I try to run it in the emulator. I'm running Visual Studio 17.6.3 (build 421) on the Mac. I get the following error messages in the "Deploy to Device" window:
Target _PrepareBuildApk:
Target _BuildApkEmbed:
Building target "_BuildApkEmbed" completely.
Input file "obj/Debug/android/bin/classes.dex" is newer than output file "obj/Debug/android/bin/Crank.apk".
Using "BuildApk" task from assembly "/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Build.Tasks.dll".
Task "BuildApk"
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2103,3): error XABLD7024: Xamarin.Tools.Zip.ZipIOException: The file 'obj/Debug/android/bin/Crank.apk' is not a ZIP archive.
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2103,3): error XABLD7024: at Xamarin.Tools.Zip.ZipArchive.Open (System.String path, System.IO.FileMode mode, System.String defaultExtractionDir, System.Boolean strictConsistencyChecks, Xamarin.Tools.Zip.IPlatformOptions options) [0x0014c] in /Users/runner/work/1/s/LibZipSharp/Xamarin.Tools.Zip/ZipArchive.cs:283
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2103,3): error XABLD7024: at Xamarin.Android.Tasks.ZipArchiveEx..ctor (System.String archive, System.IO.FileMode filemode) [0x0001b] in <2042d6a236404eba9dfd12d3be81a9bd>:0
:
Done executing task "BuildApk" -- FAILED.
I've checked the bin folder and an apk file does exist. However, if I rename to .zip, it will not open... I do have a new XCode version (16), an Mac OS upgrade (Sequoia), and the addition of API Level 34 SDKs but I'm trying to run it in the preexisting API 33 emulator.
Ideas?
Update
I've isolated the problem and it comes from the update to AndroidManifest.xml to say '34':
<uses-sdk android:minSdkVersion="28" android:targetSdkVersion="34" />
If that's 33 I don't get the error. It needs to be 34 or else I cannot upload it to the Play store.
Upvotes: 0
Views: 199
Reputation: 1
I was having the same issue until I came across a similar post that suggested a few steps to fix it. First, make sure to check for updates in Visual Studio and install the latest one (Version 17.11.5). Then, go to the Android SDK Manager under the Tools menu, and install the following components:
Android SDK Platform 34 Sources for Android 34 Google APIs Intel x86_64 Atom System Image Google Play Intel x86_64 Atom System Image Android SDK Build-Tools 34
After updating everything, I restarted my PC and now it works fine with targetSdkVersion=34. I hope this helps. Good luck!
Upvotes: 0