Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
brendanzagaeski opened this issue Mar 21, 2020 · 6 comments · Fixed by #4543
Assignees
Labels
Area: App+Library Build Issues when building Library projects or Application projects.

Comments

@brendanzagaeski
Copy link
Contributor

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]
@Johan-dutoit
Copy link

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.

@brendanzagaeski
Copy link
Contributor Author

@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!

@ctinnell
Copy link

ctinnell commented Apr 6, 2020

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

@brendanzagaeski
Copy link
Contributor Author

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

jonathanpeppers added a commit to jonathanpeppers/xamarin-android that referenced this issue Apr 8, 2020
Fixes: dotnet#4439

If you build a project with `AndroidDexTool=invalid`, you end up with
an APK file that is missing a `classes.dex`. We don't emit an error,
and you won't actually know anything is wrong until going to install
the APK.

If someone did this on accident, I think we can just default
`AndroidDexTool=d8` *unless* it is set to `dx`.

I updated a test for this.
dellis1972 pushed a commit that referenced this issue Apr 9, 2020
Fixes: #4439

If you build a project with `AndroidDexTool=invalid`, you end up with
an APK file that is missing a `classes.dex`. We don't emit an error,
and you won't actually know anything is wrong until going to install
the APK.

If someone did this on accident, I think we can just default
`AndroidDexTool=d8` *unless* it is set to `dx`.

I updated a test for this.
jonpryor pushed a commit that referenced this issue Apr 17, 2020
Fixes: #4439

If you build a project with `AndroidDexTool=invalid`, you end up with
an APK file that is missing a `classes.dex`. We don't emit an error,
and you won't actually know anything is wrong until going to install
the APK.

If someone did this on accident, I think we can just default
`AndroidDexTool=d8` *unless* it is set to `dx`.

I updated a test for this.
@brendanzagaeski
Copy link
Contributor Author

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.

@brendanzagaeski
Copy link
Contributor Author

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.

@ghost ghost locked as resolved and limited conversation to collaborators Jun 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Area: App+Library Build Issues when building Library projects or Application projects.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants