New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--android_aapt=aapt2 doesn't work on 0.13.0 with aar_import deps #5214

Closed
jin opened this Issue May 18, 2018 · 9 comments

Comments

Projects
None yet
2 participants
@jin
Member

jin commented May 18, 2018

aapt works:

$ bazel build //examples/android/java/bazel:hello_world
WARNING: API level 27 specified by android_ndk_repository 'androidndk' is not available. Using latest known API level 26
INFO: Analysed target //examples/android/java/bazel:hello_world (28 packages loaded).
INFO: Found 1 target...
Target //examples/android/java/bazel:hello_world up-to-date:
  bazel-bin/examples/android/java/bazel/hello_world_deploy.jar
  bazel-bin/examples/android/java/bazel/hello_world_unsigned.apk
  bazel-bin/examples/android/java/bazel/hello_world.apk
INFO: Elapsed time: 26.808s, Critical Path: 14.04s
INFO: 142 processes: 121 linux-sandbox, 12 local, 9 worker.
INFO: Build completed successfully, 206 total actions

aapt2 doesn't:

$ bazel build //examples/android/java/bazel:hello_world --android_aapt=aapt2
WARNING: API level 27 specified by android_ndk_repository 'androidndk' is not available. Using latest known API level 26
INFO: Analysed target //examples/android/java/bazel:hello_world (0 packages loaded).
INFO: Found 1 target...
ERROR: /usr/local/google/home/jingwen/bazels/github/examples/android/java/bazel/BUILD:12:1: Processing Android resources for //examples/android/java/bazel:hello_world failed (Exit 1)
Target //examples/android/java/bazel:hello_world failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 1.920s, Critical Path: 1.64s
INFO: 0 processes.
FAILED: Build did NOT complete successfully

--verbose_failures:

ERROR: /usr/local/google/home/jingwen/bazels/github/examples/android/java/bazel/BUILD:12:1: Processing Android resources for //examples/android/java/bazel:hello_world failed (Exit 1): ResourceProcessorBusyBox failed: error executing command
  (cd /usr/local/google/home/jingwen/.cache/bazel/_bazel_jingwen/c512c74f287f8aa09b4f3666e26c2b04/execroot/io_bazel && \
  exec env - \
    PATH={redacted} \
  bazel-out/host/bin/external/bazel_tools/src/tools/android/java/com/google/devtools/build/android/ResourceProcessorBusyBox --tool AAPT2_PACKAGE -- --aapt2 bazel-out/host/bin/external/androidsdk/aapt2_binary --data bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/_aar/unzipped/resources/support-compat-25.0.0/res:bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/_aar/unzipped/assets/support-compat-25.0.0/assets:bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/support-compat-25.0.0_processed_manifest/AndroidManifest.xml:::bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/support-compat-25.0.0_symbols/local.bin,bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/_aar/unzipped/resources/support-vector-drawable-25.0.0/res:bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/_aar/unzipped/assets/support-vector-drawable-25.0.0/assets:bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/support-vector-drawable-25.0.0_processed_manifest/AndroidManifest.xml:::bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/support-vector-drawable-25.0.0_symbols/local.bin,bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/_aar/unzipped/resources/support-core-ui-25.0.0/res:bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/_aar/unzipped/assets/support-core-ui-25.0.0/assets:bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/support-core-ui-25.0.0_processed_manifest/AndroidManifest.xml:::bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/support-core-ui-25.0.0_symbols/local.bin,bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/_aar/unzipped/resources/support-core-utils-25.0.0/res:bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/_aar/unzipped/assets/support-core-utils-25.0.0/assets:bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/support-core-utils-25.0.0_processed_manifest/AndroidManifest.xml:::bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/support-core-utils-25.0.0_symbols/local.bin,bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/_aar/unzipped/resources/support-media-compat-25.0.0/res:bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/_aar/unzipped/assets/support-media-compat-25.0.0/assets:bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/support-media-compat-25.0.0_processed_manifest/AndroidManifest.xml:::bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/support-media-compat-25.0.0_symbols/local.bin,bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/_aar/unzipped/resources/support-fragment-25.0.0/res:bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/_aar/unzipped/assets/support-fragment-25.0.0/assets:bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/support-fragment-25.0.0_processed_manifest/AndroidManifest.xml:::bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/support-fragment-25.0.0_symbols/local.bin,bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/_aar/unzipped/resources/animated-vector-drawable-25.0.0/res:bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/_aar/unzipped/assets/animated-vector-drawable-25.0.0/assets:bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/animated-vector-drawable-25.0.0_processed_manifest/AndroidManifest.xml:::bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/animated-vector-drawable-25.0.0_symbols/local.bin,bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/_aar/unzipped/resources/support-v4-25.0.0/res:bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/_aar/unzipped/assets/support-v4-25.0.0/assets:bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/support-v4-25.0.0_processed_manifest/AndroidManifest.xml:::bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/support-v4-25.0.0_symbols/local.bin --directData bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/_aar/unzipped/resources/appcompat-v7-25.0.0/res:bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/_aar/unzipped/assets/appcompat-v7-25.0.0/assets:bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/appcompat-v7-25.0.0_processed_manifest/AndroidManifest.xml:::bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/appcompat-v7-25.0.0_symbols/local.bin --primaryData examples/android/java/bazel/res::bazel-out/k8-fastbuild/bin/examples/android/java/bazel/hello_world_merged/hello_world/AndroidManifest.xml --buildToolsVersion 27.0.3 --androidJar external/androidsdk/platforms/android-27/android.jar --rOutput bazel-out/k8-fastbuild/bin/examples/android/java/bazel/hello_world_symbols/R.txt --srcJarOutput bazel-out/k8-fastbuild/bin/examples/android/java/bazel/hello_world.srcjar --proguardOutput bazel-out/k8-fastbuild/bin/examples/android/java/bazel/proguard/hello_world/_hello_world_proguard.cfg --mainDexProguardOutput bazel-out/k8-fastbuild/bin/examples/android/java/bazel/proguard/hello_world/main_dex_hello_world_proguard.cfg --manifestOutput bazel-out/k8-fastbuild/bin/examples/android/java/bazel/hello_world_processed_manifest/AndroidManifest.xml --resourcesOutput bazel-out/k8-fastbuild/bin/examples/android/java/bazel/hello_world_files/resource_files.zip --packagePath bazel-out/k8-fastbuild/bin/examples/android/java/bazel/hello_world.ap_ --debug --packageForR bazel)

Use --sandbox_debug to see verbose messages from the sandbox
Target //examples/android/java/bazel:hello_world failed to build
@jin

This comment has been minimized.

Member

jin commented May 22, 2018

Manual hard crash with stacktrace:

ERROR: /usr/local/google/home/jingwen/code/android_scratch_project/examples/android/java/bazel/BUILD:16:1: Processing Android resources for //examples/android/java/bazel:hello_world failed (Exit 1)
Exception in thread "main" java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.io.IOException: Is a directory
        at com.google.devtools.build.android.aapt2.ResourceLinker.lambda$rethrowLinkError$8(ResourceLinker.java:313)
        at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
        at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
        at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
        at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
        at java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:742)
        at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
        at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
        at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
        at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
        at com.google.devtools.build.android.aapt2.ResourceLinker.compiledResourcesToPaths(ResourceLinker.java:272)
        at com.google.devtools.build.android.aapt2.ResourceLinker.link(ResourceLinker.java:364)
        at com.google.devtools.build.android.Aapt2ResourcePackagingAction.main(Aapt2ResourcePackagingAction.java:180)
        at com.google.devtools.build.android.ResourceProcessorBusyBox$Tool$14.call(ResourceProcessorBusyBox.java:138)
        at com.google.devtools.build.android.ResourceProcessorBusyBox.main(ResourceProcessorBusyBox.java:193)
Caused by: java.util.concurrent.ExecutionException: java.io.IOException: Is a directory
        at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:528)
        at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:489)
        at com.google.common.util.concurrent.AbstractFuture$TrustedFuture.get(AbstractFuture.java:85)
        at com.google.devtools.build.android.aapt2.ResourceLinker.lambda$rethrowLinkError$8(ResourceLinker.java:307)
        ... 15 more
Caused by: java.io.IOException: Is a directory
        at sun.nio.ch.FileDispatcherImpl.pread0(Native Method)
        at sun.nio.ch.FileDispatcherImpl.pread(FileDispatcherImpl.java:52)
        at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:220)
        at sun.nio.ch.IOUtil.read(IOUtil.java:197)
        at sun.nio.ch.FileChannelImpl.readInternal(FileChannelImpl.java:741)
        at sun.nio.ch.FileChannelImpl.read(FileChannelImpl.java:727)
        at com.google.devtools.build.android.ziputils.ZipIn.loadEndOfCentralDirectory(ZipIn.java:473)
        at com.google.devtools.build.android.ziputils.ZipIn.loadCentralDirectory(ZipIn.java:515)
        at com.google.devtools.build.android.ziputils.ZipIn.centralDirectory(ZipIn.java:109)
        at com.google.devtools.build.android.ziputils.ZipIn.scanEntries(ZipIn.java:121)
        at com.google.devtools.build.android.aapt2.ResourceLinker.filterZip(ResourceLinker.java:291)
        at com.google.devtools.build.android.aapt2.ResourceLinker.lambda$compiledResourcesToPaths$5(ResourceLinker.java:268)
        at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:125)
        at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:57)
        at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:78)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Target //examples/android/java/bazel:hello_world failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 20.896s, Critical Path: 6.57s
INFO: 36 processes: 35 linux-sandbox, 1 worker.
FAILED: Build did NOT complete successfully
@jin

This comment has been minimized.

Member

jin commented May 22, 2018

Ok, here's the crashing command:

$ (cd /usr/local/google/home/jingwen/.cache/bazel/_bazel_jingwen/b1f050f5ec8123e101e99c9b5ef847b2/execroot/__main__ && \
   exec env - \
     PATH=/usr/local/google/home/jingwen/bin:/usr/lib/google-golang/bin:/usr/local/buildtools/java/jdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/google/home/jingwen/bin:/usr/local/google/home/jingwen/.fzf/bin:/usr/local/google/home/jingwen/bin \
     bazel-out/host/bin/external/bazel_tools/src/tools/android/java/com/google/devtools/build/android/ResourceProcessorBusyBox
     --debug
     --tool AAPT2_PACKAGE 
     -- 
     --aapt2 bazel-out/host/bin/external/androidsdk/aapt2_binary  
     --data bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/_aar/unzipped/resources/support-compat-25.0.0/res:bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/_aar/unzipped/assets/support-compat-25.0.0/assets:bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/support-compat-25.0.0_processed_manifest/AndroidManifest.xml:::bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/support-compat-25.0.0_symbols/local.bin,bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/_aar/unzipped/resources/support-vector-drawable-25.0.0/res:bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/_aar/unzipped/assets/support-vector-drawable-25.0.0/assets:bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/support-vector-drawable-25.0.0_processed_manifest/AndroidManifest.xml:::bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/support-vector-drawable-25.0.0_symbols/local.bin,bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/_aar/unzipped/resources/support-core-ui-25.0.0/res:bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/_aar/unzipped/assets/support-core-ui-25.0.0/assets:bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/support-core-ui-25.0.0_processed_manifest/AndroidManifest.xml:::bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/support-core-ui-25.0.0_symbols/local.bin,bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/_aar/unzipped/resources/support-core-utils-25.0.0/res:bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/_aar/unzipped/assets/support-core-utils-25.0.0/assets:bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/support-core-utils-25.0.0_processed_manifest/AndroidManifest.xml:::bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/support-core-utils-25.0.0_symbols/local.bin,bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/_aar/unzipped/resources/support-media-compat-25.0.0/res:bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/_aar/unzipped/assets/support-media-compat-25.0.0/assets:bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/support-media-compat-25.0.0_processed_manifest/AndroidManifest.xml:::bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/support-media-compat-25.0.0_symbols/local.bin,bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/_aar/unzipped/resources/support-fragment-25.0.0/res:bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/_aar/unzipped/assets/support-fragment-25.0.0/assets:bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/support-fragment-25.0.0_processed_manifest/AndroidManifest.xml:::bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/support-fragment-25.0.0_symbols/local.bin,bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/_aar/unzipped/resources/animated-vector-drawable-25.0.0/res:bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/_aar/unzipped/assets/animated-vector-drawable-25.0.0/assets:bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/animated-vector-drawable-25.0.0_processed_manifest/AndroidManifest.xml:::bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/animated-vector-drawable-25.0.0_symbols/local.bin,bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/_aar/unzipped/resources/support-v4-25.0.0/res:bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/_aar/unzipped/assets/support-v4-25.0.0/assets:bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/support-v4-25.0.0_processed_manifest/AndroidManifest.xml:::bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/support-v4-25.0.0_symbols/local.bin
     --directData bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/_aar/unzipped/resources/appcompat-v7-25.0.0/res:bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/_aar/unzipped/assets/appcompat-v7-25.0.0/assets:bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/appcompat-v7-25.0.0_processed_manifest/AndroidManifest.xml:::bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/appcompat-v7-25.0.0_symbols/local.bin
     --primaryData examples/android/java/bazel/res::bazel-out/k8-fastbuild/bin/examples/android/java/bazel/hello_world_merged/hello_world/AndroidManifest.xml
     --buildToolsVersion 28.0.0-rc2 
     --androidJar external/androidsdk/platforms/android-27/android.jar 
     --rOutput bazel-out/k8-fastbuild/bin/examples/android/java/bazel/hello_world_symbols/R.txt
     --srcJarOutput bazel-out/k8-fastbuild/bin/examples/android/java/bazel/hello_world.srcjar
     --proguardOutput bazel-out/k8-fastbuild/bin/examples/android/java/bazel/proguard/hello_world/_hello_world_proguard.cfg
     --mainDexProguardOutput bazel-out/k8-fastbuild/bin/examples/android/java/bazel/proguard/hello_world/main_dex_hello_world_proguard.cfg
     --manifestOutput bazel-out/k8-fastbuild/bin/examples/android/java/bazel/hello_world_processed_manifest/AndroidManifest.xml
     --resourcesOutput bazel-out/k8-fastbuild/bin/examples/android/java/bazel/hello_world_files/resource_files.zip
     --packagePath bazel-out/k8-fastbuild/bin/examples/android/java/bazel/hello_world.ap_
     --debug 
     --packageForR bazel)
$ echo $?
1

According to DependencyAndroidData (https://github.com/bazelbuild/bazel/blob/d18d3e2f83f9d582858a3edab7a450c60044028c/src/tools/android/java/com/google/devtools/build/android/DependencyAndroidData.java), the EXPECTED_FORMAT for --data and --directData arguments is:

public static final String EXPECTED_FORMAT =
      "resources[#resources]:assets[#assets]:manifest:r.txt(:symbols.zip?):symbols.bin";

However, the actual arguments are missing R.txt, e.g.

--directData bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/_aar/unzipped/resources/appcompat-v7-25.0.0/res:bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/_aar/unzipped/assets/appcompat-v7-25.0.0/assets:bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/appcompat-v7-25.0.0_processed_manifest/AndroidManifest.xml:::bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/appcompat-v7-25.0.0_symbols/local.bin

DependencyAndroidData#valueOf assumes that rTxt exists, but in this case, it's missing. The regex still passes because ::: matches :.+(:.*){0, 2}.

@asteinb @corbinrsmith-work I'm still not quite familiar with resource processing -- is rTxt required for DependencyAndroidData here?

@jin jin added the P1 label May 22, 2018

@jin

This comment has been minimized.

Member

jin commented May 22, 2018

Ok, it definitely seems like R.txt is required by isn't constructed at the command line in AndroidResourcesProcessorBuilder.

@jin jin added P0 and removed P1 labels May 22, 2018

@jin

This comment has been minimized.

Member

jin commented May 22, 2018

Bumping to P0, this is an important component of Android builds and should be fixed asap.

@jin

This comment has been minimized.

Member

jin commented May 25, 2018

Using --experimental_skip_parsing_action, we get ArrayIndexOutOfBoundsException in DependencyAndroidData#valueOf because R.txt is missing:

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 3
        at com.google.devtools.build.android.DependencyAndroidData.valueOf(DependencyAndroidData.java:62)
        at com.google.devtools.build.android.DependencyAndroidData.valueOf(DependencyAndroidData.java:51)
        at com.google.devtools.build.android.Converters$DependencyAndroidDataListConverter.convert(Converters.java:117)
        at com.google.devtools.build.android.Converters$DependencyAndroidDataListConverter.convert(Converters.java:106)
        at com.google.devtools.common.options.ParsedOptionDescription.getConvertedValue(ParsedOptionDescription.java:170)
        at com.google.devtools.common.options.OptionValueDescription$SingleOptionValueDescription.addOptionInstance(OptionValueDescription.java:180)
        at com.google.devtools.common.options.OptionsParserImpl.handleNewParsedOption(OptionsParserImpl.java:403)
        at com.google.devtools.common.options.OptionsParserImpl.parse(OptionsParserImpl.java:342)
        at com.google.devtools.common.options.OptionsParserImpl.parse(OptionsParserImpl.java:277)
        at com.google.devtools.common.options.OptionsParser.parseWithSourceFunction(OptionsParser.java:614)
        at com.google.devtools.common.options.OptionsParser.parse(OptionsParser.java:588)
        at com.google.devtools.common.options.OptionsParser.parseAndExitUponError(OptionsParser.java:229)
        at com.google.devtools.common.options.OptionsParser.parseAndExitUponError(OptionsParser.java:210)
        at com.google.devtools.build.android.Aapt2ResourcePackagingAction.main(Aapt2ResourcePackagingAction.java:68)
        at com.google.devtools.build.android.ResourceProcessorBusyBox$Tool$14.call(ResourceProcessorBusyBox.java:138)
        at com.google.devtools.build.android.ResourceProcessorBusyBox.main(ResourceProcessorBusyBox.java:193)
invalid DependencyAndroidData: bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/_aar/unzipped/resources/support-compat-25.0.0/res:bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/_aar/unzipped/assets/support-compat-25.0.0/assets:bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/support-compat-25.0.0_processed_manifest/AndroidManifest.xml:: is not in the format 'resources[#resources]:assets[#assets]:manifest:r.txt(:symbols.zip?):symbols.bin'
Try --help.

@jin jin changed the title from --android_aapt=aapt2 doesn't work on 0.13.0 to --android_aapt=aapt2 doesn't work on 0.13.0 with `aar_import` deps May 25, 2018

@jin

This comment has been minimized.

Member

jin commented May 25, 2018

Ok, narrowed it down to just aar_import targets.

@jin jin changed the title from --android_aapt=aapt2 doesn't work on 0.13.0 with `aar_import` deps to --android_aapt=aapt2 doesn't work on 0.13.0 with aar_import deps May 25, 2018

@jin jin added P1 and removed P0 labels May 25, 2018

@aj-michael

This comment has been minimized.

Contributor

aj-michael commented May 25, 2018

AFAIK aar_import completely ignores the R.txt. It’s not unpacked anywhere

bazel-io pushed a commit that referenced this issue May 31, 2018

Improve DependencyAndroidData VALID_REGEX's robustness.
This prevents an invalid flag like `resources:assets:AndroidManifest.xml:::local.bin` to match, as with the case in #5214
where the R.txt file is missing (shouldn't happen, but let's be defensive)

Error message:

```
.. invalid DependencyAndroidData: bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/_aar/unzipped/resources/support-compat-25.0.0/res:bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/_aar/unzipped/assets/support-compat-25.0.0/assets:bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/support-compat-25.0.0_processed_manifest/AndroidManifest.xml:::bazel-out/android-armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/support-compat-25.0.0_symbols/local.bin is not in the format 'resources[#resources]:assets[#assets]:manifest:r.txt(:symbols.zip?):symbols.bin'
```

RELNOTES: None.
PiperOrigin-RevId: 198724816
@jin

This comment has been minimized.

Member

jin commented May 31, 2018

@aj-michael that explains it, thanks. Looks like we'll need to hook up aapt2 to compile/link resources in the imported AAR and expose R.aapt2.txt downstream.

@jin

This comment has been minimized.

Member

jin commented Jul 18, 2018

@jin jin closed this Jul 18, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment