Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Issue 2570313002: Use R.txt from AAR to generate R.java for it when building APK. (Closed)

Created:
4 years ago by mlopatkin
Modified:
4 years ago
Reviewers:
agrieve, dgn
CC:
chromium-reviews, mikecase+watch_chromium.org, jbudorick+watch_chromium.org, agrieve+watch_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Use R.txt from AAR to generate R.java for it when building APK. R.java and R.txt files for an AAR were generated by extracting all resources from the AAR and its dependencies and running aapt on these resources. This approach turned out to be problematic for AARs of GMS (Play Services). GMS is shipped as a bunch of AARs with dependencies between them. However the way it deals with resources is rather unusual. GMS code references all resources via com.google.android.gms.R class that corresponds to the "basement" AAR. This AAR has R.txt with entries for all resources of the GMS but contains only a small subset of the resources. All other resources are provided by other AARs: they have different packages and no R.txt files though. The consumer of the GMS must generate com.google.android.gms.R class with entries for all resources provided by used GMS AARs. Entries for resources that belong to the unused AARs may be ommited. This is what Gradle plugin for Android does. However AAR support in Chromium discarded R.txt from "basement" then generated very small com.google.android.gms.R without essential entries and this caused crashes in runtime. This CL changes processing of the AARs resources. If R.txt is present in AAR then aapt-generated R.txt is discared. The one from AAR is used to generate R.java for java dependencies of the AAR target and to generate final R.java file during APK build which is compiled and included into the final APK. During obfuscation Proguard checks that all entries that are referenced in code were in fact generated. This check cannot be done during resource processing because "basement"'s R.txt lists resources that aren't included in Chromium and this is because code that uses these resources isn't included either. BUG=670368 R=agrieve@chromium.org,dgn@chromium.org Committed: https://crrev.com/d36c048e72f0e936b725d4de25179a7c41599c1a Cr-Commit-Position: refs/heads/master@{#439485}

Patch Set 1 #

Patch Set 2 : Refine in-code comment #

Total comments: 4

Patch Set 3 : Address review comments #

Patch Set 4 : Added workaround for aars with empty R.txt and no resources. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+66 lines, -14 lines) Patch
M build/android/gyp/aar.py View 1 2 3 2 chunks +5 lines, -0 lines 0 comments Download
M build/android/gyp/process_resources.py View 1 2 3 chunks +29 lines, -3 lines 0 comments Download
M build/config/android/internal_rules.gni View 1 2 3 chunks +12 lines, -3 lines 0 comments Download
M build/config/android/rules.gni View 8 chunks +20 lines, -5 lines 0 comments Download
M chrome/android/java/proguard.flags View 1 chunk +0 lines, -3 lines 0 comments Download

Messages

Total messages: 21 (13 generated)
mlopatkin
PTAL I verified (with test application that used some of GMS libs) that Gradle plugin ...
4 years ago (2016-12-14 16:22:01 UTC) #1
agrieve
lgtm. Looks great! Really appreciate the level of detail in the comments you added. In ...
4 years ago (2016-12-14 18:16:02 UTC) #2
dgn
Tested both upstream and downstream, that works, thanks! non owner lgtm
4 years ago (2016-12-15 18:01:22 UTC) #7
mlopatkin
agrieve, PTAL at the latest patch. I have to add a (small) workaround to fix ...
4 years ago (2016-12-19 14:44:42 UTC) #12
agrieve
On 2016/12/19 14:44:42, mlopatkin wrote: > agrieve, PTAL at the latest patch. > > I ...
4 years ago (2016-12-19 15:59:24 UTC) #13
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2570313002/60001
4 years ago (2016-12-19 16:00:31 UTC) #16
commit-bot: I haz the power
Committed patchset #4 (id:60001)
4 years ago (2016-12-19 16:05:14 UTC) #19
commit-bot: I haz the power
4 years ago (2016-12-19 16:09:12 UTC) #21
Message was sent while issue was closed.
Patchset 4 (id:??) landed as
https://crrev.com/d36c048e72f0e936b725d4de25179a7c41599c1a
Cr-Commit-Position: refs/heads/master@{#439485}

Powered by Google App Engine
This is Rietveld 408576698