Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save chirayudesai/bb24e93a0c097fc742c0ac56e39ac86f to your computer and use it in GitHub Desktop.
Save chirayudesai/bb24e93a0c097fc742c0ac56e39ac86f to your computer and use it in GitHub Desktop.
From 616c762bf2b90fa67137ce2207108434278079fc Mon Sep 17 00:00:00 2001
From: Chirayu Desai <chirayudesai1@gmail.com>
Date: Tue, 21 Jul 2020 03:25:23 +0530
Subject: [PATCH] Bring back trichrome_chrome_apk
* Since M84, chromium trichrome_chrome_bundle doesn't
play nice with bundletool and thus can't be signed.
* bundletool's aapt2 invocation fails with
"duplication configuration in resource table.",
see the bug for more details
Partial Revert of "Android: Remove trichrome_chrome_apk"
This reverts commit be712e648cb870eb125ce6832fec55859e3f56ec.
Bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1106115
---
.../docs/aosp-system-integration.md | 6 ++---
chrome/android/BUILD.gn | 25 ++++++++++++++++++-
docs/android_build_instructions.md | 10 ++++----
docs/android_native_libraries.md | 4 +--
4 files changed, 34 insertions(+), 11 deletions(-)
diff --git a/android_webview/docs/aosp-system-integration.md b/android_webview/docs/aosp-system-integration.md
index 3b8a0764a2..3941a28fc5 100644
--- a/android_webview/docs/aosp-system-integration.md
+++ b/android_webview/docs/aosp-system-integration.md
@@ -104,7 +104,7 @@ is called `MonochromePublic.apk`.
Trichrome is only compatible with Android Q and later.
-Trichrome is composed of three APK/AABs:
+Trichrome is composed of three APKs:
1. TrichromeWebView contains WebView-specific code and data, and provides
Android apps with the WebView implementation.
@@ -119,9 +119,9 @@ The three Trichrome APKs together are roughly the same size as Monochrome,
providing the same benefits, but many of the downsides and complexities of
Monochrome don't apply to Trichrome.
-The build targets are called `trichrome_webview_apk`, `trichrome_chrome_bundle`,
+The build targets are called `trichrome_webview_apk`, `trichrome_chrome_apk`,
and `trichrome_library_apk` respectively, and the resulting output files are
-called `TrichromeWebView.apk`, `TrichromeChrome.aab`, and
+called `TrichromeWebView.apk`, `TrichromeChrome.apk`, and
`TrichromeLibrary.apk`.
### Choosing a WebView version
diff --git a/chrome/android/BUILD.gn b/chrome/android/BUILD.gn
index 2e9596b4a6..875cbb8791 100644
--- a/chrome/android/BUILD.gn
+++ b/chrome/android/BUILD.gn
@@ -1566,6 +1566,10 @@ if (current_toolchain == default_toolchain) {
is_monochrome = true
is_bundle_module = true
}
+ resource_packaging("trichrome_chrome_apk_pak_assets") {
+ is_monochrome = false
+ is_trichrome = true
+ }
resource_packaging("trichrome_chrome_bundle_module_pak_assets") {
is_monochrome = false
is_trichrome = true
@@ -1966,7 +1970,7 @@ trichrome_library_apk_tmpl("trichrome_library_apk") {
if (trichrome_synchronized_proguard) {
webview_target = "//android_webview:trichrome_webview_apk"
- chrome_target = ":trichrome_chrome_bundle"
+ chrome_target = ":trichrome_chrome_apk"
}
verify_manifest = _enable_manifest_verification
@@ -2006,6 +2010,25 @@ android_resources("trichrome_dummy_resources") {
sources = [ "trichrome/res_dummy/values/strings.xml" ]
}
+monochrome_public_apk_or_module_tmpl("trichrome_chrome_apk") {
+ version_code = trichrome_version_code
+ version_name = chrome_version_name
+ apk_name = "TrichromeChrome"
+ target_type = "android_apk"
+ use_trichrome_library = true
+ static_library_provider = ":trichrome_library_apk"
+ if (!is_java_debug) {
+ static_library_synchronized_proguard = trichrome_synchronized_proguard
+ if (trichrome_synchronized_proguard) {
+ resource_ids_provider_dep = "//android_webview:trichrome_webview_apk"
+ }
+ }
+ if (android_64bit_target_cpu) {
+ is_64_bit_browser = false
+ include_64_bit_webview = true
+ }
+}
+
chrome_public_test_apk_manifest =
"$root_gen_dir/chrome_public_test_apk_manifest/AndroidManifest.xml"
chrome_public_test_vr_apk_manifest =
diff --git a/docs/android_build_instructions.md b/docs/android_build_instructions.md
index 2aeee62843..f3150f13e4 100644
--- a/docs/android_build_instructions.md
+++ b/docs/android_build_instructions.md
@@ -177,11 +177,11 @@ out/Default` from the command line. To compile one, pass the GN label to Ninja
with no preceding "//" (so, for `//chrome/test:unit_tests` use `autoninja -C
out/Default chrome/test:unit_tests`).
-### Multiple Chrome Targets
+### Multiple Chrome APK Targets
-The Google Play Store allows apps to send customized `.apk` or `.aab` files
-depending on the version of Android running on a device. Chrome uses this
-feature to target 4 different versions using 4 different ninja targets:
+The Google Play Store allows apps to send customized `.apk` files depending on
+the version of Android running on a device. Chrome uses this feature to target
+4 different versions using 4 different ninja targets:
1. `chrome_public_apk` (ChromePublic.apk)
* `minSdkVersion=19` (KitKat).
@@ -201,7 +201,7 @@ feature to target 4 different versions using 4 different ninja targets:
* Stores libmonochrome.so uncompressed within the APK.
* Does not use Crazy Linker (WebView requires system linker).
* But system linker supports crazy linker features now anyways.
-4. `trichrome_chrome_bundle` and `trichrome_library_apk` (TrichromeChrome.aab and TrichromeLibrary.apk)
+4. `trichrome_chrome_apk` and `trichrome_library_apk` (TrichromeChrome.apk and TrichromeLibrary.apk)
* `minSdkVersion=Q` (Q).
* TrichromeChrome contains only the Chrome code that is not shared with WebView.
* TrichromeLibrary contains the shared code and is a "static shared library APK", which must be installed prior to TrichromeChrome.
diff --git a/docs/android_native_libraries.md b/docs/android_native_libraries.md
index 0d3ade6f26..4ca6f290e9 100644
--- a/docs/android_native_libraries.md
+++ b/docs/android_native_libraries.md
@@ -12,7 +12,7 @@ Chrome on Android.
* It is loaded directly from the apk (without extracting) by `mmap()`'ing it.
* Android N, O & P (MonochromePublic.apk):
* `libmonochrome.so` is stored uncompressed (AndroidManifest.xml attribute disables extraction) and loaded directly from the apk (functionality now supported by the system linker).
- * Android Q (TrichromeChrome.aab+TrichromeLibrary.apk):
+ * Android Q (TrichromeChrome.apk+TrichromeLibrary.apk):
* `libmonochrome.so` is stored in the shared library apk (TrichromeLibrary.apk) instead of in the Chrome apk, so that it can be shared with TrichromeWebView. It's stored uncompressed and loaded directly from the apk the same way as on N-P. Trichrome uses the same native library as Monochrome, so it's still called `libmonochrome.so`.
## Build Variants (eg. monochrome_64_32_apk)
@@ -135,7 +135,7 @@ Builds on | Variant | Chrome | Library | Webview
* `JNI_OnLoad()` is the only exported symbol (enforced by a linker script).
* Native methods registered explicitly during start-up by generated code.
* Explicit generation is required because the Android runtime uses the system's `dlsym()`, which doesn't know about Crazy-Linker-opened libraries.
- * For MonochromePublic.apk and TrichromeChrome.aab:
+ * For MonochromePublic.apk and TrichromeChrome.apk:
* `JNI_OnLoad()` and `Java_*` symbols are exported by linker script.
* No manual JNI registration is done. Symbols are resolved lazily by the runtime.
--
2.27.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment