Xamarin.forms: [Bug] [Debugging] [Deployment] Debugging with Android 10 device Error

Created on 15 May 2020  ·  13Comments  ·  Source: xamarin/Xamarin.Forms

Description

I have a project that runs fine on my Nokia android device. To update its reach, I updated my device to android 10. I went to the SDK manager and got the android v29.

With my AMD PC, a debug only using real devices.

I changed the target framework to v29, Android 10-Q.

I am getting deployment issues

Steps to Reproduce

  1. Create a Xamarin. Forms project that targets Android 9.
  2. Update framework and Nugget package to update
  3. Run

Expected Behavior

Build and deploy successfully

Actual Behavior

Gives the error

Severity Code Description Project File Line Suppression State
Error ADB0010: Deployment failed
Mono.AndroidTools.InstallFailedException: Unexpected install output: Error: Failed to parse APK file: /data/local/tmp/Mono.Android.Platform.ApiLevel_29.apk
Exception occurred while executing:
java.lang.IllegalArgumentException: Error: Failed to parse APK file: /data/local/tmp/Mono.Android.Platform.ApiLevel_29.apk
at com.android.server.pm.PackageManagerShellCommand.setParamsSize(PackageManagerShellCommand.java:486)
at com.android.server.pm.PackageManagerShellCommand.runInstall(PackageManagerShellCommand.java:1075)
at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:169)
at android.os.ShellCommand.exec(ShellCommand.java:104)
at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:22021)
at android.os.Binder.shellCommand(Binder.java:881)
at android.os.Binder.onTransact(Binder.java:765)
at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:4876)
at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:4128)
at android.os.Binder.execTransactInternal(Binder.java:1021)
at android.os.Binder.execTransact(Binder.java:994)
Caused by: android.content.pm.PackageParser$PackageParserException: Failed to parse /data/local/tmp/Mono.Android.Platform.ApiLevel_29.apk
at android.content.pm.PackageParser.parseApkLiteInner(PackageParser.java:1597)
at android.content.pm.PackageParser.parseApkLite(PackageParser.java:1582)
at com.android.server.pm.PackageManagerShellCommand.setParamsSize(PackageManagerShellCommand.java:479)
... 10 more
at Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess(String output, String packageName) in E:\A_work\548\s\External\androidtools\Mono.AndroidTools\Internal\AdbOutputParsing.cs:line 345
at Mono.AndroidTools.AndroidDevice.<>c__DisplayClass95_0.b__0(Task1 t) in E:\A\_work\548\s\External\androidtools\Mono.AndroidTools\AndroidDevice.cs:line 753 at System.Threading.Tasks.ContinuationTaskFromResultTask1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- 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 AndroidDeviceExtensions.d__11.MoveNext() in E:\A_work\548\s\External\androidtools\Xamarin.AndroidTools\Devices\AndroidDeviceExtensions.cs:line 187
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at AndroidDeviceExtensions.d__11.MoveNext() in E:\A_work\548\s\External\androidtools\Xamarin.AndroidTools\Devices\AndroidDeviceExtensions.cs:line 203
--- 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 AndroidDeviceExtensions.d__24.MoveNext() in E:\A_work\548\s\External\androidtools\Xamarin.AndroidTools\Devices\AndroidDeviceExtensions.cs:line 478
--- 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.d__110.MoveNext() in E:\A_work\548\s\External\androidtools\Xamarin.AndroidTools\Sessions\AndroidDeploySession.cs:line 355
--- 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.d__107.MoveNext() in E:\A_work\548\s\External\androidtools\Xamarin.AndroidTools\Sessions\AndroidDeploySession.cs:line 266
--- 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.d__106.MoveNext() in E:\A_work\548\s\External\androidtools\Xamarin.AndroidTools\Sessions\AndroidDeploySession.cs:line 194
--- 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.d__104.MoveNext() in E:\A_work\548\s\External\androidtools\Xamarin.AndroidTools\Sessions\AndroidDeploySession.cs:line 119 0

Basic Information

  • Version with issue: 4.6.0.772
  • Last known good version:
  • IDE: Visual studio 2019 v16.5.4
  • Platform Target Frameworks: Android 10 (Q)

    • iOS: 8.0 (not the issue)

    • Android: 10.0

    • UWP: Windows 10 1903 18362 (not the issue)

  • Android Support Library Version:
  • Nuget Packages:
  • Affected Devices:

Screenshots

Image of error

Reproduction Link

Public git of error

Workaround

Still stuck (15-04-2020 14:11 GMT +1)

needs-info ❓ needs-repro ❔ unverified bug

All 13 comments

@jonathanpeppers thoughts?

I am not sure what you are asking, but please go into details all, anything you think/believe / discovered could help.

@Rikudouensof at build time, some APK files are generated in:

  • Windows - %localappdata%\Xamarin.Android\Cache
  • Mac - ~/Library/Caches/Xamarin.Android/

Can you delete this directory and try again?

It seems like this file is not a valid APK:

Mono.AndroidTools.InstallFailedException: Unexpected install output: Error: Failed to parse APK file: /data/local/tmp/Mono.Android.Platform.ApiLevel_29.apk

Ok, let me see to this. @jonathanpeppers.

@jonathanpeppers it is working properly now, thanks a bunch.

Let me continue with the project.

Same issue have faced:

  • on Visual Studio for Mac (8.6.2) - build is success, but every deploy finished with same error
  • on Visual Studio for Windows (16.6.1) - build is success, deploy is working randomly - sometimes it is successfully, but rarely
Xamarin.Android.Common.Debugging.targets(616,2): error ADB0010:  Deployment failed
error ADB0010: Mono.AndroidTools.InstallFailedException: Unexpected install output: Error: Failed to parse APK file: /data/local/tmp/myapp-Signed.apk
error ADB0010: 
error ADB0010: Exception occurred while executing:
error ADB0010: java.lang.IllegalArgumentException: Error: Failed to parse APK file: /data/local/tmp/myapp-Signed.apk
error ADB0010:  at com.android.server.pm.PackageManagerShellCommand.setParamsSize(PackageManagerShellCommand.java:471)
error ADB0010:  at com.android.server.pm.PackageManagerShellCommand.runInstall(PackageManagerShellCommand.java:1060)
error ADB0010:  at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:169)
error ADB0010:  at android.os.ShellCommand.exec(ShellCommand.java:104)
error ADB0010:  at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:22658)
error ADB0010:  at android.os.Binder.shellCommand(Binder.java:881)
error ADB0010:  at android.os.Binder.onTransact(Binder.java:765)
error ADB0010:  at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:4971)
error ADB0010:  at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:4491)
error ADB0010:  at android.os.Binder.execTransactInternal(Binder.java:1021)
error ADB0010:  at android.os.Binder.execTransact(Binder.java:994)
error ADB0010: Caused by: android.content.pm.PackageParser$PackageParserException: Failed to parse /data/local/tmp/myapp-Signed.apk
error ADB0010:  at android.content.pm.PackageParser.parseApkLiteInner(PackageParser.java:1622)
error ADB0010:  at android.content.pm.PackageParser.parseApkLite(PackageParser.java:1580)
error ADB0010:  at com.android.server.pm.PackageManagerShellCommand.setParamsSize(PackageManagerShellCommand.java:464)
error ADB0010:  ... 10 more
error ADB0010: Caused by: java.io.FileNotFoundException: Corrupt XML binary file
error ADB0010:  at android.content.res.ApkAssets.nativeOpenXml(Native Method)
error ADB0010:  at android.content.res.ApkAssets.openXml(ApkAssets.java:156)
error ADB0010:  at android.content.pm.PackageParser.parseApkLiteInner(PackageParser.java:1599)
error ADB0010:  ... 12 more
error ADB0010: 
error ADB0010:   at Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess (System.String output, System.String packageName) [0x00173] in /Users/builder/azdo/_work/204/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Mono.AndroidTools/Internal/AdbOutputParsing.cs:348 
error ADB0010:   at Mono.AndroidTools.AndroidDevice+<>c__DisplayClass95_0.<InstallPackage>b__0 (System.Threading.Tasks.Task`1[TResult] t) [0x00016] in /Users/builder/azdo/_work/204/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Mono.AndroidTools/AndroidDevice.cs:764 
error ADB0010:   at System.Threading.Tasks.ContinuationTaskFromResultTask`1[TAntecedentResult].InnerInvoke () [0x00024] in <55adae4546cd485ba70e2948332ebe8c>:0 
error ADB0010:   at System.Threading.Tasks.Task.Execute () [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2019-12/external/bockbuild/builds/mono-x64/external/corert/src/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs:2319 
error ADB0010: --- End of stack trace from previous location where exception was thrown ---
error ADB0010: 
error ADB0010:   at AndroidDeviceExtensions.PushAndInstallPackage (Mono.AndroidTools.AndroidDevice device, System.String apkFile, System.String packageName, System.Boolean reinstall, Mono.AndroidTools.Adb.AdbProgressReporter notifyProgress, System.Threading.CancellationToken token) [0x00189] in /Users/builder/azdo/_work/204/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Devices/AndroidDeviceExtensions.cs:187 
error ADB0010:   at AndroidDeviceExtensions.PushAndInstallPackage (Mono.AndroidTools.AndroidDevice device, System.String apkFile, System.String packageName, System.Boolean reinstall, Mono.AndroidTools.Adb.AdbProgressReporter notifyProgress, System.Threading.CancellationToken token) [0x003df] in /Users/builder/azdo/_work/204/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Devices/AndroidDeviceExtensions.cs:203 
error ADB0010:   at Xamarin.AndroidTools.AndroidDeploySession.InstallPackage () [0x003be] in /Users/builder/azdo/_work/204/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Sessions/AndroidDeploySession.cs:433 
error ADB0010:   at Xamarin.AndroidTools.AndroidDeploySession.RunAsync (System.Threading.CancellationToken token) [0x003ae] in /Users/builder/azdo/_work/204/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Sessions/AndroidDeploySession.cs:217 
error ADB0010:   at Xamarin.AndroidTools.AndroidDeploySession.RunLoggedAsync (System.Threading.CancellationToken token) [0x0002f] in /Users/builder/azdo/_work/204/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Sessions/AndroidDeploySession.cs:119 

@VictorKochetkov did you try the workaround? https://github.com/xamarin/Xamarin.Forms/issues/10707#issuecomment-630271548

Xamarin.Android's deployment workflow will be changing soon, so this error wouldn't happen at all in the future.

Yes, I've tried - no effect.
In future - ok, but what to do right now?) I'm unable to deploy, debug app :(
Any suggestions?

Ok, yours is actually failing to install _your app_: myapp-Signed.apk. This is a different issue.

Are you comfortable uploading the .apk here? Or email me privately? Use my email listed on Github. Thanks!

Closing this for now. @VictorKochetkov if you're still having issues and can upload an apk I'll reopen

@VictorKochetkov I'm facing the same issue on Visual Studio for Mac (8.6.8), were you able to fix it?

@VictorKochetkov I'm facing the same issue on Visual Studio for Mac (8.6.8), were you able to fix it?

This issue is still appears. But I have some workaround) Just check/uncheck multidex feature in project properties temporarily fixes the issue.

@VictorKochetkov can you attach a diagnostic MSBuild log the next time you hit the error?

Was this page helpful?
0 / 5 - 0 ratings