Commit 1d7092d
authored
[Xamarin.Android.Build.Tasks] Fix issue where app will not install (dotnet#7719)
Fixes: https://dev.azure.com/DevDiv/DevDiv/_workitems/edit/1398544
It is quite common for users to switch between Debug and Release
configurations in order to test the app. However, if the `Release`
build is using a custom signing keystore you will generally see this
warning and error:
warning MSB6006: "adb" exited with code 1.
[BT : 1.8.1] error : Installation of the app failed.
This is not entirely helpful, since you often need to dig into the
diagnostic log to figure out what the actual issue is.
This warning is produced when we try to run
`adb uninstall -k @PACKAGE_NAME@`:
adb uninstall -k com.xamarin.example
The -k option uninstalls the application while retaining the data/cache.
At the moment, there is no way to remove the remaining data.
You will have to reinstall the application with the same signature, and fully uninstall it.
If you truly wish to continue, execute 'adb shell cmd package uninstall -k'.
We are not entirely sure why the application gets into this state,
but once it does you have to completely uninstall it. We currently
ignore this error but that then results in the following error:
Error: INSTALL_FAILED_UPDATE_INCOMPATIBLE: Existing package com.xamarin.example signatures do not match newer version; ignoring!
This is because the apps used different signing keystores. As a
result they are incompatible. The only option once you get this issue
is to uninstall the app manually and try again. However the error
messaging is not obvious so users generally have no idea what to do.
Fix a few things in this area. Introduce a new `<AndroidAdb/>` task
which is responsible for making the calls to `adb`. We previously used
`<Exec/>`, which made it hard to make any customizations around error
messaging. We will check the result of the `<AndroidAdb/>` task when
calling `adb uninstall -k @PACKAGE_NAME@` and if the output contains
`adb shell cmd package uninstall` then we will automatically call
`adb shell cmd package uninstall @PACKAGE_NAME@`. This will completely
remove the app from the device and will allow the later `bundletool`
invocation to work.
We have also updated `<InstallApkSet/>` to look for error messages from
`bundletool` and report them, so users will get better information.
We now generate error messages like:
[BT : 1.8.1] error : Installation of the app failed.
obj/Release/android/bin/com.xamarin.toggledebugreleasewithsigning.apks : java error BT0000: The APKs have been extracted in the directory: /var/folders/5p/10yqy2kx6r9dnmnxh_nt6s0r0000gn/T/1389125984700138671
obj/Release/android/bin/com.xamarin.toggledebugreleasewithsigning.apks : java error BT0000: 01:54:24 E/SplitApkInstallerBase: Failed to commit install session 1426763565 with command cmd package install-commit 1426763565. Error: INSTALL_FAILED_UPDATE_INCOMPATIBLE: Existing package com.xamarin.toggledebugreleasewithsigning signatures do not match newer version; ignoring!
obj/Release/android/bin/com.xamarin.toggledebugreleasewithsigning.apks : java error BT0000: [BT:1.8.1] Error: Installation of the app failed.
obj/Release/android/bin/com.xamarin.toggledebugreleasewithsigning.apks : java error BT0000: com.android.tools.build.bundletool.model.exceptions.CommandExecutionException
obj/Release/android/bin/com.xamarin.toggledebugreleasewithsigning.apks : java error BT0000: Installation of the app failed.
obj/Release/android/bin/com.xamarin.toggledebugreleasewithsigning.apks : java error BT0000: at com.android.tools.build.bundletool.model.exceptions.InternalExceptionBuilder.build(InternalExceptionBuilder.java:57)
obj/Release/android/bin/com.xamarin.toggledebugreleasewithsigning.apks : java error BT0000: at com.android.tools.build.bundletool.device.DdmlibDevice.installApks(DdmlibDevice.java:192)
obj/Release/android/bin/com.xamarin.toggledebugreleasewithsigning.apks : java error BT0000: at com.android.tools.build.bundletool.commands.InstallApksCommand.lambda$execute$2(InstallApksCommand.java:214)
obj/Release/android/bin/com.xamarin.toggledebugreleasewithsigning.apks : java error BT0000: at com.android.tools.build.bundletool.device.AdbRunner.run(AdbRunner.java:81)
obj/Release/android/bin/com.xamarin.toggledebugreleasewithsigning.apks : java error BT0000: at com.android.tools.build.bundletool.device.AdbRunner.run(AdbRunner.java:43)
obj/Release/android/bin/com.xamarin.toggledebugreleasewithsigning.apks : java error BT0000: at com.android.tools.build.bundletool.commands.InstallApksCommand.execute(InstallApksCommand.java:214)
obj/Release/android/bin/com.xamarin.toggledebugreleasewithsigning.apks : java error BT0000: at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:91)
obj/Release/android/bin/com.xamarin.toggledebugreleasewithsigning.apks : java error BT0000: at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:49)
obj/Release/android/bin/com.xamarin.toggledebugreleasewithsigning.apks : java error BT0000: Caused by: com.android.ddmlib.InstallException: Failed to commit install session 1426763565 with command cmd package install-commit 1426763565. Error: INSTALL_FAILED_UPDATE_INCOMPATIBLE: Existing package com.xamarin.toggledebugreleasewithsigning signatures do not match newer version; ignoring!
obj/Release/android/bin/com.xamarin.toggledebugreleasewithsigning.apks : java error BT0000: at com.android.ddmlib.SplitApkInstallerBase.installCommit(SplitApkInstallerBase.java:99)
obj/Release/android/bin/com.xamarin.toggledebugreleasewithsigning.apks : java error BT0000: at com.android.ddmlib.SplitApkInstaller.install(SplitApkInstaller.java:85)
obj/Release/android/bin/com.xamarin.toggledebugreleasewithsigning.apks : java error BT0000: at com.android.ddmlib.internal.DeviceImpl.installPackages(DeviceImpl.java:1166)
obj/Release/android/bin/com.xamarin.toggledebugreleasewithsigning.apks : java error BT0000: at com.android.tools.build.bundletool.device.DdmlibDevice.installApks(DdmlibDevice.java:176)
obj/Release/android/bin/com.xamarin.toggledebugreleasewithsigning.apks : java error BT0000: ... 6 more
Unit Test are added.1 parent 35db527 commit 1d7092d
File tree
5 files changed
+186
-23
lines changed- src/Xamarin.Android.Build.Tasks
- Tasks
- tests/MSBuildDeviceIntegration/Tests
5 files changed
+186
-23
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
| 5 | + | |
| 6 | + | |
4 | 7 | | |
5 | 8 | | |
6 | 9 | | |
| |||
14 | 17 | | |
15 | 18 | | |
16 | 19 | | |
| 20 | + | |
| 21 | + | |
17 | 22 | | |
18 | 23 | | |
19 | 24 | | |
| |||
37 | 42 | | |
38 | 43 | | |
39 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
40 | 68 | | |
41 | 69 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
131 | | - | |
| 131 | + | |
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
141 | | - | |
| 141 | + | |
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| |||
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
200 | 217 | | |
201 | 218 | | |
202 | 219 | | |
| |||
207 | 224 | | |
208 | 225 | | |
209 | 226 | | |
210 | | - | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
211 | 232 | | |
212 | 233 | | |
213 | 234 | | |
| |||
Lines changed: 32 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
2658 | 2659 | | |
2659 | 2660 | | |
2660 | 2661 | | |
2661 | | - | |
2662 | | - | |
2663 | | - | |
2664 | | - | |
2665 | | - | |
2666 | | - | |
2667 | | - | |
2668 | | - | |
2669 | | - | |
2670 | | - | |
2671 | | - | |
2672 | | - | |
2673 | | - | |
2674 | | - | |
2675 | | - | |
| 2662 | + | |
| 2663 | + | |
| 2664 | + | |
| 2665 | + | |
| 2666 | + | |
| 2667 | + | |
2676 | 2668 | | |
2677 | 2669 | | |
2678 | 2670 | | |
| |||
2704 | 2696 | | |
2705 | 2697 | | |
2706 | 2698 | | |
2707 | | - | |
2708 | | - | |
2709 | | - | |
2710 | | - | |
| 2699 | + | |
2711 | 2700 | | |
| 2701 | + | |
| 2702 | + | |
| 2703 | + | |
| 2704 | + | |
| 2705 | + | |
| 2706 | + | |
| 2707 | + | |
| 2708 | + | |
| 2709 | + | |
| 2710 | + | |
| 2711 | + | |
| 2712 | + | |
| 2713 | + | |
| 2714 | + | |
| 2715 | + | |
| 2716 | + | |
| 2717 | + | |
2712 | 2718 | | |
2713 | 2719 | | |
2714 | 2720 | | |
| |||
2728 | 2734 | | |
2729 | 2735 | | |
2730 | 2736 | | |
2731 | | - | |
| 2737 | + | |
| 2738 | + | |
| 2739 | + | |
| 2740 | + | |
| 2741 | + | |
| 2742 | + | |
| 2743 | + | |
2732 | 2744 | | |
2733 | 2745 | | |
2734 | 2746 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
290 | 290 | | |
291 | 291 | | |
292 | 292 | | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
293 | 338 | | |
294 | 339 | | |
295 | 340 | | |
| |||
0 commit comments