-
Notifications
You must be signed in to change notification settings - Fork 525
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
[One .NET] select defaults for App Bundles #6087
Conversation
Ok , huge number of test failures because we are producing an |
...id.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.DefaultProperties.targets
Outdated
Show resolved
Hide resolved
Conceptually, Is there a reason to not go with |
@dellis1972 addressed this on #6059:
I wonder how much larger it would be, though…. Could we make it work with an "inner build"-like system? |
Additionally, the way these properties are worded implies that they're commutative; these should be the same: <!-- 1 -->
<AndroidPackageFormat>apk</AndroidPackageFormat>
<AndroidAdditionalPackageFormats>aab</AndroidAdditionalPackageFormats>
<!-- 2 -->
<AndroidPackageFormat>aab</AndroidPackageFormat>
<AndroidAdditionalPackageFormats>apk</AndroidAdditionalPackageFormats> I don't think they are commutative, though, at least not based on the current <Target Name="_CreateUniversalApkFromBundle"
Condition=" '$(AndroidPackageFormat)' == 'aab' And $(AndroidAdditionalPackageFormats.Contains('apk')) " |
We have many MSBuild Properties which rely on an it being one or the other for example (and this is just a small example).
Also take a look at our current signing system. https://github.com/xamarin/xamarin-android/blob/main/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets#L2287 Its pretty messy. and depends on if we are signing with ApkSigner or not. Now I'm not saying that we don't need to rework this because its clear that we do. However, the approach in this PR seemed like the most straight forward given the time constraints for this feature. Tacking on the additional apk generation for this specific case i.e when the user is in release mode and are generating an As we talked about on the meeting, we could just make
my concern with inner builds are performance, the fact that we (in .net 6) have to do an inner build for each abi already, adding yet another one for packaging/signing, then in the future more for Dynamic Features. I'd rather avoid those if possible. But it might well be our only option. So I guess the question really is, how quickly do we want this? Should we do it fast or right? |
Oh and all the unit tests are going to have to change as well. Most are hardcoded to look for |
@dellis1972: what I think we should do is "split the difference", somewhat:
This should allow a more "future-proof" "public API" in the form of |
4f4872f
to
03c0fbf
Compare
src/Xamarin.Android.Build.Tasks/Microsoft.NET.Sdk.Android/WorkloadManifest.targets
Outdated
Show resolved
Hide resolved
src/Xamarin.Android.Build.Tasks/Microsoft.NET.Sdk.Android/WorkloadManifest.targets
Outdated
Show resolved
Hide resolved
doh. So .. we have a slight problem here. bundle-tool does NOT support the
So we effectively can't use |
27efea7
to
1c18e28
Compare
e405fed
to
e2af22a
Compare
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Android/AndroidSdkResolver.cs
Show resolved
Hide resolved
Fixes dotnet#6059 Users will probably want to target more than one App Store. Google is now requiring the `aab` format for Google Play Store uploads. Unfortunately this package format is not compatible with other stores. Users can build their app twice producing an `aab` for one build and `apk` for another, but we should try to make this a bit easier. `bundle-tool` has the ability to create a universal apk from the `aab` file. So lets make use of that to generate one along side the `aab`. We are introducing a new property `AndroidPackageFormats`. Under .net 6 this will have a value of `aab;apk` by default for Release builds, for Legacy it will be empty. If `AndroidPackageFormats` is specified and `AndroidPackageFormat` is empty we will use the values in `AndroidPackageFormats` to populate `AndroidPackageFormat`. If none of these values are provided the `AndroidPackageFormat` will still default to `apk` as it has always done. The following setting will produce both an `aab` and an `apk`. ``` <PropertyGroup> <AndroidPackageFormats>aab;apk</AndroidPackageFormats> </PropertyGroup> ``` This will produce just an `aab` ``` <PropertyGroup> <AndroidPackageFormats>aab</AndroidPackageFormats> </PropertyGroup> ``` and this will produce just an `apk` ``` <PropertyGroup> <AndroidPackageFormats>apk</AndroidPackageFormats> </PropertyGroup> ``` For .net 6 users this will be enabled by default for Release builds. For legacy users they will need to define the property manually.
Commit message for review: Fixes: https://github.com/xamarin/xamarin-android/issues/6059
Context: https://android-developers.googleblog.com/2020/11/new-android-app-bundle-and-target-api.html
Context: https://blogs.windows.com/windowsexperience/2021/06/24/building-a-new-open-microsoft-store-on-windows-11/
Context: https://developer.amazon.com/blogs/appstore/post/50b1ca0f-bbec-48ec-9eea-3c395efb8f9f/amazon-appstore-to-support-android-app-bundle
The Google Play Store requires Android App Bundles (`.aab` files) for
all new apps as of August 2021, and for all apps in November 2021.
Meanwhile, Microsoft has announced that Windows 11 will support
running Android apps and installing them via the Amazon Appstore,
which currently only supports `.apk` file uploads.
While a Xamarin.Android user could build their app twice, changing
the [`$(AndroidPackageFormat)`][0] between each build, we feel it
would be "better" -- faster, more convenient -- if a single
`SignAndroidPackage` target invocation could produce *both* `.aab`
and `.apk` outputs.
[`bundletool.jar`][1] has the ability to create a universal `.apk`
from the `.aab` file.
Introduce support for a new `$(AndroidPackageFormats)` (plural)
MSBuild property, which is a `;`-delimited sequence of
`$(AndroidPackageFormat)` values to produce as build outputs.
For example, if `$(AndroidPackageFormats)`=`aab;apk`, then *both*
`.aab` and `.apk` outputs will be produced.
<PropertyGroup>
<AndroidPackageFormats>aab;apk</AndroidPackageFormats>
</PropertyGroup>
The `.apk` output will be generated from the `.aab` file, ensuring
consistency.
In .NET 6 Debug configuration builds, `$(AndroidPackageFormats)` will
default to `.apk`, as this behaves better with Fast Deployment and
developer productivity.
In .NET 6 Release configuration builds, `$(AndroidPackageFormats)`
will default to `aab;apk`, i.e. both `.aab` and `.apk` files will be
produced by default.
In Legacy Xamarin.Android, `$(AndroidPackageFormats)` will not be
set, and `$(AndroidPackageFormat)` will continue to default to `.apk`,
meaning that only `.apk` files will be produced (this week…).
[0]: https://docs.microsoft.com/en-us/xamarin/android/deploy-test/building-apps/build-properties#androidpackageformat
[1]: https://developer.android.com/studio/command-line/bundletool |
Fixes: #6059 Context: https://android-developers.googleblog.com/2020/11/new-android-app-bundle-and-target-api.html Context: https://blogs.windows.com/windowsexperience/2021/06/24/building-a-new-open-microsoft-store-on-windows-11/ Context: https://developer.amazon.com/blogs/appstore/post/50b1ca0f-bbec-48ec-9eea-3c395efb8f9f/amazon-appstore-to-support-android-app-bundle The Google Play Store requires Android App Bundles (`.aab` files) for all new apps as of August 2021, and for all apps in November 2021. Meanwhile, Microsoft has announced that Windows 11 will support running Android apps and installing them via the Amazon Appstore, which currently only supports `.apk` file uploads. While a Xamarin.Android user could build their app twice, changing the [`$(AndroidPackageFormat)`][0] between each build, we feel it would be "better" -- faster, more convenient -- if a single `SignAndroidPackage` target invocation could produce *both* `.aab` and `.apk` outputs. [`bundletool.jar`][1] has the ability to create a universal `.apk` from the `.aab` file. Introduce support for a new `$(AndroidPackageFormats)` (plural) MSBuild property, which is a `;`-delimited sequence of `$(AndroidPackageFormat)` values to produce as build outputs. For example, if `$(AndroidPackageFormats)`=`aab;apk`, then *both* `.aab` and `.apk` outputs will be produced. <PropertyGroup> <AndroidPackageFormats>aab;apk</AndroidPackageFormats> </PropertyGroup> The `.apk` output will be generated from the `.aab` file, ensuring consistency. In .NET 6 Debug configuration builds, `$(AndroidPackageFormats)` will default to `.apk`, as this behaves better with Fast Deployment and developer productivity. In .NET 6 Release configuration builds, `$(AndroidPackageFormats)` will default to `aab;apk`, i.e. both `.aab` and `.apk` files will be produced by default. In Legacy Xamarin.Android, `$(AndroidPackageFormats)` will not be set, and `$(AndroidPackageFormat)` will continue to default to `.apk`, meaning that only `.apk` files will be produced (this week…). [0]: https://docs.microsoft.com/en-us/xamarin/android/deploy-test/building-apps/build-properties#androidpackageformat [1]: https://developer.android.com/studio/command-line/bundletool
Fixes #6059
Users will probably want to target more than one App Store. Google is now requiring the
aab
format forGoogle Play Store uploads. Unfortunately this package format is not compatible with other stores.
Users can build their app twice producing an
aab
for one build andapk
for another, but we shouldtry to make this a bit easier.
bundle-tool
has the ability to create a universal apk from theaab
file. So lets make use of that togenerate one along side the
aab
. We are introducing a new propertyAndroidPackageFormats
.Under .net 6 this will have a value of
aab;apk
by default for Release builds, for Legacy it will beempty.
If
AndroidPackageFormats
is specified andAndroidPackageFormat
is empty we will use thevalues in
AndroidPackageFormats
to populateAndroidPackageFormat
. If none of these valuesare provided the
AndroidPackageFormat
will still default toapk
as it has always done.The following setting will produce both an
aab
and anapk
.This will produce just an
aab
and this will produce just an
apk
For .net 6 users this will be enabled by default for Release builds. For legacy users they will need
to define the property manually.