New issue
Advanced search Search tips

Issue 702606 link

Starred by 2 users

Issue metadata

Status: Archived
Owner: ----
Closed: Jan 14
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 3
Type: ----



Sign in to add a comment

Adding a dependency on an 'android_aar_prebuilt' for an aar file with an empty res folder and an R.txt causes the build to fail

Reported by mmcma...@jana.com, Mar 17 2017

Issue description

Discovered trying to add a dependency on 'firebase-jobdispatcher-with-gcm-dep-0.5.2.aar'.  An aar that has both an R.txt and an emptyres folder in the archive will cause the build to fail when added as a dependency.

Steps to reproduce:
1. Add firebase-jobdispatcher-with-gcm-dep-0.5.2.aar to the project

  Download http://jcenter.bintray.com/com/firebase/firebase-jobdispatcher-with-gcm-dep/0.5.2/firebase-jobdispatcher-with-gcm-dep-0.5.2.aar
  Save in src/third_party/my_includes

2. Create a src/third_party/my_includes/BUILD.gn
  # ########################		
  import("//build/config/android/rules.gni")

  android_aar_prebuilt("firebase_job_dispatcher_with_gcm_dep_java") {
    aar_path = "./firebase-jobdispatcher-with-gcm-dep-0.5.2.aar"
    ignore_manifest = true
  }

3. Add the depdendency to the src/chrome/android/BUIlD.gn

  Add this to the deps of the android_library("chrome_java")
    "//third_party/my_includes:firebase_job_dispatcher_with_gcm_dep_java"

4. Run the build
    gn gen --args='target_os="android"' out/Default
    ninja -C out/Default chrome_public_apk


Result:
ninja: Entering directory `out/Default'
[15/231] ACTION //third_party/my_includes:firebase_job_dispatcher_with_gcm_dep_java__res__process_resources(//build/toolchain/android:android_arm)
FAILED: gen/third_party/my_includes/firebase_job_dispatcher_with_gcm_dep_java__res.resources.zip gen/third_party/my_includes/firebase_job_dispatcher_with_gcm_dep_java__res.srcjar gen/third_party/my_includes/firebase_job_dispatcher_with_gcm_dep_java__res_R.txt
python ../../build/android/gyp/process_resources.py --depfile gen/third_party/my_includes/firebase_job_dispatcher_with_gcm_dep_java__res__process_resources.d --android-sdk-jar ../../third_party/android_tools/sdk/platforms/android-24/android.jar --aapt-path ../../third_party/android_tools/sdk/build-tools/24.0.2/aapt --android-manifest gen/third_party/my_includes/firebase_job_dispatcher_with_gcm_dep_java/AndroidManifest.xml --resource-dirs=\[\"gen/third_party/my_includes/firebase_job_dispatcher_with_gcm_dep_java/res\"\] --srcjar-out gen/third_party/my_includes/firebase_job_dispatcher_with_gcm_dep_java__res.srcjar --resource-zip-out gen/third_party/my_includes/firebase_job_dispatcher_with_gcm_dep_java__res.resources.zip --r-text-out gen/third_party/my_includes/firebase_job_dispatcher_with_gcm_dep_java__res_R.txt --dependencies-res-zips=@FileArg\(gen/third_party/my_includes/firebase_job_dispatcher_with_gcm_dep_java__res.build_config:resources:dependency_zips\) --extra-res-packages=@FileArg\(gen/third_party/my_includes/firebase_job_dispatcher_with_gcm_dep_java__res.build_config:resources:extra_package_names\) --extra-r-text-files=@FileArg\(gen/third_party/my_includes/firebase_job_dispatcher_with_gcm_dep_java__res.build_config:resources:extra_r_text_files\) --r-text-in gen/third_party/my_includes/firebase_job_dispatcher_with_gcm_dep_java/R.txt --non-constant-id --v14-skip --shared-resources
Traceback (most recent call last):
  File "../../build/android/gyp/process_resources.py", line 574, in <module>
    main(sys.argv[1:])
  File "../../build/android/gyp/process_resources.py", line 570, in main
    force=options.R_dir)
  File "/home/matt/jana/chromium/src/build/android/gyp/util/build_utils.py", line 583, in CallAndWriteDepfileIfStale
    pass_changes=True)
  File "/home/matt/jana/chromium/src/build/android/gyp/util/md5_check.py", line 87, in CallAndRecordIfStale
    function(*args)
  File "/home/matt/jana/chromium/src/build/android/gyp/util/build_utils.py", line 566, in on_stale_md5
    function(*args)
  File "../../build/android/gyp/process_resources.py", line 564, in <lambda>
    lambda: _OnStaleMd5(options),
  File "../../build/android/gyp/process_resources.py", line 454, in _OnStaleMd5
    build_utils.CheckOutput(package_command, print_stderr=False)
  File "/home/matt/jana/chromium/src/build/android/gyp/util/build_utils.py", line 170, in CheckOutput
    raise CalledProcessError(cwd, args, stdout + stderr)
util.build_utils.CalledProcessError: Command failed: ( cd /home/matt/jana/chromium/src/out/Default; ../../third_party/android_tools/sdk/build-tools/24.0.2/aapt package -m -M gen/third_party/my_includes/firebase_job_dispatcher_with_gcm_dep_java/AndroidManifest.xml --auto-add-overlay --no-version-vectors -I ../../third_party/android_tools/sdk/platforms/android-24/android.jar --output-text-symbols /tmp/tmp9Ogkmk/gen -J /tmp/tmp9Ogkmk/gen --ignore-assets '!OWNERS:!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~:!*.d.stamp' -S gen/third_party/my_includes/firebase_job_dispatcher_with_gcm_dep_java/res )
ERROR: resource directory 'gen/third_party/my_includes/firebase_job_dispatcher_with_gcm_dep_java/res' does not exist

[17/231] ACTION //components/resources:about_credits(//build/toolchain/android:android_arm)


Looking at the contents of the exploded aar, there is a R.txt file and an empty res folder. The presence of the R.txt causes the android_aar_prebuilt template defined in /build/config/android/rules.gni to create the android_resources target, adding this setting:

generated_resource_dirs = [ "${_output_path}/res" ]

That res folder does not get created in the gen 'gen/third_party/my_includes/firebase_job_dispatcher_with_gcm_dep_java'.  This is because the build/android/gyp/util/build_utils.ExtractAll skips any file name that ends with '/' without extracting it:

  with zipfile.ZipFile(zip_path) as z:
    for name in z.namelist():
      if name.endswith('/'):
        continue

As a result empty directories are not extracted.


After applying this change the build succeeds:

diff --git a/build/config/android/rules.gni b/build/config/android/rules.gni
index ba8930f..bf522c6 100644
--- a/build/config/android/rules.gni
+++ b/build/config/android/rules.gni
@@ -2813,9 +2813,11 @@ if (enable_java_templates) {
         }
         deps += [ ":$_unpack_target_name" ]
         resource_dirs = []
-        generated_resource_dirs = [ "${_output_path}/res" ]
-        generated_resource_files =
-            rebase_path(_scanned_files.resources, "", _output_path)
+        if (_scanned_files.resources != []) {
+          generated_resource_dirs = [ "${_output_path}/res" ]
+          generated_resource_files =
+              rebase_path(_scanned_files.resources, "", _output_path)
+        }
         android_manifest_dep = ":$_unpack_target_name"
         android_manifest = "${_output_path}/AndroidManifest.xml"
         if (_scanned_files.has_r_text_file) {

 

Comment 1 Deleted

Cc: kozyatinskiy@chromium.org caseq@chromium.org
Components: Platform>DevTools
Status: Available (was: Unconfirmed)

Comment 3 by mmcma...@jana.com, Mar 17 2017

CL Review Link https://codereview.chromium.org/2759683002
Components: -Platform>DevTools Build
Platform>DevTools is for Chrome Developer Tools, how this is related to DevTools? Forwarded to Build.

Comment 5 by caseq@chromium.org, Mar 17 2017

Cc: -caseq@chromium.org
Cc: -kozyatinskiy@chromium.org
Project Member

Comment 7 by sheriffbot@chromium.org, Mar 28 2018

Labels: Hotlist-Recharge-Cold
Status: Untriaged (was: Available)
This issue has been Available for over a year. If it's no longer important or seems unlikely to be fixed, please consider closing it out. If it is important, please re-triage the issue.

Sorry for the inconvenience if the bug really should have been left as Available.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Status: Archived (was: Untriaged)

Sign in to add a comment