Skip to content
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 Support Library was removed from recent Android SDKs #1745

Closed
aj-michael opened this issue Sep 8, 2016 · 28 comments
Closed

Android Support Library was removed from recent Android SDKs #1745

aj-michael opened this issue Sep 8, 2016 · 28 comments
Assignees
Labels
P1 I'll work on this now. (Assignee required) type: bug
Milestone

Comments

@aj-michael
Copy link
Contributor

Android Support Library was removed from recent Android SDKs [1] in favor of Android Support Repository, a local maven repository of AARs.

Because of this, the appcompat_{v4,v7,v7_import,v13} targets in https://github.com/bazelbuild/bazel/blob/master/tools/android/android_sdk_repository_template.bzl are broken.

Bazel does not yet support importing AARs (see #564) so the only current workaround for users is to get the necessary AARs from their Android SDK, unzip them into their component JARs and resources and wrap these in java_imports and android_libraries.

[1] I can't find a changelog that shows how recent.

@aj-michael aj-michael self-assigned this Sep 8, 2016
@kchodorow kchodorow added type: bug P2 We'll consider working on this in future. (Assignee optional) labels Sep 9, 2016
bazel-io pushed a commit that referenced this issue Sep 14, 2016
…. Currently only uses AndroidManifest.xml, classes.jar and res/ from AARs. This is sufficient for many of the AARs of Google Play Services and Android Support Repository.

The next step will be for AndroidSdkRepositoryRule to scan the SDK and generate aar_import rules for the AARs within.

The rule is not yet documented because it is not intended for end users to use it yet. We should probably support more of the features of AARs before that time. See http://tools.android.com/tech-docs/new-build-system/aar-format for all of the files that can be included in AARs.

Also note that R.txt from the AAR is intentionally ignored and regenerated based on the contents of res/. This is more correct, because the R.txt inside of an AAR can contain ids for dependencies of the AAR that are not included in res/.

See #564 for discussion of supporting AARs and #1745 for motivation to get it done soon.

--
MOS_MIGRATED_REVID=133127933
bazel-io pushed a commit that referenced this issue Oct 11, 2016
…s in <sdk>/extras for sdk in android_sdk_repository.

Addresses #1745.

--
MOS_MIGRATED_REVID=135679008
@aj-michael
Copy link
Contributor Author

aj-michael commented Oct 11, 2016

As of 2fcf0e4, if your WORKSPACE contains android_sdk_repository, the contents of your Android SDK extras/ directory will be scanned for libraries and aar_import and java_import rules generated for them.

You can put these rules in the deps of your android_library and android_binary as such:

# WORKSPACE
android_sdk_repository(
    name = "androidsdk",
    path = "/path/to/Android/Sdk",
    build_tools_version = "24.0.0",
    api_level = 24,
)
# BUILD
android_binary(
    name = "myapp",
    ...
    deps = [
        "@androidsdk//com.android.support:mediarouter-v7-24.0.0",
        "@androidsdk//com.google.firebase:firebase-ads-9.6.1",
    ],
)

The label format is

@<name of android_sdk_repository>//<group id>:<artifact id>-<version>

@zvh
Copy link

zvh commented Oct 11, 2016

Thanks so much for working on this! I have tried it in my project and am experiencing an error:

ERROR: /usr/local/google/home/zachh/.cache/bazel/_bazel_zachh/8b6a25785bcaef089bf3e18c1286d461/external/androidsdk/com.android.support/BUILD:2982:1: Processing Android resources for @androidsdk//com.android.support:support-compat-24.2.1 failed: linux-sandbox failed: error executing command /usr/local/google/home/zachh/.cache/bazel/_bazel_zachh/8b6a25785bcaef089bf3e18c1286d461/execroot/tmp1FQaA6/_bin/linux-sandbox ... (remaining 27 argument(s) skipped).
Error parsing command line: While parsing option --primaryData: invalid UnvalidatedAndroidData: bazel-out/android-stub_armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/_aar/unzipped/support-compat-24.2.1 does not exist

I haven't tried creating a minimal repro case but can try to do that if necessary, thanks!

@aj-michael
Copy link
Contributor Author

Hi @zvh, sorry about the error. That is a bug that I am aware of with the Bazel sandbox that I forgot to mention here. The workaround is to use --spawn_strategy=standalone when you build.

I will file another GitHub issue that tracks this. The problem is as follows:

aar_import is one of the first rules to use a new Bazel feature called TreeArtifacts. TreeArtifacts represent directories that are inputs and outputs of actions. The Bazel sandbox is responsible for ensuring that only the appropriate input files are accessible to actions. However, if the input artifact to an action is an empty tree artifact, the sandbox does not create the empty directory which utlimately causes the "Processing Android resources error" that you've encountered.

Please let me know if --spawn_strategy=standalone works for you.

@aj-michael
Copy link
Contributor Author

I've filed #1928 to track this issue.

@zvh
Copy link

zvh commented Oct 11, 2016

Thank you @aj-michael, that flag seems to get me past that error.

However, I am now getting a different compilation error:

ERROR: /tmp/tmp1FQaA6/java/com/android/dialer/common/BUILD:7:1: Java compilation in rule '//java/com/android/dialer/common:common' failed: Worker process sent response with exit code: 1.
java/com/android/dialer/common/FragmentUtils.java:87: error: cannot access ActivityCompatApi23
? frag.getActivity().getClass().getName()
^
class file for android.support.v4.app.ActivityCompatApi23 not found

If it's useful, when I was looking into extracting the .aar files myself, I think I found that this class was part of the internal_impl-24.2.0.jar in the libs directory (of support-compat)

bazel-io pushed a commit that referenced this issue Oct 12, 2016
*** Reason for rollback ***

Breaks android_integration_test, see #1927

*** Original change description ***

Generate aar_import and java_import rules for local maven repositories in <sdk>/extras for sdk in android_sdk_repository.

Addresses #1745.

--
MOS_MIGRATED_REVID=135926334
@aj-michael
Copy link
Contributor Author

Ah, unfortunately aar_import currently only gets classes.jar, AndroidManifest.xml and res/* from the AAR. I am working on adding support for jni/* and libs/*, but that is not available yet. As you mentioned, support-compat uses an internal jar for ActivityCompatApi23.

@aj-michael
Copy link
Contributor Author

Of course, if you want to get it working, you can extract that jar, and put a java_import of it in the deps of your android_binary.

@aj-michael
Copy link
Contributor Author

I should note, unfortunately this change was rolled back due to #1927. I am working on rolling it forward soon.

bazel-io pushed a commit that referenced this issue Oct 27, 2016
*** Reason for rollback ***

Rollforward with fixes for android_integration_test.sh

*** Original change description ***

Automated [] rollback of commit 2fcf0e4.

*** Reason for rollback ***

Breaks android_integration_test, see #1927

*** Original change description ***

Generate aar_import and java_import rules for local maven repositories in <sdk>/extras for sdk in android_sdk_repository.

Addresses #1745.

--
MOS_MIGRATED_REVID=137407118
@aj-michael
Copy link
Contributor Author

Oops, I meant to update this thread when the commit went through. The Android Support Libraries should be good to go as described earlier in this bug. Note however, that --spawn_strategy=standalone is still needed.

bazel-io pushed a commit that referenced this issue Nov 30, 2016
In December 2015, these JARs needed for these targets were removed from all subsequent Android SDK releases. They were replaced by a two local maven repositories:
<android sdk>/extras/android/m2repository and <android sdk>/extras/google/m2repository. Furthermore, the new dependencies are AARs and the Maven repositories are sem-ver'd so the developer needs to select the version of the library to use.

In 2fcf0e I added support for android_sdk_repository to parse these local maven repositories and generate java_import and aar_import rules along with their dependencies.

Since these "extras" do not ship with the SDK by default and are not versioned with the build-tools, you cannot currently download the old JAR versions. As such, anyone who has updated their Android SDK in the last year should not have been able to download the old JARs.

See #1745 for the tracking issue and information on migrating from the old targets to the new ones.

RELNOTES: Top level @AndroidSDK support library targets have been replaced by @androidsdk//<group id>:<artifact id>-<version> for Android SDK Support and Google Play Services libraries.

--
MOS_MIGRATED_REVID=140562616
@aj-michael
Copy link
Contributor Author

Ok, marking this as fixed.

@zvh
Copy link

zvh commented Dec 6, 2016

@aj-michael, I just tried syncing to head and removing --spawn_strategy but I get:

> /usr/local/google/github/bazel/bazel-bin/src/bazel build    --experimental_android_use_singlejar_for_multidex   java/com/android/dialer
.
INFO: Found 1 target...
ERROR: /usr/local/google/home/zachh/.cache/bazel/_bazel_zachh/5d48db0541e6f14eaa26f2867879638e/external/androidsdk/com.android.support/BUILD:3390:1: Merging AAR embedded jars failed: I/O error during sandboxed execution: /usr/local/google/home/zachh/.cache/bazel/_bazel_zachh/5d48db0541e6f14eaa26f2867879638e/bazel-sandbox/095c0713-769b-4650-8135-ece4e8828fef-85/execroot/tmpjoTlzF/bazel-out/android-stub_armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/_aar/unzipped/jars/support-fragment-25.0.0 (Directory not empty).
WARNING: Cannot delete sandbox directory after action execution: /usr/local/google/home/zachh/.cache/bazel/_bazel_zachh/5d48db0541e6f14eaa26f2867879638e/bazel-sandbox/095c0713-769b-4650-8135-ece4e8828fef-88 (java.io.IOException: /usr/local/google/home/zachh/.cache/bazel/_bazel_zachh/5d48db0541e6f14eaa26f2867879638e/bazel-sandbox/095c0713-769b-4650-8135-ece4e8828fef-88/execroot/tmpjoTlzF (Device or resource busy)).
WARNING: Cannot delete sandbox directory after action execution: /usr/local/google/home/zachh/.cache/bazel/_bazel_zachh/5d48db0541e6f14eaa26f2867879638e/bazel-sandbox/095c0713-769b-4650-8135-ece4e8828fef-80 (java.io.IOException: /usr/local/google/home/zachh/.cache/bazel/_bazel_zachh/5d48db0541e6f14eaa26f2867879638e/bazel-sandbox/095c0713-769b-4650-8135-ece4e8828fef-80/execroot/tmpjoTlzF (Device or resource busy)).
Target //java/com/android/dialer:dialer failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 11.853s, Critical Path: 3.94s

@aj-michael
Copy link
Contributor Author

Ah, shucks. Thanks for the report @zvh. I suspect the issue here is that the sandbox does not create the output directory that the action then populates, whereas without the sandbox, the directory is created in advance. 216410b is most likely the culprit.

@aj-michael aj-michael reopened this Dec 6, 2016
@aj-michael
Copy link
Contributor Author

Ok, the actual problem is that 3f008a0 unconditionally mounts TreeArtifacts into the Bazel sandbox as directories. However, if the TreeArtifact is not empty, the contained Artifacts are symlinked first, resulting in a ERR_DIRECTORY_NOT_EMPTY when we try to symlink the TreeArtifact directory. I have a fix for this.

@aj-michael aj-michael added this to the 0.5 milestone Dec 9, 2016
@ahumesky ahumesky added P1 I'll work on this now. (Assignee required) and removed P2 We'll consider working on this in future. (Assignee optional) labels Dec 12, 2016
@aj-michael
Copy link
Contributor Author

Ok, b5f480c should have fixed this once and for all.

@coroner4817
Copy link

Hi I still facing this not find support package issue. My bazel is 0.4.4

➜  NDKjniTest-bazel bazel build --strategy=AndroidAapt=standalone //app:ndkjnitest
WARNING: Bazel Android NDK crosstools are based on Android NDK revision 12. The revision of the Android NDK given in android_ndk_repository rule 'androidndk' is '14.0.3675639-beta2'.
INFO: Found 1 target...
ERROR: /Users/YingnanWang/Documents/EE202B/android/NDKjniTest-bazel/app/BUILD:7:1: Java compilation in rule '//app:android_core' failed: Worker process sent response with exit code: 1.
app/src/main/java/com/yingnanwang/ndkjnitest/MainActivity.java:3: error: package android.support.v7.app does not exist
import android.support.v7.app.AppCompatActivity;
                             ^app/src/main/java/com/yingnanwang/ndkjnitest/MainActivity.java:8: error: cannot find symbol
public class MainActivity extends AppCompatActivity {
                                  ^
  symbol: class AppCompatActivityapp/src/main/java/com/yingnanwang/ndkjnitest/MainActivity.java:11: error: method does not override or implement a method from a supertype
    @Override
    ^app/src/main/java/com/yingnanwang/ndkjnitest/MainActivity.java:13: error: cannot find symbol
        super.onCreate(savedInstanceState);
        ^
  symbol:   variable super
  location: class MainActivityapp/src/main/java/com/yingnanwang/ndkjnitest/MainActivity.java:14: error: cannot find symbol
        setContentView(R.layout.activity_main);
        ^
  symbol:   method setContentView(int)
  location: class MainActivityapp/src/main/java/com/yingnanwang/ndkjnitest/MainActivity.java:17: error: cannot find symbol
        TextView tv = (TextView) findViewById(R.id.sample_text);
                                 ^
  symbol:   method findViewById(int)
  location: class MainActivityTarget //app:ndkjnitest failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 13.558s, Critical Path: 8.71s

@aj-michael
Copy link
Contributor Author

Hi @coroner4817 , can you please open a separate github issue containing the contents of your BUILD file and WORKSPACE file and that stack trace?

@charafau
Copy link

charafau commented Apr 4, 2017

Hi @aj-michael I tried new way of doing this but I still get an error :

➜  bazel bazel build //BazelTest  --verbose_failures
INFO: Found 1 target...
ERROR: /private/var/tmp/_bazel_charafau/6654ac68c72738dc646a201633d60c3b/external/androidsdk/com.android.support/BUILD:4463:1: Processing Android resources for @androidsdk//com.android.support:support-core-utils-25.3.1 failed: ResourceProcessorBusyBox failed: error executing command
  (exec env - \
  bazel-out/host/bin/external/bazel_tools/src/tools/android/java/com/google/devtools/build/android/ResourceProcessorBusyBox --tool PACKAGE -- --buildToolsVersion 25.0.2 --aapt bazel-out/host/bin/external/androidsdk/aapt_binary --annotationJar external/androidsdk/tools/support/annotations.jar --androidJar external/androidsdk/platforms/android-25/android.jar --primaryData bazel-out/android-stub_armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/_aar/unzipped/resources/support-core-utils-25.3.1::bazel-out/android-stub_armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/_aar/support-core-utils-25.3.1/AndroidManifest.xml --directData bazel-out/android-stub_armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/_aar/unzipped/resources/support-compat-25.3.1::bazel-out/android-stub_armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/support-compat-25.3.1_processed_manifest/AndroidManifest.xml:bazel-out/android-stub_armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/support-compat-25.3.1_symbols/R.txt:bazel-out/android-stub_armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/support-compat-25.3.1_symbols/symbols.bin --packageType LIBRARY --rOutput bazel-out/android-stub_armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/support-core-utils-25.3.1_symbols/R.txt --symbolsOut bazel-out/android-stub_armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/support-core-utils-25.3.1_symbols/symbols.bin --srcJarOutput bazel-out/android-stub_armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/support-core-utils-25.3.1.srcjar --manifestOutput bazel-out/android-stub_armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/support-core-utils-25.3.1_processed_manifest/AndroidManifest.xml --resourcesOutput bazel-out/android-stub_armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/support-core-utils-25.3.1_files/resource_files.zip '--useAaptCruncher=no' --debug)

Use --sandbox_debug to see verbose messages from the sandbox.
Error parsing command line: While parsing option --primaryData: invalid UnvalidatedAndroidData: bazel-out/android-stub_armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/_aar/unzipped/resources/support-core-utils-25.3.1 does not exist
Try --help.
Use --strategy=AndroidAapt=standalone to disable sandboxing for the failing actions.
Target //BazelTest:BazelTest failed to build

my workspace:

➜  bazel cat WORKSPACE
android_sdk_repository(
    name = "androidsdk",
    # Replace with your installed Android SDK API level
    api_level = 25,
    path="/Users/charafau/Utils/android-sdk",
    build_tools_version = "25.0.2",
)

my BUILD

➜  bazel cat BazelTest/buILD
android_binary(
    name = "BazelTest",
    custom_package = "com.nullpointerbay.bazeltest",
    manifest = "app/src/main/AndroidManifest.xml",
    resource_files = glob(["app/src/main/res/**"]),
    visibility = ["//visibility:public"],
    deps = [":activities",
            "@androidsdk//com.android.support:appcompat-v7-25.3.1",
    ],
)

android_library(
    name = "activities",
    srcs = glob(["app/src/main/java/com/nullpointerbay/bazel/bazeltest/*.java"]),
    custom_package = "com.nullpointerbay.bazeltest",
    manifest = "app/src/main/AndroidManifest.xml",
    resource_files = glob(["app/src/main/res/**"]),
)

I'm new to bazel so maybe I'm doing something wrong.

@aj-michael
Copy link
Contributor Author

Hey @charafau, that definitely looks like the same error that other people reported here.

What is the output of bazel version and what is your OS?

@charafau
Copy link

charafau commented Apr 4, 2017

I'm using OSX 10.12.4 (16E195) with bazel Build label: 0.4.5-homebrew

@aj-michael
Copy link
Contributor Author

Ah, I am forgetful today. This was reported in a separate issue (see #2597). It was a bug in the OS X implementation. I checked in a fix a month ago in acdd43b but unfortunately it just missed the cut-off for bazel 0.4.5. The fix will be in the next Bazel release.

If you want to get unblocked, you can build Bazel from head following these instructions:

git clone https://github.com/bazelbuild/bazel
cd bazel
bazel build //src:bazel
bazel_with_fix=$(pwd)/bazel-bin/src/bazel

@charafau
Copy link

charafau commented Apr 4, 2017

Thank you for answer. I tried your solution but still got error:

➜  BazelTest bazel_fix build //BazelTest  --verbose_failures
WARNING: /private/var/tmp/_bazel_charafau/6654ac68c72738dc646a201633d60c3b/external/bazel_tools/tools/cpp/cc_configure.bzl:57:3:
Auto-Configuration Warning: 'ABI_VERSION' environment variable is not set, using 'local' as default
.
WARNING: /private/var/tmp/_bazel_charafau/6654ac68c72738dc646a201633d60c3b/external/bazel_tools/tools/cpp/cc_configure.bzl:57:3:
Auto-Configuration Warning: 'ABI_LIBC_VERSION' environment variable is not set, using 'local' as default
.
WARNING: /private/var/tmp/_bazel_charafau/6654ac68c72738dc646a201633d60c3b/external/bazel_tools/tools/cpp/cc_configure.bzl:57:3:
Auto-Configuration Warning: 'BAZEL_COMPILER' environment variable is not set, using 'compiler' as default
.
WARNING: /private/var/tmp/_bazel_charafau/6654ac68c72738dc646a201633d60c3b/external/bazel_tools/tools/cpp/cc_configure.bzl:57:3:
Auto-Configuration Warning: 'BAZEL_HOST_SYSTEM' environment variable is not set, using 'local' as default
.
WARNING: /private/var/tmp/_bazel_charafau/6654ac68c72738dc646a201633d60c3b/external/bazel_tools/tools/cpp/cc_configure.bzl:57:3:
Auto-Configuration Warning: 'BAZEL_TARGET_CPU' environment variable is not set, using 'darwin' as default
.
WARNING: /private/var/tmp/_bazel_charafau/6654ac68c72738dc646a201633d60c3b/external/bazel_tools/tools/cpp/cc_configure.bzl:57:3:
Auto-Configuration Warning: 'BAZEL_TARGET_SYSTEM' environment variable is not set, using 'local' as default
.
WARNING: /private/var/tmp/_bazel_charafau/6654ac68c72738dc646a201633d60c3b/external/bazel_tools/tools/cpp/cc_configure.bzl:57:3:
Auto-Configuration Warning: 'BAZEL_COMPILER' environment variable is not set, using 'compiler' as default
.
WARNING: /private/var/tmp/_bazel_charafau/6654ac68c72738dc646a201633d60c3b/external/bazel_tools/tools/cpp/cc_configure.bzl:57:3:
Auto-Configuration Warning: 'CC_TOOLCHAIN_NAME' environment variable is not set, using 'local' as default
.
WARNING: /private/var/tmp/_bazel_charafau/6654ac68c72738dc646a201633d60c3b/external/bazel_tools/tools/cpp/cc_configure.bzl:57:3:
Auto-Configuration Warning: 'CC_TOOLCHAIN_NAME' environment variable is not set, using 'local' as default
.
INFO: Found 1 target...
ERROR: /Users/charafau/Projects/bazel/BazelTest/BUILD:12:1: Validating Android resources for //BazelTest:activities failed: ResourceProcessorBusyBox failed: error executing command
  (exec env - \
  bazel-out/host/bin/external/bazel_tools/src/tools/android/java/com/google/devtools/build/android/ResourceProcessorBusyBox --tool VALIDATE -- --buildToolsVersion 25.0.2 --aapt bazel-out/host/bin/external/androidsdk/aapt_binary --annotationJar external/androidsdk/tools/support/annotations.jar --androidJar external/androidsdk/platforms/android-25/android.jar --mergedResources bazel-out/android-stub_armeabi-v7a-fastbuild/bin/BazelTest/activities_files/resource_files.zip --manifest bazel-out/android-stub_armeabi-v7a-fastbuild/bin/BazelTest/activities_processed_manifest/AndroidManifest.xml --debug --packageForR com.nullpointerbay.bazeltest --rOutput bazel-out/android-stub_armeabi-v7a-fastbuild/bin/BazelTest/activities_symbols/R.txt --srcJarOutput bazel-out/android-stub_armeabi-v7a-fastbuild/bin/BazelTest/activities.srcjar)

Use --sandbox_debug to see verbose messages from the sandbox.
Error: /var/folders/93/4s8b2bsn4mg1py2dmh1zr47r0000gn/T/resource_validator_tmp6064201763130658352/tmp-expanded/res/values/values.xml:13: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'.
Error:
Error: /var/folders/93/4s8b2bsn4mg1py2dmh1zr47r0000gn/T/resource_validator_tmp6064201763130658352/tmp-expanded/res/values/values.xml:15: error: Error: No resource found that matches the given name: attr 'colorAccent'.
Error:
Error: /var/folders/93/4s8b2bsn4mg1py2dmh1zr47r0000gn/T/resource_validator_tmp6064201763130658352/tmp-expanded/res/values/values.xml:14: error: Error: No resource found that matches the given name: attr 'colorPrimary'.
Error:
Error: /var/folders/93/4s8b2bsn4mg1py2dmh1zr47r0000gn/T/resource_validator_tmp6064201763130658352/tmp-expanded/res/values/values.xml:16: error: Error: No resource found that matches the given name: attr 'colorPrimaryDark'.
Error:
Apr 05, 2017 3:29:45 AM com.google.devtools.build.android.AndroidResourceValidatorAction main
SEVERE: Unexpected
com.android.ide.common.internal.LoggedErrorException: Failed to run command:
	bazel-out/host/bin/external/androidsdk/aapt_binary package -f --no-crunch --no-version-vectors -I external/androidsdk/platforms/android-25/android.jar -M /var/folders/93/4s8b2bsn4mg1py2dmh1zr47r0000gn/T/resource_validator_tmp6064201763130658352/manifest-aapt-dummy/AndroidManifest.xml -S /var/folders/93/4s8b2bsn4mg1py2dmh1zr47r0000gn/T/resource_validator_tmp6064201763130658352/tmp-expanded/res -m -J /var/folders/93/4s8b2bsn4mg1py2dmh1zr47r0000gn/T/resource_validator_tmp6064201763130658352/generated_resources --output-text-symbols /var/folders/93/4s8b2bsn4mg1py2dmh1zr47r0000gn/T/resource_validator_tmp6064201763130658352/generated_resources --debug-mode --custom-package com.nullpointerbay.bazeltest --non-constant-id -0 apk
Error Code:
	1
Output:

Error at 13 : /var/folders/93/4s8b2bsn4mg1py2dmh1zr47r0000gn/T/resource_validator_tmp6064201763130658352/tmp-expanded/res/values/values.xml:13: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'.
8	:  <eat-comment/>
9	:  <string name="app_name">Bazel Test</string>
10	:  <!-- BazelTest/app/src/main/res/values/styles.xml -->
11	:  <eat-comment/>
12	:  <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
13	:  <item name="colorPrimary">@color/colorPrimary</item>
14	:  <item name="colorAccent">@color/colorAccent</item>
15	:  <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
16	:  </style>
17	:  </resources>


Error at 15 : /var/folders/93/4s8b2bsn4mg1py2dmh1zr47r0000gn/T/resource_validator_tmp6064201763130658352/tmp-expanded/res/values/values.xml:15: error: Error: No resource found that matches the given name: attr 'colorAccent'.
10	:  <!-- BazelTest/app/src/main/res/values/styles.xml -->
11	:  <eat-comment/>
12	:  <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
13	:  <item name="colorPrimary">@color/colorPrimary</item>
14	:  <item name="colorAccent">@color/colorAccent</item>
15	:  <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
16	:  </style>
17	:  </resources>


Error at 14 : /var/folders/93/4s8b2bsn4mg1py2dmh1zr47r0000gn/T/resource_validator_tmp6064201763130658352/tmp-expanded/res/values/values.xml:14: error: Error: No resource found that matches the given name: attr 'colorPrimary'.
9	:  <string name="app_name">Bazel Test</string>
10	:  <!-- BazelTest/app/src/main/res/values/styles.xml -->
11	:  <eat-comment/>
12	:  <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
13	:  <item name="colorPrimary">@color/colorPrimary</item>
14	:  <item name="colorAccent">@color/colorAccent</item>
15	:  <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
16	:  </style>
17	:  </resources>


Error at 16 : /var/folders/93/4s8b2bsn4mg1py2dmh1zr47r0000gn/T/resource_validator_tmp6064201763130658352/tmp-expanded/res/values/values.xml:16: error: Error: No resource found that matches the given name: attr 'colorPrimaryDark'.
11	:  <eat-comment/>
12	:  <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
13	:  <item name="colorPrimary">@color/colorPrimary</item>
14	:  <item name="colorAccent">@color/colorAccent</item>
15	:  <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
16	:  </style>
17	:  </resources>


	at com.google.devtools.build.android.AndroidResourceProcessor.runAapt(AndroidResourceProcessor.java:385)
	at com.google.devtools.build.android.AndroidResourceValidatorAction.main(AndroidResourceValidatorAction.java:128)
	at com.google.devtools.build.android.ResourceProcessorBusyBox$Tool$2.call(ResourceProcessorBusyBox.java:59)
	at com.google.devtools.build.android.ResourceProcessorBusyBox.main(ResourceProcessorBusyBox.java:137)

Exception in thread "main" com.android.ide.common.internal.LoggedErrorException: Failed to run command:
	bazel-out/host/bin/external/androidsdk/aapt_binary package -f --no-crunch --no-version-vectors -I external/androidsdk/platforms/android-25/android.jar -M /var/folders/93/4s8b2bsn4mg1py2dmh1zr47r0000gn/T/resource_validator_tmp6064201763130658352/manifest-aapt-dummy/AndroidManifest.xml -S /var/folders/93/4s8b2bsn4mg1py2dmh1zr47r0000gn/T/resource_validator_tmp6064201763130658352/tmp-expanded/res -m -J /var/folders/93/4s8b2bsn4mg1py2dmh1zr47r0000gn/T/resource_validator_tmp6064201763130658352/generated_resources --output-text-symbols /var/folders/93/4s8b2bsn4mg1py2dmh1zr47r0000gn/T/resource_validator_tmp6064201763130658352/generated_resources --debug-mode --custom-package com.nullpointerbay.bazeltest --non-constant-id -0 apk
Error Code:
	1
Output:

Error at 13 : /var/folders/93/4s8b2bsn4mg1py2dmh1zr47r0000gn/T/resource_validator_tmp6064201763130658352/tmp-expanded/res/values/values.xml:13: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'.
8	:  <eat-comment/>
9	:  <string name="app_name">Bazel Test</string>
10	:  <!-- BazelTest/app/src/main/res/values/styles.xml -->
11	:  <eat-comment/>
12	:  <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
13	:  <item name="colorPrimary">@color/colorPrimary</item>
14	:  <item name="colorAccent">@color/colorAccent</item>
15	:  <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
16	:  </style>
17	:  </resources>


Error at 15 : /var/folders/93/4s8b2bsn4mg1py2dmh1zr47r0000gn/T/resource_validator_tmp6064201763130658352/tmp-expanded/res/values/values.xml:15: error: Error: No resource found that matches the given name: attr 'colorAccent'.
10	:  <!-- BazelTest/app/src/main/res/values/styles.xml -->
11	:  <eat-comment/>
12	:  <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
13	:  <item name="colorPrimary">@color/colorPrimary</item>
14	:  <item name="colorAccent">@color/colorAccent</item>
15	:  <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
16	:  </style>
17	:  </resources>


Error at 14 : /var/folders/93/4s8b2bsn4mg1py2dmh1zr47r0000gn/T/resource_validator_tmp6064201763130658352/tmp-expanded/res/values/values.xml:14: error: Error: No resource found that matches the given name: attr 'colorPrimary'.
9	:  <string name="app_name">Bazel Test</string>
10	:  <!-- BazelTest/app/src/main/res/values/styles.xml -->
11	:  <eat-comment/>
12	:  <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
13	:  <item name="colorPrimary">@color/colorPrimary</item>
14	:  <item name="colorAccent">@color/colorAccent</item>
15	:  <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
16	:  </style>
17	:  </resources>


Error at 16 : /var/folders/93/4s8b2bsn4mg1py2dmh1zr47r0000gn/T/resource_validator_tmp6064201763130658352/tmp-expanded/res/values/values.xml:16: error: Error: No resource found that matches the given name: attr 'colorPrimaryDark'.
11	:  <eat-comment/>
12	:  <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
13	:  <item name="colorPrimary">@color/colorPrimary</item>
14	:  <item name="colorAccent">@color/colorAccent</item>
15	:  <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
16	:  </style>
17	:  </resources>


	at com.google.devtools.build.android.AndroidResourceProcessor.runAapt(AndroidResourceProcessor.java:385)
	at com.google.devtools.build.android.AndroidResourceValidatorAction.main(AndroidResourceValidatorAction.java:128)
	at com.google.devtools.build.android.ResourceProcessorBusyBox$Tool$2.call(ResourceProcessorBusyBox.java:59)
	at com.google.devtools.build.android.ResourceProcessorBusyBox.main(ResourceProcessorBusyBox.java:137)
Use --strategy=AndroidResourceValidator=standalone to disable sandboxing for the failing actions.
Target //BazelTest:BazelTest failed to build
INFO: Elapsed time: 3.498s, Critical Path: 3.25s

@aj-michael
Copy link
Contributor Author

@apelle03 or @corbinrsmith-work, do either of you have a guess as to why the BusyBox is failing to validate?

@corbinrsmith-work
Copy link
Contributor

Looks like appcompat is missing from the library -- it should be a dependency on the library not just the binary.

And you don't need to duplicate the resources on both the binary and library.

Try this:


android_binary(
    name = "BazelTest",
    custom_package = "com.nullpointerbay.bazeltest",
    manifest = "app/src/main/AndroidManifest.xml",
    visibility = ["//visibility:public"],
    deps = [":activities"],
)

android_library(
    name = "activities",
    srcs = glob(["app/src/main/java/com/nullpointerbay/bazel/bazeltest/*.java"]),
    custom_package = "com.nullpointerbay.bazeltest",
    manifest = "app/src/main/AndroidManifest.xml",
    resource_files = glob(["app/src/main/res/**"]),
   deps = [
      "@androidsdk//com.android.support:appcompat-v7-25.3.1",
   ]
)

@charafau
Copy link

charafau commented Apr 7, 2017

Thank you for answer and sorry for late reply. After applying that changes I got this:
my BUILD file:

android_binary(
    name = "BazelTest",
    custom_package = "com.nullpointerbay.bazeltest",
    manifest = "app/src/main/AndroidManifest.xml",
    visibility = ["//visibility:public"],
    deps = [":activities"],
)

android_library(
    name = "activities",
    srcs = glob(["app/src/main/java/com/nullpointerbay/bazel/bazeltest/*.java"]),
    custom_package = "com.nullpointerbay.bazeltest",
    manifest = "app/src/main/AndroidManifest.xml",
    resource_files = glob(["app/src/main/res/**"]),
    deps = ["@androidsdk//com.android.support:appcompat-v7-25.3.1"],
)

error I get:

➜  bazel bazel build //BazelTest  --verbose_failures
INFO: Found 1 target...
ERROR: /private/var/tmp/_bazel_charafau/6654ac68c72738dc646a201633d60c3b/external/androidsdk/com.android.support/BUILD:4293:1: Processing Android resources for @androidsdk//com.android.support:support-compat-25.3.1 failed: ResourceProcessorBusyBox failed: error executing command
  (exec env - \
  bazel-out/host/bin/external/bazel_tools/src/tools/android/java/com/google/devtools/build/android/ResourceProcessorBusyBox --tool PACKAGE -- --buildToolsVersion 25.0.2 --aapt bazel-out/host/bin/external/androidsdk/aapt_binary --annotationJar external/androidsdk/tools/support/annotations.jar --androidJar external/androidsdk/platforms/android-25/android.jar --primaryData bazel-out/android-stub_armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/_aar/unzipped/resources/support-compat-25.3.1::bazel-out/android-stub_armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/_aar/support-compat-25.3.1/AndroidManifest.xml --packageType LIBRARY --rOutput bazel-out/android-stub_armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/support-compat-25.3.1_symbols/R.txt --symbolsOut bazel-out/android-stub_armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/support-compat-25.3.1_symbols/symbols.bin --srcJarOutput bazel-out/android-stub_armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/support-compat-25.3.1.srcjar --manifestOutput bazel-out/android-stub_armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/support-compat-25.3.1_processed_manifest/AndroidManifest.xml --resourcesOutput bazel-out/android-stub_armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/support-compat-25.3.1_files/resource_files.zip '--useAaptCruncher=no' --debug)

Use --sandbox_debug to see verbose messages from the sandbox.
Error parsing command line: While parsing option --primaryData: invalid UnvalidatedAndroidData: bazel-out/android-stub_armeabi-v7a-fastbuild/bin/external/androidsdk/com.android.support/_aar/unzipped/resources/support-compat-25.3.1 does not exist
Try --help.
Use --strategy=AndroidAapt=standalone to disable sandboxing for the failing actions.
Target //BazelTest:BazelTest failed to build
INFO: Elapsed time: 0.967s, Critical Path: 0.78s

I can upload this project to github if it helps tracking bugs.

@aj-michael
Copy link
Contributor Author

@charafau , can you open a separate GitHub issue for this? Also, uploading the project to GitHub would definitely help us help you :)

@aj-michael
Copy link
Contributor Author

(Also, as a quick note, the error that you just posted is same as the original error, which appears to because you forgot to use the new bazel binary).

@charafau
Copy link

charafau commented May 2, 2017

@aj-michael Sorry for no contact, got busy lately. I checkout new bazel version from git, recompiled and got working project:

https://github.com/charafau/BazelTest

One thing I would like to suggest is, android_library doesnt check if sources are in given path i.e.:

android_library(
    name = "activities",
    srcs = glob(["app/src/main/java/com/nullpointerbay/bazeltest/*.java"]),
    manifest = "app/src/main/AndroidManifest.xml",
    custom_package = "com.nullpointerbay.bazeltest",
    resource_files = glob(["app/src/main/res/**"]),
    deps = ["@androidsdk//com.android.support:appcompat-v7-25.3.1"],
)

if I change srcs = glob(["app/src/main/java/com/nullpointerbay/bazeltest/*.java"]), to some different path, bazel will compile and install apk but it will fail on start, maybe warning or something would be nice to have.

I also dont know why it takes ~11 seconds to reinstall this simple app with mobile-install --incremental after changing string in xml file

Anyway, thank you for helping me with my issue!

@aj-michael
Copy link
Contributor Author

@charafau, thanks for the feedback.

Regarding the lack of sources, that is just glob working as intended. It could be the case that all your code comes from another library that you depend on, so this is not an error. You do not need to use glob. In fact, you could use

srcs = [
    "app/src/main/java/com/nullpointerbay/bazeltest/MyActivity.java",
    "app/src/main/java/com/nullpointerbay/bazeltest/MyOtherActivity.java",
]

And then the build would fail if either of those files did not exist. If you have an idea for a way to improve this, please open a separate github issue.

Please open a separate GitHub issue about mobile-install and we can discuss it there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 I'll work on this now. (Assignee required) type: bug
Projects
None yet
Development

No branches or pull requests

7 participants