New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 820459 link

Starred by 4 users

Issue metadata

Status: Fixed
Owner:
Last visit > 30 days ago
Closed: Oct 25
Cc:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 1
Type: Feature

Blocked on:
issue 845405
issue 846633
issue 862525

Blocking:
issue 835323



Sign in to add a comment

Android Build: Support for Dynamic App Model bundles

Project Member Reported by digit@chromium.org, Mar 9 2018

Issue description

NOTE: This issue is about the use of a Play Store feature that has not been publicly announced yet, though most of it is developed as open-source. The Google-only restriction shall be lifted when all information becomes public.

The Play Store is developing a new application distribution model, similar (but better!) than iOS's app thinning. In a nutshell, the idea is to allow distributing smaller APKs to devices, based on their exact configuration.

Adopting this model would help reduce the size of Chrome installation and updates for many users. This issue is about adapting the Chromium build system to the generation of "dynamic app bundles", instead of APKs.

In a nutshell, extract from the current (internal) documentation:

-------------------- BEGIN_EXTRACT ---------------------------
Say your app is split into two main components:
Base: Part of the app used by all your users.
Payment: A payment feature that is only used by a fraction of users.

The App Bundle would contain two modules named base and payment (note: there must always be one module named “base”), which would translate to the users receiving by default two Split APKs base.apk and payment.apk with the same package name but a different splitId attribute (also set in the AndroidManifest.xml).

Now, if the Android App Bundle is configured to be split by, say, ABI and screen density, then a given user would receive smaller APKs containing only the relevant files for their device configuration. For instance, for a user with a configuration [ABI=x86, screen-density=HDPI], they would receive the following APKs:

base-master.apk (non-configuration-specific files)
base-x86.apk
base-hdpi.apk
payment-master.apk (non-configuration-specific files)
payment-x86.apk 
payment-hdpi.apk

In the future, you would also be able to configure the payment module to be served on demand, so that the majority of your users don’t have to download this feature if they are not going to use it.
---------------------- END_EXTRACT ----------------------------------

This issue is about adapting the Chromium build system to the generation of "dynamic app bundles". These are zip archives that are *not* APKs (their file structure is different, and compiled resources are protobufs, not binary XML, for example).

This relies on a new (yet unreleased) version of 'aapt2' (which supports a new option --proto-format used when compiling resources), as well as a new packaging/extracting tool called 'bundletool'.

Exact details are out of scope here, but can be found through this internal Google link: http://go/app-model/

This new build mode should not impact non-Android builds, and should still allow building regular APKs when needed.

 
Project Member

Comment 1 by bugdroid1@chromium.org, Mar 18 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/1fa1c441748db30f39da7c6f555d5bcd773608cd

commit 1fa1c441748db30f39da7c6f555d5bcd773608cd
Author: David 'Digit' Turner <digit@google.com>
Date: Sun Mar 18 20:02:02 2018

android build: Split process_resources GN rule and script.

The process_resources() GN template and the associated
process_resources.py script are huge and difficult to understand
because they can be used to perform two slightly related
different things.

In preparation for a future CL that will introduce a new resource
compilation mode, this CL tries to clarify the situation by splitting
them into two sets of GN template + script:

   - prepare_resources() + prepare_resources.py, which are
     used to create .resources.zip archives of raw/uncompiled
     resources for resource related targets, as well as
     generating a corresponding R.txt and .srcjar(R.java)
     file.

     This corresponds to what process_resources() did when
     it was called from android_resources() and junit_binary().

     Note that this always generates non-final resource IDs,
     as well as a dummy onResourcesLoaded() method, necessary
     to compile, but not link, the ResourceRewriter class
     used to implement the system webview feature.

   - compile_resources() + compile_resources.py, which are used
     to compile all resource dependencies of a given binary
     (e.g. android_apk) into an intermediate .ap_ file.

     This corresponds to the behaviour of process_resources()
     when called from android_apk(). This generates final
     resource IDs by default, unless |shared_resources| or
     |shared_resources_whitelist| is used.

     Also, as a simplification, |shared_resources_whitelist|
     now implies |shared_resources|, except that it restrict
     the list of non-final resource IDs.

- Removed generate_constant_ids, since compile_resources()
  will always generate constant ids unless shared resources
  are being used. And prepare_resources() always generates
  non-constant IDs, as before the CL.

+ Add documentation for the prepare_resources() and
  compile_resources() internal GN rules, to make them
  a little less intimidating.

+ Removed |app_as_shared_lib|, since even before this CL all
  resources were generated with package ID 0x7f anyway, or
  fixed a compile_resources() time. Hence |shared_resources|
  did the exact same thing.

+ Improve --help output for prepare_resources.py and
  compile_resources.py by using option groups for inputs
  and outputs.

R=agrieve@chromium.org,yfriedman@chromium.org,estevenson@chromium.org,trevordixon@chromium.org

Bug:  820459 
Change-Id: If05ac24a57c4dfa11f9ce43c30ab22e957b2765d
Reviewed-on: https://chromium-review.googlesource.com/957095
Commit-Queue: David Turner <digit@chromium.org>
Reviewed-by: agrieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#543957}
[add] https://crrev.com/1fa1c441748db30f39da7c6f555d5bcd773608cd/build/android/gyp/compile_resources.py
[add] https://crrev.com/1fa1c441748db30f39da7c6f555d5bcd773608cd/build/android/gyp/prepare_resources.py
[delete] https://crrev.com/f6520325e85fba98874125bb0fd044c312ce7976/build/android/gyp/process_resources.py
[add] https://crrev.com/1fa1c441748db30f39da7c6f555d5bcd773608cd/build/android/gyp/util/resource_utils.py
[modify] https://crrev.com/1fa1c441748db30f39da7c6f555d5bcd773608cd/build/config/android/internal_rules.gni
[modify] https://crrev.com/1fa1c441748db30f39da7c6f555d5bcd773608cd/build/config/android/rules.gni
[modify] https://crrev.com/1fa1c441748db30f39da7c6f555d5bcd773608cd/chrome/android/chrome_public_apk_tmpl.gni

Project Member

Comment 2 by bugdroid1@chromium.org, Mar 19 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/b101f5dbf2b0b6a481d61e8b9c2678ad3cb71f70

commit b101f5dbf2b0b6a481d61e8b9c2678ad3cb71f70
Author: Boris Sazonov <bsazonov@chromium.org>
Date: Mon Mar 19 11:47:34 2018

Revert "android build: Split process_resources GN rule and script."

This reverts commit 1fa1c441748db30f39da7c6f555d5bcd773608cd.

Reason for revert: broke downstream builders

Original change's description:
> android build: Split process_resources GN rule and script.
> 
> The process_resources() GN template and the associated
> process_resources.py script are huge and difficult to understand
> because they can be used to perform two slightly related
> different things.
> 
> In preparation for a future CL that will introduce a new resource
> compilation mode, this CL tries to clarify the situation by splitting
> them into two sets of GN template + script:
> 
>    - prepare_resources() + prepare_resources.py, which are
>      used to create .resources.zip archives of raw/uncompiled
>      resources for resource related targets, as well as
>      generating a corresponding R.txt and .srcjar(R.java)
>      file.
> 
>      This corresponds to what process_resources() did when
>      it was called from android_resources() and junit_binary().
> 
>      Note that this always generates non-final resource IDs,
>      as well as a dummy onResourcesLoaded() method, necessary
>      to compile, but not link, the ResourceRewriter class
>      used to implement the system webview feature.
> 
>    - compile_resources() + compile_resources.py, which are used
>      to compile all resource dependencies of a given binary
>      (e.g. android_apk) into an intermediate .ap_ file.
> 
>      This corresponds to the behaviour of process_resources()
>      when called from android_apk(). This generates final
>      resource IDs by default, unless |shared_resources| or
>      |shared_resources_whitelist| is used.
> 
>      Also, as a simplification, |shared_resources_whitelist|
>      now implies |shared_resources|, except that it restrict
>      the list of non-final resource IDs.
> 
> - Removed generate_constant_ids, since compile_resources()
>   will always generate constant ids unless shared resources
>   are being used. And prepare_resources() always generates
>   non-constant IDs, as before the CL.
> 
> + Add documentation for the prepare_resources() and
>   compile_resources() internal GN rules, to make them
>   a little less intimidating.
> 
> + Removed |app_as_shared_lib|, since even before this CL all
>   resources were generated with package ID 0x7f anyway, or
>   fixed a compile_resources() time. Hence |shared_resources|
>   did the exact same thing.
> 
> + Improve --help output for prepare_resources.py and
>   compile_resources.py by using option groups for inputs
>   and outputs.
> 
> R=​agrieve@chromium.org,yfriedman@chromium.org,estevenson@chromium.org,trevordixon@chromium.org
> 
> Bug:  820459 
> Change-Id: If05ac24a57c4dfa11f9ce43c30ab22e957b2765d
> Reviewed-on: https://chromium-review.googlesource.com/957095
> Commit-Queue: David Turner <digit@chromium.org>
> Reviewed-by: agrieve <agrieve@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#543957}

TBR=digit@chromium.org,yfriedman@chromium.org,agrieve@chromium.org,estevenson@chromium.org,trevordixon@chromium.org

Change-Id: I38d7922928cc6222750e057bc4a602a1faaec59e
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug:  820459 
Reviewed-on: https://chromium-review.googlesource.com/968461
Reviewed-by: Boris Sazonov <bsazonov@chromium.org>
Commit-Queue: Boris Sazonov <bsazonov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#544011}
[delete] https://crrev.com/b7cc0a155a592ff4a280b6ff6399836ce3f29dfd/build/android/gyp/compile_resources.py
[delete] https://crrev.com/b7cc0a155a592ff4a280b6ff6399836ce3f29dfd/build/android/gyp/prepare_resources.py
[add] https://crrev.com/b101f5dbf2b0b6a481d61e8b9c2678ad3cb71f70/build/android/gyp/process_resources.py
[delete] https://crrev.com/b7cc0a155a592ff4a280b6ff6399836ce3f29dfd/build/android/gyp/util/resource_utils.py
[modify] https://crrev.com/b101f5dbf2b0b6a481d61e8b9c2678ad3cb71f70/build/config/android/internal_rules.gni
[modify] https://crrev.com/b101f5dbf2b0b6a481d61e8b9c2678ad3cb71f70/build/config/android/rules.gni
[modify] https://crrev.com/b101f5dbf2b0b6a481d61e8b9c2678ad3cb71f70/chrome/android/chrome_public_apk_tmpl.gni

Project Member

Comment 3 by bugdroid1@chromium.org, Mar 20 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/be9a5dbbb310fd325785de38f64dc2e1cf75791b

commit be9a5dbbb310fd325785de38f64dc2e1cf75791b
Author: David 'Digit' Turner <digit@google.com>
Date: Tue Mar 20 06:55:44 2018

android build: Split process_resources GN rule and script.

This is a reland of [1] which got reverted in [2] because the
former actual broke the internal official build of Clank.

It turns out that instead of removing |app_as_shared_library = true|,
for the monochrome apk template, it should be turned into
|shared_resources = true|.

Apart from that, see description of the change in the original
CL, everything still applies.

[1] https://chromium-review.googlesource.com/c/chromium/src/+/957095
[2] https://chromium-review.googlesource.com/c/chromium/src/+/968461

R=agrieve@chromium.org,yfriedman@chromium.org,estevenson@chromium.org,trevordixon@chromium.org

Bug:  820459 
Change-Id: I6f6e71c3a13a388c67b68b684c733cd549a2cef0
Reviewed-on: https://chromium-review.googlesource.com/968870
Reviewed-by: agrieve <agrieve@chromium.org>
Commit-Queue: David Turner <digit@chromium.org>
Cr-Commit-Position: refs/heads/master@{#544300}
[add] https://crrev.com/be9a5dbbb310fd325785de38f64dc2e1cf75791b/build/android/gyp/compile_resources.py
[add] https://crrev.com/be9a5dbbb310fd325785de38f64dc2e1cf75791b/build/android/gyp/prepare_resources.py
[delete] https://crrev.com/56924fcbdf6a93dfdf460ffb88589bf80eb3c947/build/android/gyp/process_resources.py
[add] https://crrev.com/be9a5dbbb310fd325785de38f64dc2e1cf75791b/build/android/gyp/util/resource_utils.py
[modify] https://crrev.com/be9a5dbbb310fd325785de38f64dc2e1cf75791b/build/config/android/internal_rules.gni
[modify] https://crrev.com/be9a5dbbb310fd325785de38f64dc2e1cf75791b/build/config/android/rules.gni
[modify] https://crrev.com/be9a5dbbb310fd325785de38f64dc2e1cf75791b/chrome/android/chrome_public_apk_tmpl.gni

Project Member

Comment 4 by bugdroid1@chromium.org, Mar 21 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/af71563d3c61e712f355f6b73d5b589ab9d9ed97

commit af71563d3c61e712f355f6b73d5b589ab9d9ed97
Author: agrieve <agrieve@chromium.org>
Date: Wed Mar 21 01:57:39 2018

Revert "android build: Split process_resources GN rule and script."

This reverts commit be9a5dbbb310fd325785de38f64dc2e1cf75791b.

Reason for revert: Broke resources on Monochrome

Original change's description:
> android build: Split process_resources GN rule and script.
> 
> This is a reland of [1] which got reverted in [2] because the
> former actual broke the internal official build of Clank.
> 
> It turns out that instead of removing |app_as_shared_library = true|,
> for the monochrome apk template, it should be turned into
> |shared_resources = true|.
> 
> Apart from that, see description of the change in the original
> CL, everything still applies.
> 
> [1] https://chromium-review.googlesource.com/c/chromium/src/+/957095
> [2] https://chromium-review.googlesource.com/c/chromium/src/+/968461
> 
> R=​agrieve@chromium.org,yfriedman@chromium.org,estevenson@chromium.org,trevordixon@chromium.org
> 
> Bug:  820459 
> Change-Id: I6f6e71c3a13a388c67b68b684c733cd549a2cef0
> Reviewed-on: https://chromium-review.googlesource.com/968870
> Reviewed-by: agrieve <agrieve@chromium.org>
> Commit-Queue: David Turner <digit@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#544300}

TBR=digit@chromium.org,yfriedman@chromium.org,agrieve@chromium.org,estevenson@chromium.org,trevordixon@chromium.org

Change-Id: I2906cc84ab3bf07504a5de6846ec4a747a4f92fc
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug:  820459 , 820591
Reviewed-on: https://chromium-review.googlesource.com/972632
Reviewed-by: agrieve <agrieve@chromium.org>
Commit-Queue: agrieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#544617}
[delete] https://crrev.com/82318a8d26f071e01360c38c2d9bd27fbc2c7f58/build/android/gyp/compile_resources.py
[delete] https://crrev.com/82318a8d26f071e01360c38c2d9bd27fbc2c7f58/build/android/gyp/prepare_resources.py
[add] https://crrev.com/af71563d3c61e712f355f6b73d5b589ab9d9ed97/build/android/gyp/process_resources.py
[delete] https://crrev.com/82318a8d26f071e01360c38c2d9bd27fbc2c7f58/build/android/gyp/util/resource_utils.py
[modify] https://crrev.com/af71563d3c61e712f355f6b73d5b589ab9d9ed97/build/config/android/internal_rules.gni
[modify] https://crrev.com/af71563d3c61e712f355f6b73d5b589ab9d9ed97/build/config/android/rules.gni
[modify] https://crrev.com/af71563d3c61e712f355f6b73d5b589ab9d9ed97/chrome/android/chrome_public_apk_tmpl.gni

Project Member

Comment 5 by bugdroid1@chromium.org, Mar 23 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/81bb55bc0b81aa61561e93c928eeb2de69980e68

commit 81bb55bc0b81aa61561e93c928eeb2de69980e68
Author: David 'Digit' Turner <digit@google.com>
Date: Fri Mar 23 09:09:42 2018

android build: Split process_resources GN rule and script.

This is a reland of [1] which itself was a reland of [2].
Note that [1] was reverted in [3] due to broken package id
generation in monochrome_public_apk and its cousins.

The process_resources() GN template and the associated
process_resources.py script are huge and difficult to understand
because they can be used to perform two slightly related
different things.

In preparation for a future CL that will introduce a new resource
compilation mode, this CL tries to clarify the situation by splitting
them into two sets of GN template + script:

   - prepare_resources() + prepare_resources.py, which are
     used to create .resources.zip archives of raw/uncompiled
     resources for resource related targets, as well as
     generating a corresponding R.txt and .srcjar(R.java)
     file.

     This corresponds to what process_resources() did when
     it was called from android_resources() and junit_binary().

     Note that this always generates non-final resource IDs,
     as well as a dummy onResourcesLoaded() method, necessary
     to compile, but not link, the ResourceRewriter class
     used to implement the system webview feature.

   - compile_resources() + compile_resources.py, which are used
     to compile all resource dependencies of a given binary
     (e.g. android_apk) into an intermediate .ap_ file.

     This corresponds to the behaviour of process_resources()
     when called from android_apk(). This generates final
     resource IDs by default, unless |shared_resources| or
     |shared_resources_whitelist| is used.

     Also, as a simplification, |shared_resources_whitelist|
     now implies |shared_resources|, except that it restrict
     the list of non-final resource IDs.

- Removed generate_constant_ids, since compile_resources()
  will always generate constant ids unless shared resources
  are being used. And prepare_resources() always generates
  non-constant IDs, as before the CL.

+ Add documentation for the prepare_resources() and
  compile_resources() internal GN rules, to make them
  a little less intimidating.

+ Add documentation for shared_resources, app_as_shared_lib,
  shared_resources_whitelist_target for android_apk()
  template.

+ Add sanity checking for the resources table package
  ID of each generated APK. This is done by adding
  (and using) --check-resources-pkg-id=ID option to
  compile_resources.py.

+ Improve --help output for prepare_resources.py and
  compile_resources.py by using option groups for inputs
  and outputs.

[1] https://chromium-review.googlesource.com/c/chromium/src/+/968870
[2] https://chromium-review.googlesource.com/c/chromium/src/+/957095
[3] https://chromium-review.googlesource.com/c/chromium/src/+/972632

R=agrieve@chromium.org,yfriedman@chromium.org,estevenson@chromium.org,trevordixon@chromium.org

Bug:  820459 
Change-Id: I34a5018f54c06c110bbe996da88cddb9e3b9a21b
Reviewed-on: https://chromium-review.googlesource.com/973963
Commit-Queue: David Turner <digit@chromium.org>
Reviewed-by: agrieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#545392}
[add] https://crrev.com/81bb55bc0b81aa61561e93c928eeb2de69980e68/build/android/gyp/compile_resources.py
[add] https://crrev.com/81bb55bc0b81aa61561e93c928eeb2de69980e68/build/android/gyp/prepare_resources.py
[delete] https://crrev.com/8e793a18ec6358414ffc337b336c93d4f6061c91/build/android/gyp/process_resources.py
[add] https://crrev.com/81bb55bc0b81aa61561e93c928eeb2de69980e68/build/android/gyp/util/resource_utils.py
[modify] https://crrev.com/81bb55bc0b81aa61561e93c928eeb2de69980e68/build/config/android/internal_rules.gni
[modify] https://crrev.com/81bb55bc0b81aa61561e93c928eeb2de69980e68/build/config/android/rules.gni

Comment 6 by ssid@chromium.org, Mar 28 2018

Cc: ssid@chromium.org

Comment 7 by digit@chromium.org, Apr 9 2018

Blockedon: 830641
Project Member

Comment 8 by bugdroid1@chromium.org, Apr 17 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/92e8223dcdf8813dbff0ec99ab9fd973e360f4ae

commit 92e8223dcdf8813dbff0ec99ab9fd973e360f4ae
Author: David 'Digit' Turner <digit@google.com>
Date: Tue Apr 17 14:49:18 2018

android: store compressed locales under assets/locales/

This patch simply moves the location where the compressed
locale .pak files are stored within the final Chrome and
Monochrome APKs, from assets/<locale>.pak to
assets/locales/<locale>.pak

The reason to do this is to allow language-dependent
splits in the future, which will require apkbuilder.py
to support an option to place the files under a
directory like assets/locales#<lang>/<locale>.pak,
where <lang> is the language code of each corresponding
locale.

Note that these files are never accessed directly from
Chromium, instead they are extracted at startup time
if needed to the application's private data directory,
and the uncompressed file there is what Chrome will
later memory-map from native code.

In detail:

- Modify chrome/android/BUILD.gn to ensure that the
  compressed locale pak files are placed under
  assets/locales/

- Modify write_build_config.py to not use the directory
  of locale pak files when generating the Java locale
  lists for COMPRESSED_LOCALES and UNCOMPRESSED_LOCALES.

- Modify ResourceBundle.java to deal with the new list
  format when looking for uncompressed locales.

- Modify ResourceExtractor.java to deal with the new
  list format and the new locations.

BUG= 820459 
R=agrieve@chromium.org,dtrainor@chromium.org,tedchoc@chromium.org

Change-Id: Ia0caef3514a1ccfa72fe0ab1ff6fc1bf418377a6
Reviewed-on: https://chromium-review.googlesource.com/1010352
Commit-Queue: David Turner <digit@chromium.org>
Reviewed-by: agrieve <agrieve@chromium.org>
Reviewed-by: Ted Choc <tedchoc@chromium.org>
Reviewed-by: David Trainor <dtrainor@chromium.org>
Cr-Commit-Position: refs/heads/master@{#551332}
[modify] https://crrev.com/92e8223dcdf8813dbff0ec99ab9fd973e360f4ae/base/android/java/src/org/chromium/base/ResourceExtractor.java
[modify] https://crrev.com/92e8223dcdf8813dbff0ec99ab9fd973e360f4ae/build/android/gyp/write_build_config.py
[modify] https://crrev.com/92e8223dcdf8813dbff0ec99ab9fd973e360f4ae/chrome/android/BUILD.gn
[modify] https://crrev.com/92e8223dcdf8813dbff0ec99ab9fd973e360f4ae/ui/android/java/src/org/chromium/ui/base/ResourceBundle.java

Project Member

Comment 9 by bugdroid1@chromium.org, May 17 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/b9a9abdb6b670cb87f5245d03973f9896b1fa9c6

commit b9a9abdb6b670cb87f5245d03973f9896b1fa9c6
Author: David 'Digit' Turner <digit@google.com>
Date: Thu May 17 15:36:35 2018

android: build: Support compiling resources in protobuf format.

Android dynamic app bundle generation requires compiling the
resources into a new format based on serialized protocol buffers,
instead of the existing binary xml + resources.arsc file.

This is performed through an updated (and yet unreleased)
version of the 'aapt2 compile' command that takes a new
--proto-format command-line option to specify the output
format.

This CL modifies the build system to support these, in
the following way:

- compile_resources.py now supports a --proto-format
  option that can be used to specify the output format
  of the generated file.

- The new GN build var android_sdk_app_bundle_build_tools
  can be used in your args.gn file the path of an updated
  Android SDK build-tools/<version>/ directory that
  contains the updated 'aapt2' binary.

  There is also a global android_enable_app_bundles
  global boolean, which is set to true when said
  build tools path is set.

- The android_apk() GN template can also define a new
  target (${target_name}__compile_proto_resources)
  used to compile the APK's resources set into the
  new format.

  Note that the output is put under
  $CHROMIUM_OUTPUT_DIR/gen/proto_resources/$APK_NAME.proto.ap_

  While the existing one is put under
  $CHROMIUM_OUTPUT_DIR/gen/arsc/$APK_NAME.ap_

  IMPORTANT NOTE: The APK target itself does not depend
  on this .proto.ap_ file, but a future CL will introduce
  new targets for app bundles, which will depend on
  the APK target, and use it to depend on it.

- The APK's .build_config file now includes a new
  deps_info['proto_resources_path'] that points to the
  proto-compiled resources file.

  This will be used by app bundles that depend on
  the APK itself to define a bundle module.

  The value can be specified by using --apk-proto-resources
  when using write_build_config.py

BUG= 820459 
R=agrieve@chromium.org, yfriedman@chromium.org, trevordixon@chromium.org

Change-Id: I1765a3d7818397a0400466ab7f8e02cf882b8927
Reviewed-on: https://chromium-review.googlesource.com/1047607
Commit-Queue: David Turner <digit@chromium.org>
Reviewed-by: agrieve <agrieve@chromium.org>
Reviewed-by: Yaron Friedman <yfriedman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#559542}
[modify] https://crrev.com/b9a9abdb6b670cb87f5245d03973f9896b1fa9c6/build/android/gyp/compile_resources.py
[modify] https://crrev.com/b9a9abdb6b670cb87f5245d03973f9896b1fa9c6/build/android/gyp/write_build_config.py
[modify] https://crrev.com/b9a9abdb6b670cb87f5245d03973f9896b1fa9c6/build/config/android/config.gni
[modify] https://crrev.com/b9a9abdb6b670cb87f5245d03973f9896b1fa9c6/build/config/android/internal_rules.gni
[modify] https://crrev.com/b9a9abdb6b670cb87f5245d03973f9896b1fa9c6/build/config/android/rules.gni

Comment 10 by digit@google.com, May 22 2018

Labels: -Restrict-View-Google
Since app bundles are now officially announced [1], removing the Google-view restriction on this issue.

[1] https://developer.android.com/platform/technology/app-bundle/

Comment 11 by digit@google.com, May 22 2018

Blockedon: 845405
Project Member

Comment 12 by bugdroid1@chromium.org, May 24 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/52f78b1683a099f282aa06aea703d5e2c5ee59c0

commit 52f78b1683a099f282aa06aea703d5e2c5ee59c0
Author: David 'Digit' Turner <digit@google.com>
Date: Thu May 24 11:33:37 2018

android: build: Add extra native libraries to APK .build_config

This CL augments the .build_config file of APK with a new
entry at native['extra_shared_libraries'] that list extra
shared libraries that can be packaged into the final APK
(but which may be processed differently from the list
in native['libraries'].

This entry will be used later when building an App Bundle
module that depends on the APK's .build_config.

This is required because the full list of native libraries
is determined by a set of complex rules performed by the
android_apk() rule, which would be difficult to replicate
in a different one without lots of code duplication, or
making android_apk() even more complicated that it currently
is.

+ Add a flag in the APK's .build_config file telling it whether
  the libraries are stored uncompressed (and page-aligned)
  in the APK. This will allow reproducing the same
  compression setting when generating the bundle later.

BUG= 820459 
R=agrieve@chromium.org, estevenson@chromium.org, yfriedman@chromium.org


Change-Id: I7a4fa94e68370dbc167c1f9729d152f4692fdaff
Reviewed-on: https://chromium-review.googlesource.com/1047865
Commit-Queue: David Turner <digit@chromium.org>
Reviewed-by: agrieve <agrieve@chromium.org>
Reviewed-by: Eric Stevenson <estevenson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#561464}
[modify] https://crrev.com/52f78b1683a099f282aa06aea703d5e2c5ee59c0/build/android/gyp/apkbuilder.py
[modify] https://crrev.com/52f78b1683a099f282aa06aea703d5e2c5ee59c0/build/android/gyp/write_build_config.py
[modify] https://crrev.com/52f78b1683a099f282aa06aea703d5e2c5ee59c0/build/config/android/internal_rules.gni
[modify] https://crrev.com/52f78b1683a099f282aa06aea703d5e2c5ee59c0/build/config/android/rules.gni

Comment 13 by digit@chromium.org, May 25 2018

Blockedon: 846633
Blocking: 835323
Project Member

Comment 15 by bugdroid1@chromium.org, Jul 3

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/8541637904013cfeca56a4700ba82ee8c463594f

commit 8541637904013cfeca56a4700ba82ee8c463594f
Author: David 'Digit' Turner <digit@google.com>
Date: Tue Jul 03 15:23:51 2018

android: More app bundle related fixes.

This CL contains a few changes related to app bundle generation.
part of a simplification of the following large CL:
https://chromium-review.googlesource.com/c/chromium/src/+/1071657

More specifically:

- bundletool.py: Enable the python script to be imported. This
  will happen in a future CL that will add new Python build
  scripts to generate app bundles and apk sets.

- Compile resources to protobuf-based format using the new
  aapt2 binary added recently to third_party/android_build_tools/.

- Add an entry in an APK's .build_config file indicating the location
  of its final dex files, to help the bundle-generating targets
  use them later.

BUG= 820459 
R=agrieve@chromium.org, benmason@chromium.org, yfriedman@chromium.org

Change-Id: Ifd66f11bafe804625efba3051ecf5f7c40fcf740
Reviewed-on: https://chromium-review.googlesource.com/1120530
Reviewed-by: agrieve <agrieve@chromium.org>
Commit-Queue: David Turner <digit@chromium.org>
Cr-Commit-Position: refs/heads/master@{#572223}
[modify] https://crrev.com/8541637904013cfeca56a4700ba82ee8c463594f/build/android/gyp/bundletool.py
[modify] https://crrev.com/8541637904013cfeca56a4700ba82ee8c463594f/build/android/gyp/compile_resources.py
[modify] https://crrev.com/8541637904013cfeca56a4700ba82ee8c463594f/build/android/gyp/util/resource_utils.py
[modify] https://crrev.com/8541637904013cfeca56a4700ba82ee8c463594f/build/android/gyp/write_build_config.py
[modify] https://crrev.com/8541637904013cfeca56a4700ba82ee8c463594f/build/config/android/config.gni
[modify] https://crrev.com/8541637904013cfeca56a4700ba82ee8c463594f/build/config/android/internal_rules.gni
[modify] https://crrev.com/8541637904013cfeca56a4700ba82ee8c463594f/build/config/android/rules.gni

Project Member

Comment 16 by bugdroid1@chromium.org, Jul 3

Labels: merge-merged-3474
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/12da62358e4d2c3a2347c7b6e5cd3bf4f091e4e7

commit 12da62358e4d2c3a2347c7b6e5cd3bf4f091e4e7
Author: David 'Digit' Turner <digit@google.com>
Date: Tue Jul 03 18:53:14 2018

android: Add android_app_bundle GN template.

This CL adds a new public template named android_app_bundle()
that can be used to generate an Android App Bundle [1] that
maps the content of an existing base APK (plus optional additional
feature modules).

IMPORTANT: Language-based splits are disabled for now
           (see  http://crbug.com/846633  for details).

For now, this relies on the latest aapt2 and bundletool-all.jar
binaries in a directory specified throug the GN args variable
android_sdk_app_bundle_build_tools. This requirement will be
lifted once these binaries are properly rolled out in the Chromium
source tree (tracked by  http://crbug.com/845405 ).

This also adds a few new GN targets to build some bundles, as
well as ".apks" files, which are zip archives containing several
APK splits + some configuration data.

  chrome_public_bundle
    ($OUT/gen/chrome/android/chrome_public_bundle.aab)

  chrome_public_bundle_apks
    ($OUT/gen/chrome/android/chrome_public_bundle.apks)

  chrome_modern_public_bundle
    ($OUT/gen/chrome/android/chrome_modern_public_bundle.aab)

  monochrome_public_bundle
    ($OUT/gen/chrome/android/monochrome_public_bundle.aab)

To install the .apks on a local device, use the following:

  build/android/gyp/bundletool.py install-apks \
    --apks=out/Release/gen/chrome/android/chrome_public_bundle.apks \
    --adb=$(which adb)

+ Fix resource extraction logic to recognize when the .pak files
  are stored in APK splits with asset-targeting directories.

BUG= 820459 
R=​benmason@chromium.org,agrieve@chromium.org,yfriedman@chromium.org,tedchoc@chromium.org,dtrainor@chromium.org

Change-Id: Iaf63985e5e955ad97403ad4c938b8471a0128fee
Reviewed-on: https://chromium-review.googlesource.com/1124904
Reviewed-by: Ben Mason <benmason@chromium.org>
Cr-Commit-Position: refs/branch-heads/3474@{#5}
Cr-Branched-From: e3d2bf14a3ded568e72df70feac71980d34da10c-refs/heads/master@{#570647}
[modify] https://crrev.com/12da62358e4d2c3a2347c7b6e5cd3bf4f091e4e7/build/android/gyp/apkbuilder.py
[add] https://crrev.com/12da62358e4d2c3a2347c7b6e5cd3bf4f091e4e7/build/android/gyp/app_bundle_to_apks.py
[modify] https://crrev.com/12da62358e4d2c3a2347c7b6e5cd3bf4f091e4e7/build/android/gyp/bundletool.py
[modify] https://crrev.com/12da62358e4d2c3a2347c7b6e5cd3bf4f091e4e7/build/android/gyp/compile_resources.py
[add] https://crrev.com/12da62358e4d2c3a2347c7b6e5cd3bf4f091e4e7/build/android/gyp/create_app_bundle.py
[modify] https://crrev.com/12da62358e4d2c3a2347c7b6e5cd3bf4f091e4e7/build/android/gyp/util/resource_utils.py
[modify] https://crrev.com/12da62358e4d2c3a2347c7b6e5cd3bf4f091e4e7/build/android/gyp/write_build_config.py
[modify] https://crrev.com/12da62358e4d2c3a2347c7b6e5cd3bf4f091e4e7/build/config/android/config.gni
[modify] https://crrev.com/12da62358e4d2c3a2347c7b6e5cd3bf4f091e4e7/build/config/android/internal_rules.gni
[modify] https://crrev.com/12da62358e4d2c3a2347c7b6e5cd3bf4f091e4e7/build/config/android/rules.gni
[modify] https://crrev.com/12da62358e4d2c3a2347c7b6e5cd3bf4f091e4e7/chrome/android/BUILD.gn
[modify] https://crrev.com/12da62358e4d2c3a2347c7b6e5cd3bf4f091e4e7/ui/android/java/src/org/chromium/ui/base/LocalizationUtils.java
[modify] https://crrev.com/12da62358e4d2c3a2347c7b6e5cd3bf4f091e4e7/ui/android/java/src/org/chromium/ui/resources/ResourceExtractor.java

Project Member

Comment 17 by bugdroid1@chromium.org, Jul 5

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/7122b4b42baa41f338c896f874b46ebc5f6f13c3

commit 7122b4b42baa41f338c896f874b46ebc5f6f13c3
Author: David 'Digit' Turner <digit@google.com>
Date: Thu Jul 05 11:03:56 2018

android: Support building Android App Bundles for Chrome.

This CL adds new GN rules and two example targets to
generate App Bundles for Chromium. For now, the bundles
do not use any split dimensions, or feature modules, but
these will appear in future CLs.

Note that:

- Signing the bundles is optional, and controlled by the
  'sign_bundle' boolean target variable. This is because
  signing requires 'jarsigner' which is very slow. Since
  the signing is only required to upload to the Play Store,
  it is currently only performed for official builds in
  the chrome_public_bundle target.

- It is possible to generate an .apks archive from a
  bundle at build time. This is only useful for local
  installation / testing, but could also be performed
  outside of the build on demand (e.g. with a python
  script like bundle_operations.py, which would reflect
  apk_operations.py, but for bundles).

  For now, this requires setting the GN variable
  'generate_apks' to true in the target declaration,
  and will automatically declare another target with
  an _apks suffix (e.g. foo_bundle -> foo_bundle_apks).

- The bundles and the .apks archive are signed with the
  same key as the one used to sign regular APKs. A
  future CL might introduce a way to specify a different
  signing key for bundles, in order to match Play Store
  uploader keys used by the project (if needed).

The new targets defined here are:

  chrome_public_bundle
    ($OUT/gen/chrome/android/chrome_public_bundle.aab)

  chrome_public_bundle_apks
    ($OUT/gen/chrome/android/chrome_public_bundle.apks)

  chrome_modern_public_bundle
    ($OUT/gen/chrome/android/chrome_modern_public_bundle.aab)

  monochrome_public_bundle
    ($OUT/gen/chrome/android/monochrome_public_bundle.aab)

The bundles cannot be installed, only the .apks archive can.
To install the .apks on a local device, use the following:

  build/android/gyp/bundletool.py install-apks \
    --apks=out/Release/gen/chrome/android/chrome_public_bundle.apks \
    --adb=$(which adb)

More details:

- apkbuilder.py: Add a new --format=bundle-module option that
  is used to generate an App Bundle module zip archive, instead
  of an APK.

- create_app_bundle.py: New script to generate a bundle from
  a list of bundle module archives, and some configuration
  options.

- app_bundle_to_apks.py: New script used to generate a bundle
  into an .apks archive (which contains a set of split APKs,
  which can be installed with the bundletool install-apks
  command described above).

  Only use this for local testing, not for distribution.

- New android_app_bundle GN template to define a bundle
  target from one or more android_apk targets.

BUG= 820459 
R=benmason@chromium.org, agrieve@chromium.org, yfriedman@chromium.org

Change-Id: I5be05742fe389853644a970bda4f8267a9f90ae7
Reviewed-on: https://chromium-review.googlesource.com/1125932
Commit-Queue: David Turner <digit@chromium.org>
Reviewed-by: agrieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#572755}
[modify] https://crrev.com/7122b4b42baa41f338c896f874b46ebc5f6f13c3/build/android/gyp/apkbuilder.py
[add] https://crrev.com/7122b4b42baa41f338c896f874b46ebc5f6f13c3/build/android/gyp/app_bundle_to_apks.py
[add] https://crrev.com/7122b4b42baa41f338c896f874b46ebc5f6f13c3/build/android/gyp/create_app_bundle.py
[modify] https://crrev.com/7122b4b42baa41f338c896f874b46ebc5f6f13c3/build/config/android/config.gni
[modify] https://crrev.com/7122b4b42baa41f338c896f874b46ebc5f6f13c3/build/config/android/internal_rules.gni
[modify] https://crrev.com/7122b4b42baa41f338c896f874b46ebc5f6f13c3/build/config/android/rules.gni
[modify] https://crrev.com/7122b4b42baa41f338c896f874b46ebc5f6f13c3/chrome/android/BUILD.gn

Blockedon: 862525
Project Member

Comment 19 by bugdroid1@chromium.org, Jul 12

The following revision refers to this bug:
  https://chrome-internal.googlesource.com/clank/internal/apps/+/791904830192473e340e0c135b66c450abd1c8c8

commit 791904830192473e340e0c135b66c450abd1c8c8
Author: David 'Digit' Turner <digit@google.com>
Date: Thu Jul 12 14:38:42 2018

Cc: -trevordixon@chromium.org
Project Member

Comment 21 by bugdroid1@chromium.org, Jul 12

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/dc6d74d7b8c120d3d8d90ab8c68c5285e384a7f8

commit dc6d74d7b8c120d3d8d90ab8c68c5285e384a7f8
Author: David 'Digit' Turner <digit@google.com>
Date: Thu Jul 12 17:07:14 2018

android: Update bundletool binary to 0.5.0

This release contains a bugfix required to generate Android
app bundle APKs archives that can be installed on all devices.

For more context, see:
https://buganizer.corp.google.com/issues/110777526

BUG= 846633 , 820459 
R=agrieve@chromium.org, bensmason@chromium.org, yfriedman@chromium.org

Change-Id: Ic71445f49a4548c8610f5d18598cdd3d3d5692c4
Reviewed-on: https://chromium-review.googlesource.com/1135127
Reviewed-by: agrieve <agrieve@chromium.org>
Commit-Queue: David Turner <digit@chromium.org>
Cr-Commit-Position: refs/heads/master@{#574608}
[modify] https://crrev.com/dc6d74d7b8c120d3d8d90ab8c68c5285e384a7f8/DEPS
[modify] https://crrev.com/dc6d74d7b8c120d3d8d90ab8c68c5285e384a7f8/build/android/gyp/bundletool.py
[modify] https://crrev.com/dc6d74d7b8c120d3d8d90ab8c68c5285e384a7f8/third_party/android_build_tools/bundletool/README.chromium

Project Member

Comment 22 by bugdroid1@chromium.org, Jul 13

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/bdb7c6bf6d378e95ddeb81014e30bb19cdd87c86

commit bdb7c6bf6d378e95ddeb81014e30bb19cdd87c86
Author: David 'Digit' Turner <digit@google.com>
Date: Fri Jul 13 12:54:36 2018

android: Enable language-based splits for app bundles.

This is done by adding a new |enable_language_splits| variable to
the android_app_bundle GN template. Note that splitting by
screen_density or ABI currently doesn't make sense for Chromium,
but could be added in the future.

Only the chrome_public_bundle target uses language-based
splits in this CL.

BUG= 846633 , 820459 
R=agrieve@chromium.org, yfriedman@chromium.org
TBR=twellington@chromium.org,tedchoc@chromium.org

Change-Id: Ic89f9dd4b8c78e8b2127bb19208db18bc8027eab
Reviewed-on: https://chromium-review.googlesource.com/1125934
Commit-Queue: David Turner <digit@chromium.org>
Reviewed-by: agrieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#574888}
[modify] https://crrev.com/bdb7c6bf6d378e95ddeb81014e30bb19cdd87c86/build/android/gyp/create_app_bundle.py
[modify] https://crrev.com/bdb7c6bf6d378e95ddeb81014e30bb19cdd87c86/build/android/gyp/util/resource_utils.py
[modify] https://crrev.com/bdb7c6bf6d378e95ddeb81014e30bb19cdd87c86/build/config/android/rules.gni
[modify] https://crrev.com/bdb7c6bf6d378e95ddeb81014e30bb19cdd87c86/chrome/android/BUILD.gn
[modify] https://crrev.com/bdb7c6bf6d378e95ddeb81014e30bb19cdd87c86/ui/android/java/src/org/chromium/ui/base/LocalizationUtils.java
[modify] https://crrev.com/bdb7c6bf6d378e95ddeb81014e30bb19cdd87c86/ui/android/java/src/org/chromium/ui/resources/ResourceExtractor.java

Project Member

Comment 23 by bugdroid1@chromium.org, Jul 25

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/f9cabcfefa27dec40d08dca29f515bbbc568171e

commit f9cabcfefa27dec40d08dca29f515bbbc568171e
Author: David 'Digit' Turner <digit@google.com>
Date: Wed Jul 25 15:10:40 2018

android: Minor fix for Chrome official bundle builds.

The following CL contains a small fix required to ensure
that it is possible to build app bundle for official Chrome
builds, which require placeholders native libraries for
older Android releases.

BUG= 820459 
R=benmason@chromium.org,tiborg@chromium.org
TBR=agrieve@chromium.org

Change-Id: I1fa5999c808b11c248c854f6c5131c54996d9959
Reviewed-on: https://chromium-review.googlesource.com/1150173
Reviewed-by: David Turner <digit@chromium.org>
Reviewed-by: Tibor Goldschwendt <tiborg@chromium.org>
Commit-Queue: David Turner <digit@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577893}
[modify] https://crrev.com/f9cabcfefa27dec40d08dca29f515bbbc568171e/build/config/android/rules.gni

Blockedon: 862185
Labels: Target-72 Pri-1
Increasing priority since this bug is blocking bundle release.
Blockedon: -862185
Blockedon: -830641
Status: Fixed (was: Started)
All the pieces are now in place and we can build bundles reliably now.

Sign in to add a comment