Skip to content

When using FastDeployment get error message XA0136: The 'run-as' command failed with 'run-as: Package 'packagename' has corrupt installation #7821

Closed

Description

@jlinker7

Android application type

Classic Xamarin.Android (MonoAndroid12.0, etc.)

Affected platform version

Windows VS 2020 Latest release (including Beta version), Android 7.1.1 Custom Device

Description

While trying the work around for issue #7521 (comment), which involves using Fast Deployment, I encounter the error

XA0136: The 'run-as' command failed with 'run-as: Package 'packagename' has corrupt installation'.
The currently installation of the package in corrupt. Please manually uninstall the
package from all the users on device and try again. If that does not work you can disable Fast Deployment.
Fast Deployment can be disabled in the Visual Studio project property pages or edit the project file in a text editor and set the 'EmbedAssembliesIntoApk' MSBuild property to 'true'.

msbuild.zip

Steps to Reproduce

  1. Xamarin.Android project running on custom device, Android 7.1.1, armv7 chip
  2. Visual Studio 2022 17.5.0 Preview 6.0 (but also experienced in on previous versions)
  3. Currently there is a bug that is preventing from running with debugger (mscorblib cannot load) that has a fix that isn't released yet, the work around is to use Fast Deployment
  4. Run with debug and Fast Deployment enabled
  5. Observe error about run-as command failed due to corrupt installation
  6. Without Fast Deployment, the app will start then crash due to the mscorlib error, but then you can relaunch the app without debugger and it runs fine
  7. With fast deployment, even after the initial attempt at it running, trying to run it again will result in an immediate crash

Did you find any workaround?

No

Relevant log output

XA0136: The 'run-as' command failed with 'run-as: Package 'packagename' has corrupt installation'.
The currently installation of the package in corrupt. Please manually uninstall the 
package from all the users on device and try again. If that does not work you can disable Fast Deployment.
Fast Deployment can be disabled in the Visual Studio project property pages or edit the project file in a text editor and set the 'EmbedAssembliesIntoApk' MSBuild property to 'true'.

Also attached msbuild.binlog.

Activity

  1. added
    Area: App+Library BuildIssues when building Library projects or Application projects.
    need-infoIssues that need more information from the author.
    and removed
    needs-triageIssues that need to be assigned.
    on Feb 22, 2023
  2. dellis1972 commented on Feb 22, 2023

    @dellis1972
    Contributor

    @jlinker7

    Thanks for opening the issue and the binlog.
    However we are missing the additional diagnostics produced by the _FastDeploymentDiagnosticLogging option.
    Could you please provide a new one with that option enabed?

    msbuild foo.csproj /restore -t:Install -p:_FastDeploymentDiagnosticLogging=true -bl
    
  3. jlinker7 commented on Feb 22, 2023

    @jlinker7
    Author

    msbuildoutput_and_binlog.zip

    My apologies, I thought I had it enabled before that run, but may have switched branches without realizing it. Let me know if this includes the information needed. I included both the binlog file and the output to the command prompt window when running the msbuild command. Thanks!

  4. ghost removed
    need-infoIssues that need more information from the author.
    on Feb 22, 2023
  5. ghost added
    need-attentionA xamarin-android contributor needs to review
    on Feb 22, 2023
  6. dellis1972 commented on Feb 22, 2023

    @dellis1972
    Contributor

    @jlinker7

    can you try running the following command from the "Adb Command Prompt"

     adb shell pm uninstall com.lathem.payclock
    

    Note we are not using the -k option which preserves data. I just wonder if there is something from a previous installation which didn't work. Also out of interest, has this ever worked?

  7. 12 remaining items

  8. ghost added
    need-attentionA xamarin-android contributor needs to review
    on Mar 10, 2023
  9. dellis1972 commented on Mar 10, 2023

    @dellis1972
    Contributor

    Looking back though the old source code we find this

    https://github.com/aosp-mirror/platform_system_core/blob/nougat-mr1-release/run-as/run-as.c#L176

    /* check that the data directory path is valid */
    if (check_data_path(info.dataDir, userAppId) < 0) {
        panic("Package '%s' has corrupt installation\n", pkgname);
    }

    Which leads us to https://github.com/aosp-mirror/platform_system_core/blob/nougat-mr1-release/run-as/package.c#L217.

    Which suggests there is something wrong with the data directory

  10. jlinker7 commented on Mar 10, 2023

    @jlinker7
    Author

    @dellis1972 Thank you for pointing me in the direction of that code, next chance I have I will look through it and see if I can verify each of those checks on the device. A cursory glance looks like permissions/ownership issues, or the directory is a simlink instead of real. Does this mean that deploying without Fast Deploy does not do the same check, as it seems deploying with or without Fast Deploy shouldn't affect the directory permissions or structure. When I get a chance to look more closely I will comment back here with my findings.

  11. dellis1972 commented on Mar 10, 2023

    @dellis1972
    Contributor

    @jlinker7

    Normal installaton does not use run-as. For fast deployment we have to use run-as to gain access to the internal files directory so we can place the changed assemblies there. This is what speeds up the dev process.

    A normal install the assemblies are packaged in the apk so it never hits this "path". But it does reduce development times since the apk has to be built and installed each time. With Fast dev we can just send the changed dll`s over and not touch the apk.

  12. jlinker7 commented on Mar 10, 2023

    @jlinker7
    Author

    @dellis1972 Ok, so since it doesn't use this directory when Fast Deployment is off, then it wouldn't run this check. Looking through the code I am leaning towards it being a permissions/ownership type issue. But have not quite figured out how to verify that.

  13. removed
    need-attentionA xamarin-android contributor needs to review
    on Mar 20, 2024
  14. dotnet-policy-service commented on Aug 13, 2026

    @dotnet-policy-service

    We suspect this issue is stale and no longer relevant. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will undo this process.

  15. dotnet-policy-service commented on Aug 27, 2026

    @dotnet-policy-service

    This issue will now be closed since it had been marked "possibly-stale" but received no further activity in the past 14 days. It is still possible to reopen or comment on the issue, but please note that the issue will be locked if it remains inactive for another 30 days.

  16. locked and limited conversation to collaborators on Sep 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Area: App+Library BuildIssues when building Library projects or Application projects.possibly-staleIssues that are potentially no longer relevant.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions