DescriptionUse 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. #
Messages
Total messages: 21 (13 generated)
|