Creating an asset pack in Maui causes deployment error

62 Views Asked by At

I'm developing a multi-platform Maui app which contains a quantity of media items that will take it above the size limit for the Play Store. In order to solve this problem, I'm doing Android builds with the media separated into an install-time asset feature.

I have an MSBuild process in the .csproj file which replicates the steps shown in this answer and I have also referenced the (rather complicated) build process in this project.

These samples contradict each other in a couple of places in what they do with the ApplicationID and whether or not a hex PackageID is important, but I have tried several variations with no luck.

Opening the resulting release .aab as a zip file demonstrates that all the data is there, including all the media files in an assetsfeature subfolder, but when I try to start the app in the emulator, I get the following output:

C:\Program Files (x86)\Android\openjdk\jdk-17.0.8.101-hotspot\bin\jarsigner.exe -keystore "C:\Users\Bob\AppData\Local\Xamarin\Mono for Android\debug.keystore" -storepass android -keypass android -digestalg SHA-256 -sigalg SHA256withRSA -signedjar bin\Release\net7.0-android\com.bob_sammers.SampleApp-Signed.aab obj\Release\net7.0-android\android\bin\com.bob_sammers.SampleApp.aab  androiddebugkey 
jar signed.
The signer's certificate is self-signed.
Signed android package ''
Deleting file "M:\repos\SampleApp\SampleApp\bin\Release\net7.0-android\com.bob_sammers.SampleApp-Signed.apk".
Deleting file "obj\Release\net7.0-android\android\bin\com.bob_sammers.SampleApp-Universal.apks".
C:\Program Files (x86)\Android\openjdk\jdk-17.0.8.101-hotspot\bin\java.exe -Xmx1G -jar "C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\33.0.95\tools\bundletool.jar" build-apks --mode universal --bundle obj\Release\net7.0-android\android\bin\com.bob_sammers.SampleApp.aab --output obj\Release\net7.0-android\android\bin\com.bob_sammers.SampleApp-Universal.apks --aapt2 "C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\33.0.95\tools\aapt2.exe" --ks "C:\Users\Bob\AppData\Local\Xamarin\Mono for Android\debug.keystore" --ks-key-alias androiddebugkey --key-pass pass:android --ks-pass pass:android 
C:\Program Files (x86)\Android\openjdk\jdk-17.0.8.101-hotspot\bin\java.exe -Xmx1G -jar "C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\33.0.95\tools\bundletool.jar" build-apks --connected-device --mode default --adb "C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe" --device-id emulator-5554 --bundle obj\Release\net7.0-android\android\bin\com.bob_sammers.SampleApp.aab --output obj\Release\net7.0-android\android\bin\com.bob_sammers.SampleApp.apks --aapt2 "C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\33.0.95\tools\aapt2.exe" --ks "C:\Users\Bob\AppData\Local\Xamarin\Mono for Android\debug.keystore" --ks-key-alias androiddebugkey --key-pass pass:android --ks-pass pass:android 
Touching "obj\Release\net7.0-android\android\bin\com.bob_sammers.SampleApp.apks".
"C:\Program Files (x86)\Android\android-sdk\platform-tools\adb" -s emulator-5554 uninstall -k "com.bob_sammers.SampleApp"
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'.
The command ""C:\Program Files (x86)\Android\android-sdk\platform-tools\adb" -s emulator-5554 uninstall -k "com.bob_sammers.SampleApp"" exited with code 1.
The previous error was converted to a warning because the task was called with ContinueOnError=true.
Build continuing because "ContinueOnError" on the task "Exec" is set to "True".
C:\Program Files (x86)\Android\openjdk\jdk-17.0.8.101-hotspot\bin\java.exe -Xmx1G -jar "C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\33.0.95\tools\bundletool.jar" install-apks --apks obj\Release\net7.0-android\android\bin\com.bob_sammers.SampleApp.apks --adb "C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe" --device-id emulator-5554 --allow-downgrade --modules _ALL_ 
The APKs have been extracted in the directory: C:\Users\Bob\AppData\Local\Temp\7591497133595311945
Installation of the app failed.
com.android.tools.build.bundletool.model.exceptions.CommandExecutionException: Installation of the app failed.
    at com.android.tools.build.bundletool.model.exceptions.InternalExceptionBuilder.build(InternalExceptionBuilder.java:57)
    at com.android.tools.build.bundletool.device.DdmlibDevice.installApks(DdmlibDevice.java:192)
    at com.android.tools.build.bundletool.commands.InstallApksCommand.lambda$execute$1(InstallApksCommand.java:212)
    at com.android.tools.build.bundletool.device.AdbRunner.run(AdbRunner.java:81)
    at com.android.tools.build.bundletool.device.AdbRunner.run(AdbRunner.java:61)
    at com.android.tools.build.bundletool.commands.InstallApksCommand.execute(InstallApksCommand.java:211)
    at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:91)
    at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:49)
Caused by: com.android.ddmlib.InstallException: Failed to commit install session 1664841885 with command cmd package install-commit 1664841885. Error: INSTALL_FAILED_INVALID_APK: /data/app/vmdl1664841885.tmp/4_assetsfeature-master package com.sampleapp.SampleApp inconsistent with com.bob_sammers.SampleApp
    at com.android.ddmlib.SplitApkInstallerBase.installCommit(SplitApkInstallerBase.java:99)
    at com.android.ddmlib.SplitApkInstaller.install(SplitApkInstaller.java:85)
    at com.android.ddmlib.internal.DeviceImpl.installPackages(DeviceImpl.java:1166)
    at com.android.tools.build.bundletool.device.DdmlibDevice.installApks(DdmlibDevice.java:176)
    ... 6 more
Done building project "SampleApp.csproj" -- FAILED.
Build FAILED.
4>Deployment failed to pixel_4a_-_api_30.

INSTALL_FAILED_INVALID_APK suggests I'm doing something wrong creating the asset feature, but the error message is not very descriptive and all the Android documentation I can find talks about how to use gradle to build bundles, rather than actually explaining what is supposed to happen, so its hard to use it as reference material.

How can I debug this error? Is there a way of upping the verbosity of the output? Have I done something stupid (such as invalid characters, naming rules, etc.)?

0

There are 0 best solutions below