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

[Xamarin.Android.Build.Tasks] App Bundles & Google Play #3146

Merged
merged 1 commit into from
May 31, 2019

Conversation

jonathanpeppers
Copy link
Member

@Redth and I recently went through the process of submitting a
Xamarin.Android App Bundle to Google Play. He had an existing app,
while I tested the SmartHotel360 app.

Unfortunately, Google Play did not accept the bundle at first:

"The Android App Bundle was not signed."

But it was signed?

Looking at the build log, the build was running:

jarsigner.exe
    -keystore foo.keystore
    -storepass foo
    -keypass foo
    -digestalg SHA1
    -sigalg md5withRSA
    -signedjar bin\Release\com.foo.smarthotel-Signed.aab
    obj\Release\90\android\bin\com.foo.smarthotel.aab

For Android App Bundles, Google Play seems to no longer allow md5 or
SHA1 in favor of SHA-256.

For App Bundles to be accepted by Google Play, we had to run
jarsigner manually with:

jarsigner.exe
    -keystore foo.keystore
    -storepass foo
    -keypass foo
    -digestalg SHA-256
    -sigalg SHA256withRSA
    -signedjar bin\Release\com.foo.smarthotel-Signed.aab
    obj\Release\90\android\bin\com.foo.smarthotel.aab

To fix our MSBuild targets:

  • $(AndroidApkSigningAlgorithm) now has default values to support
    both .apk and .aab files
  • A new $(AndroidApkDigestAlgorithm) property was added with
    respective default values

This will give developers flexibility if these values need to be
changed from a .csproj in the future.

After this change, I was able to produce an App Bundle Google Play
will accept with:

msbuild foo.android.csproj /t:SignAndroidPackage /p:Configuration=Release /p:AndroidPackageFormat=aab

I also had the following properties configured in the .csproj:

<AndroidKeyStore>True</AndroidKeyStore>
<AndroidSigningKeyStore>foo.keystore</AndroidSigningKeyStore>
<AndroidSigningStorePass>foo</AndroidSigningStorePass>
<AndroidSigningKeyAlias>foo</AndroidSigningKeyAlias>
<AndroidSigningKeyPass>foo</AndroidSigningKeyPass>

foo.keystore I created by using the command from this doc:

https://docs.microsoft.com/en-us/xamarin/android/deploy-test/signing/manually-signing-the-apk

Results

@Redth's app had some good size improvements:

  • APK: 39.4MB
  • Android App Bundle: 23.3MB to 25.4MB

~35% savings!

@Redth and I recently went through the process of submitting a
Xamarin.Android App Bundle to Google Play. He had an existing app,
while I tested the SmartHotel360 app.

Unfortunately, Google Play did not accept the bundle at first:

    "The Android App Bundle was not signed."

But it *was* signed?

Looking at the build log, the build was running:

    jarsigner.exe
        -keystore foo.keystore
        -storepass foo
        -keypass foo
        -digestalg SHA1
        -sigalg md5withRSA
        -signedjar bin\Release\com.foo.smarthotel-Signed.aab
        obj\Release\90\android\bin\com.foo.smarthotel.aab

For Android App Bundles, Google Play seems to no longer allow md5 or
SHA1 in favor of SHA-256.

For App Bundles to be accepted by Google Play, we had to run
`jarsigner` manually with:

    jarsigner.exe
        -keystore foo.keystore
        -storepass foo
        -keypass foo
        -digestalg SHA-256
        -sigalg SHA256withRSA
        -signedjar bin\Release\com.foo.smarthotel-Signed.aab
        obj\Release\90\android\bin\com.foo.smarthotel.aab

To fix our MSBuild targets:

* `$(AndroidApkSigningAlgorithm)` now has default values to support
  both `.apk` and `.aab` files
* A new `$(AndroidApkDigestAlgorithm)` property was added with
  respective default values

This will give developers flexibility if these values need to be
changed from a `.csproj` in the future.

After this change, I was able to produce an App Bundle Google Play
will accept with:

    msbuild foo.android.csproj /t:SignAndroidPackage /p:Configuration=Release /p:AndroidPackageFormat=aab

I also had the following properties configured in the `.csproj`:

    <AndroidKeyStore>True</AndroidKeyStore>
    <AndroidSigningKeyStore>foo.keystore</AndroidSigningKeyStore>
    <AndroidSigningStorePass>foo</AndroidSigningStorePass>
    <AndroidSigningKeyAlias>foo</AndroidSigningKeyAlias>
    <AndroidSigningKeyPass>foo</AndroidSigningKeyPass>

`foo.keystore` I created by using the command from this doc:

https://docs.microsoft.com/en-us/xamarin/android/deploy-test/signing/manually-signing-the-apk

~~ Results ~~

@Redth's app had some good size improvements:

* APK: 39.4MB
* Android App Bundle: 23.3MB to 25.4MB

~35% savings!
@jonathanpeppers
Copy link
Member Author

The failure I see on macOS:

[2019-05-30T04:16:12.198Z]   mono --debug packages/NUnit.ConsoleRunner.3.9.0/tools/nunit3-console.exe  /Users/builder/jenkins/workspace/xamarin-android-pr-pipeline-release/xamarin-android/external/Java.Interop/build-tools/scripts/../../bin/TestRelease/Java.Interop.Export-Tests.dll  --result="TestResult-Java.Interop.Export-Tests.xml;format=nunit2" --output="bin/TestRelease/TestOutput-Java.Interop.Export-Tests.txt"
[2019-05-30T04:16:12.198Z]   NUnit Console Runner 3.9.0
[2019-05-30T04:16:12.198Z]   Copyright (c) 2018 Charlie Poole, Rob Prouse
[2019-05-30T04:16:12.198Z]   
[2019-05-30T04:16:12.492Z]   Runtime Environment
[2019-05-30T04:16:12.492Z]      OS Version: MacOSX 16.7.0.0 
[2019-05-30T04:16:12.492Z]     CLR Version: 4.0.30319.42000
[2019-05-30T04:16:12.492Z]   
[2019-05-30T04:16:12.492Z]   Test Files
[2019-05-30T04:16:12.492Z]       /Users/builder/jenkins/workspace/xamarin-android-pr-pipeline-release/xamarin-android/external/Java.Interop/build-tools/scripts/../../bin/TestRelease/Java.Interop.Export-Tests.dll
[2019-05-30T04:16:12.492Z]   
[2019-05-30T04:16:13.534Z]   WARNING in native method: JNI call made without checking exceptions when required to from CallStaticObjectMethod
[2019-05-30T04:16:13.830Z]   
[2019-05-30T04:16:13.830Z]   Run Settings
[2019-05-30T04:16:13.830Z]       DisposeRunners: True
[2019-05-30T04:16:13.830Z]       WorkDirectory: /Users/builder/jenkins/workspace/xamarin-android-pr-pipeline-release/xamarin-android/external/Java.Interop
[2019-05-30T04:16:13.830Z]       ImageRuntimeVersion: 4.0.30319
[2019-05-30T04:16:13.830Z]       ImageTargetFrameworkName: .NETFramework,Version=v4.6.1
[2019-05-30T04:16:13.830Z]       ImageRequiresX86: False
[2019-05-30T04:16:13.830Z]       ImageRequiresDefaultAppDomainAssemblyResolver: False
[2019-05-30T04:16:13.830Z]       NumberOfTestWorkers: 4
[2019-05-30T04:16:13.830Z]   
[2019-05-30T04:16:13.830Z]   Test Run Summary
[2019-05-30T04:16:13.830Z]     Overall result: Passed
[2019-05-30T04:16:13.830Z]     Test Count: 17, Passed: 17, Failed: 0, Warnings: 0, Inconclusive: 0, Skipped: 0
[2019-05-30T04:16:13.830Z]   
[2019-05-30T04:16:13.830Z]   =================================================================
[2019-05-30T04:16:13.830Z]   	Native Crash Reporting
[2019-05-30T04:16:13.830Z]   =================================================================
[2019-05-30T04:16:13.830Z]   Got a SIGSEGV while executing native code. This usually indicates
[2019-05-30T04:16:13.830Z]   a fatal error in the mono runtime or one of the native libraries 
[2019-05-30T04:16:13.830Z]   used by your application.
[2019-05-30T04:16:13.830Z]   =================================================================
[2019-05-30T04:16:13.830Z]   
[2019-05-30T04:16:13.830Z]   =================================================================
[2019-05-30T04:16:13.830Z]   	Native stacktrace:
[2019-05-30T04:16:13.830Z]   =================================================================
[2019-05-30T04:16:13.830Z]   	0x10ee36f38 - /Library/Frameworks/Mono.framework/Versions/Current/Commands/mono : mono_dump_native_crash_info
[2019-05-30T04:16:13.830Z]   	0x10edd1b15 - /Library/Frameworks/Mono.framework/Versions/Current/Commands/mono : mono_handle_native_crash
[2019-05-30T04:16:13.830Z]   	0x10ee312f6 - /Library/Frameworks/Mono.framework/Versions/Current/Commands/mono : altstack_handle_and_restore

I don't think this PR would cause that, and we can ignore it. These tests run on the deskop, changes to jarsigner couldn't affect it?

@jonpryor
Copy link
Member

changes to jarsigner couldn't affect it?

Correct, changes to jarsigner shouldn't impact Java.Interop.Export-Tests.dll.

Additionally, Java.Interop.Export-Tests.dll is "known flaky" for reasons nobody has investigated.

@jonpryor jonpryor merged commit 46858e4 into dotnet:master May 31, 2019
jonpryor pushed a commit that referenced this pull request May 31, 2019
@Redth and I recently went through the process of submitting a
Xamarin.Android App Bundle to Google Play.  He had an existing app,
while I tested the SmartHotel360 app.

Unfortunately, Google Play did not accept the bundle at first:

> The Android App Bundle was not signed.

But it *was* signed?

Looking at the build log, the build was running:

	jarsigner.exe ^
	    -keystore foo.keystore ^
	    -storepass foo ^
	    -keypass foo ^
	    -digestalg SHA1 ^
	    -sigalg md5withRSA ^
	    -signedjar bin\Release\com.foo.smarthotel-Signed.aab ^
	    obj\Release\90\android\bin\com.foo.smarthotel.aab

For Android App Bundles, Google Play seems to no longer allow md5 or
SHA1 in favor of SHA-256.

For App Bundles to be accepted by Google Play, we had to run
`jarsigner` manually with:

	jarsigner.exe ^
	    -keystore foo.keystore ^
	    -storepass foo ^
	    -keypass foo ^
	    -digestalg SHA-256 ^
	    -sigalg SHA256withRSA ^
	    -signedjar bin\Release\com.foo.smarthotel-Signed.aab ^
	    obj\Release\90\android\bin\com.foo.smarthotel.aab

To fix our MSBuild targets:

  * `$(AndroidApkSigningAlgorithm)` now has default values to support
    both `.apk` and `.aab` files
  * A new `$(AndroidApkDigestAlgorithm)` property was added with
    respective default values

This will give developers flexibility if these values need to be
changed from a `.csproj` in the future.

After this change, I was able to produce an App Bundle Google Play
will accept with:

	msbuild foo.android.csproj /t:SignAndroidPackage /p:Configuration=Release /p:AndroidPackageFormat=aab

I also had the following properties configured in the `.csproj`:

	<AndroidKeyStore>True</AndroidKeyStore>
	<AndroidSigningKeyStore>foo.keystore</AndroidSigningKeyStore>
	<AndroidSigningStorePass>foo</AndroidSigningStorePass>
	<AndroidSigningKeyAlias>foo</AndroidSigningKeyAlias>
	<AndroidSigningKeyPass>foo</AndroidSigningKeyPass>

`foo.keystore` I created by using the command from this doc:

	https://docs.microsoft.com/en-us/xamarin/android/deploy-test/signing/manually-signing-the-apk

~~ Results ~~

@Redth's app had some good size improvements:

  * APK: 39.4MB
  * Android App Bundle: 23.3MB to 25.4MB

A ~35% savings by using App Bundles!
@jonathanpeppers jonathanpeppers deleted the appbundle-googleplay branch July 8, 2019 20:09
@github-actions github-actions bot locked and limited conversation to collaborators Jan 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants