Skip to content

Invalid values of $(AndroidDexTool) result in misleading InstallFailedException during deployment instead of an error during the build #4439

Closed

Description

@brendanzagaeski

Context: #4437 (comment)

Steps to reproduce

  1. Create a new Single View Android app.
  2. msbuild -restore -p:AndroidDexTool=invalid -t:Install

Expected behavior

Two possibilities are:

(a) The Build targets fail because $(AndroidDexTool) is set to an invalid value.

or

(b) The build ignores the invalid value of $(AndroidDexTool) and uses whatever the default would be (currently d8).

Actual behavior

The Build targets complete successfully, but they skip doing any DEX compilation:

Target "_CompileToDalvikWithDx" skipped, due to false condition; ( '$(AndroidDexTool)' == 'dx' ) was evaluated as ( 'invalid' == 'dx' ).
Target "_CompileToDalvikWithD8" skipped, due to false condition; ( '$(AndroidDexTool)' == 'd8' ) was evaluated as ( 'invalid' == 'd8' ).
Target "_CompileDex: (TargetId:166)" in file "C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets" from project "C:\Temp\SingleViewApp1.Droid\SingleViewApp1.Droid\SingleViewApp1.Droid.csproj" (target "CoreBuild" depends on it):
Done building target "_CompileDex" in project "SingleViewApp1.Droid.csproj".: (TargetId:166)

It's not until the InstallPackageAssemblies task that a failure appears:

Xamarin.Android.Common.Debugging.targets(616,2): error ADB0010:  Deployment failed
Xamarin.Android.Common.Debugging.targets(616,2): error ADB0010: Mono.AndroidTools.InstallFailedException: Failure [INSTALL_FAILED_INVALID_APK: Package couldn't be installed in /data/app/com.companyname.singleviewapp1.droid-vUKFwUGHx8l9Mn56vd6dqg==: Package /data/app/com.companyname.singleviewapp1.droid-vUKFwUGHx8l9Mn56vd6dqg==/base.apk code is missing]

Activity

  1. added
    Area: App+Library Build
    on Mar 21, 2020
  2. Johan-dutoit commented on Mar 27, 2020

    @Johan-dutoit

    FWIW I updated to the latest version (without changing any settings) and got the /base.apk code is missing error. Downgrading Xamarin.Android to 10.1.3.7 from 10.2.0.100 allowed my project to build and run again.

  3. brendanzagaeski commented on Mar 27, 2020

    @brendanzagaeski
    ContributorAuthor

    @Johan-dutoit, thanks for the info! That sounds like it would be a different behavior compared to this particular issue. This issue is only about the case where the AndroidDexTool MSBuild property is explicitly set to an invalid value.

    If by chance you might have time to update again temporarily to version 10.2.0.100 so that you can collect the diagnostic build output from your build that's giving you the bad results, then if you could attach that build output on a new issue so the team can take a look, that would be perfect. Thanks in advance!

  4. ctinnell commented on Apr 6, 2020

    @ctinnell

    I am getting this error also. Is the recommended solution to downgrade Xamarin.Android?

  5. brendanzagaeski commented on Apr 6, 2020

    @brendanzagaeski
    ContributorAuthor

    @ctinnell, if you're building on macOS, it's likely you're seeing #4478. There's a candidate workaround mentioned there #4478 (comment).

  6. brendanzagaeski commented on May 20, 2020

    @brendanzagaeski
    ContributorAuthor

    Release status update

    A new Preview version has now been published that includes the fix for this item. The fix is not yet included in a Release version. I will update this again when a Release version is available that includes the fix.

    Fix included in Xamarin.Android 10.3.99.230.

    Fix included on Windows in Visual Studio 2019 version 16.7 Preview 1. To try the Preview version that includes the fix, check for the latest updates in Visual Studio Preview.

    Fix included on macOS in Visual Studio 2019 for Mac version 8.7 Preview 1. To try the Preview version that includes the fix, check for the latest updates on the Preview updater channel.

  7. brendanzagaeski commented on Aug 5, 2020

    @brendanzagaeski
    ContributorAuthor

    Release status update

    A new Release version of Xamarin.Android has now been published that includes the fix for this item.

    Fix included in Xamarin.Android SDK version 11.0.0.3.

    Fix included on Windows in Visual Studio 2019 version 16.7. To get the new version that includes the fix, check for the latest updates or install the most recent release from https://visualstudio.microsoft.com/downloads/.

    Fix included on macOS in Visual Studio 2019 for Mac version 8.7. To get the new version that includes the fix, check for the latest updates on the Stable updater channel.

  8. ghost locked as resolved and limited conversation to collaborators on Jun 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Area: App+Library Build

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions