Search code examples
xamarinxamarin.formsxamarin.androidvisual-studio-app-centerandroid-app-bundle

AppCenter doesn't build an Android App Bundle (aab)


I have created a Xamarin Forms application and when it builds on my computer it generates an AAB. When I enabled signing then the AAB file is accepted by the Google Play store and can be published.

AppCenter has been set-up to build the same solution and I enabled the option to build an Android App Bundle (available via the wrench icon in the Build tab when you hover the branch): AAB option

It does seem to build the Android App Bundle when I look at the build logging:

...
##[section]Finishing: Build Xamarin.Android project
##[section]Starting: Sign Android App Bundle
==============================================================================
Task         : Android Signing
Description  : Sign and align Android APK files
Version      : 1.122.0
Author       : Microsoft Corporation
Help         : [More Information](https://go.microsoft.com/fwlink/?LinkID=613717)
==============================================================================
(node:1767) Warning: Use Cipheriv for counter mode of aes-256-ctr (repeated 11 times)
[command]/usr/bin/jarsigner -keystore /Users/runner/runners/2.170.0/work/1/s/.certs/keystore.jks -storepass *** -keypass *** -verbose -sigalg SHA256withRSA -digestalg SHA-256 -signedjar /Users/runner/runners/2.170.0/work/1/s/Example.Test.Android/bin/Release/com.example.test-Signed.aab /Users/runner/runners/2.170.0/work/1/s/Example.Test.Android/bin/Release/com.example.test-Signed.aab.unsigned ***
   adding: META-INF/CPANDROI.SF
   adding: META-INF/CPANDROI.RSA
  signing: BundleConfig.pb
... (removed a lot of files from the logging)
  signing: base/manifest/AndroidManifest.xml
  signing: base/native.pb
  signing: base/resources.pb
>>> Signer
    X.509, CN="REMOVED, O=REMOVED, L=REMOVED, S=REMOVED, C=NL"
    [trusted certificate]

jar signed.

Warning: 
The signer's certificate is self-signed.
[command]/Users/runner/Library/Android/sdk/build-tools/24.0.0/zipalign -v 4 /Users/runner/runners/2.170.0/work/1/s/Example.Test.Android/bin/Release/com.example.test-Signed.aab.unaligned /Users/runner/runners/2.170.0/work/1/s/Example.Test.Android/bin/Release/com.example.test-Signed.aab
Verifying alignment of /Users/runner/runners/2.170.0/work/1/s/Example.Test.Android/bin/Release/com.example.test-Signed.aab (4)...
      50 META-INF/MANIFEST.MF (OK - compressed)
   27883 META-INF/CPANDROI.SF (OK - compressed)
   56907 META-INF/CPANDROI.RSA (OK - compressed)
... (removed a lot of files from the logging)
13130472 base/manifest/AndroidManifest.xml (OK - compressed)
13132552 base/native.pb (OK - compressed)
13132664 base/resources.pb (OK - compressed)
Verification succesful
##[section]Finishing: Sign Android App Bundle
##[section]Starting: Sign APK

I guess the build and siging is all fine, but I guess something goes wrong during the Copy bundle files to staging stage. Before that the Copy build files to staging stage runs and it shows the following output:

##[section]Starting: Copy build files to staging
==============================================================================
Task         : Command Line
Description  : Run a command line with arguments
Version      : 1.1.3
Author       : Microsoft Corporation
Help         : [More Information](https://go.microsoft.com/fwlink/?LinkID=613735)
==============================================================================
[command]/bin/bash -c /usr/bin/find . -path '*/bin/*' ! -path '*/obj/*' -type f ! -name '*-Signed.apk' ! -name '*-armeabi-v7a.apk' ! -name '*-arm64-v8a.apk' ! -name '*-x86.apk' ! -name '*-x86_64.apk' -name '*.apk' -print0 | xargs -0 stat -f "%m %N" | sort -rn | head -1 | cut -f2- -d" " | xargs -L 1 -I{} cp -R -v {} /Users/runner/runners/2.170.0/work/1/a/build
(node:1777) Warning: Use Cipheriv for counter mode of aes-256-ctr (11 times)
./CrossPoint.Xpact.Android/bin/Release/com.example.test.apk -> /Users/runner/runners/2.170.0/work/1/a/build/com.example.test.apk
##[section]Finishing: Copy build files to staging

It seems to copy the APK to the staging folder and then it tries to do the same for the Android App Bundle (AAB):

##[section]Starting: Copy bundle files to staging
==============================================================================
Task         : Command Line
Description  : Run a command line with arguments
Version      : 1.1.3
Author       : Microsoft Corporation
Help         : [More Information](https://go.microsoft.com/fwlink/?LinkID=613735)
==============================================================================
[command]/bin/bash -c mkdir -p /Users/runner/runners/2.170.0/work/1/a/bundle && ls -LR && /usr/bin/find . -path '*/obj/*' -type f -name '*.aab' -print0 | xargs -0 stat -f "%m %N" | sort -rn | head -1 | cut -f2- -d" " | xargs -L 1 -I{} cp -R -v {} /Users/runner/runners/2.170.0/work/1/a/bundle
(node:1787) Warning: Use Cipheriv for counter mode of aes-256-ctr (11 times)
Example.Common.DataTypes
Example.Identity.Common
Example.Test
Example.Test.Android
Example.Test.UWP
Example.Test.iOS
Example.Test.sln
Example.ruleset

./Example.Common.DataTypes:
ExampleType.cs
Example.Common.DataTypes.csproj
AnotherType.cs
bin
obj

... (whole lot of files removed from this logging)

./Example.Test.iOS/obj:
Example.Test.iOS.csproj.nuget.dgspec.json
Example.Test.iOS.csproj.nuget.g.props
Example.Test.iOS.csproj.nuget.g.targets
project.assets.json
project.nuget.cache
##[section]Finishing: Copy bundle files to staging

It seems to dump all the files, but it doesn't copy the actual AAB file. I'm not sure why it cannot find the AAB file, because it did seem to create the AAB file in the obj folder. This was shown during the Build bundle from Xamarin.Android project stage:

_BuildApkEmbed:
  /Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/bin/java -Xmx1G -jar /Library/Frameworks/Xamarin.Android.framework/Libraries/xbuild/Xamarin/Android/bundletool.jar build-bundle --modules obj/Release/android/bin/base.zip --output obj/Release/android/bin/com.example.test.aab --config /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/tmpb29e9af.tmp 
_CopyPackage:
  Copying file from "/Users/runner/runners/2.170.0/work/1/s/Example.Test.Android/obj/Release/android/bin/com.example.test.aab" to "/Users/runner/runners/2.170.0/work/1/s/Example.Test.Android/bin/Release/com.example.test.aab".
_CreateAndroidDebugSigningKey:
  /Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/bin/keytool -genkeypair -alias androiddebugkey -storepass android -keypass android -keystore "/Users/runner/.local/share/Xamarin/Mono for Android/debug.keystore" -dname "CN=Android Debug,O=Android,C=US" -keyalg RSA -validity 10950 -storetype pkcs12 
_ResolveAndroidSigningKey:
  Creating "obj/Release/android_debug_keystore.flag" because "AlwaysCreate" was specified.
_Sign:
  /Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/bin/jarsigner -keystore "/Users/runner/.local/share/Xamarin/Mono for Android/debug.keystore" -storepass android -keypass android -digestalg SHA-256 -sigalg SHA256withRSA -signedjar bin/Release/com.example.test-Signed.aab /Users/runner/runners/2.170.0/work/1/s/Example.Test.Android/obj/Release/android/bin/com.example.test.aab androiddebugkey 
  jar signed.
  The signer's certificate is self-signed.
  Signed android package ''
Done Building Project "/Users/runner/runners/2.170.0/work/1/s/Example.Test.Android/Example.Test.Android.csproj" (PackageForAndroid;SignAndroidPackage target(s)).

Build succeeded.

I don't know what could be wrong and why that last steps dumps all my files, instead of copying the AAB to the staging folder.


Solution

  • AppCenter support confirmed the issue and filed a bug-report. It only occurs with Xamarin 10.3 and downgrading to Xamarin 10.2 indeed solves this issue. At June 16th, 2020 I got an e-mail that the bug has been fixed and it now also works with Xamarin 10.3 again.