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

Unable to deploy example NDK app to Android 9: 'remote secure_mkdirs failed: Operation not permitted' #77

Closed
jgavris opened this issue Sep 18, 2018 · 4 comments
Assignees

Comments

@jgavris
Copy link

jgavris commented Sep 18, 2018

I'm running bazel 0.17.1, android NDK r17b. When I try to deploy to an Android 9 device I get:

jgavris in ~/code/examples/android/ndk on master
λ bazel mobile-install //app/src/main:app --fat_apk_cpu=arm64-v8a --start_app
INFO: Analysed target //app/src/main:app (0 packages loaded).
INFO: Found 1 target...
ERROR: /Users/jgavris/code/examples/android/ndk/app/src/main/BUILD.bazel:21:1: Installing //app/src/main:app failed (Exit 1)
Error:
adb command: ['external/androidsdk/platform-tools/adb', 'push', '/var/folders/q4/yjz6lvkj5hgg3tw1802g76zh0000gn/T/tmpIsCjcL/adbfile_4', u'/data/local/tmp/incrementaldeployment/com.example.android.bazel/native/native_manifest']
return code: 1
stdout: [   ?] /data/local/tmp/incrementaldeployment/com.example.android.bazel/native/native_manifest: 0/?
adb: error: failed to copy '/var/folders/q4/yjz6lvkj5hgg3tw1802g76zh0000gn/T/tmpIsCjcL/adbfile_4' to '/data/local/tmp/incrementaldeployment/com.example.android.bazel/native/native_manifest': remote secure_mkdirs failed: Operation not permitted
/var/folders/q4/yjz6lvkj5hgg3tw1802g76zh0000gn/T/tmpIsCjcL/adbfile_4: 0 files pushed.
stderr:
Updating 1 dex...
Updating application resources...
Updating 0 native libs...
Target //app/src/main:app failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 1.691s, Critical Path: 1.37s
INFO: 0 processes.
FAILED: Build did NOT complete successfully
jgavris in ~/code/examples/android/ndk on master
λ bazel info
bazel-bin: /private/var/tmp/_bazel_jgavris/a529821f4856b67750ce7a4f6d160c6a/execroot/__main__/bazel-out/darwin-fastbuild/bin
bazel-genfiles: /private/var/tmp/_bazel_jgavris/a529821f4856b67750ce7a4f6d160c6a/execroot/__main__/bazel-out/darwin-fastbuild/genfiles
bazel-testlogs: /private/var/tmp/_bazel_jgavris/a529821f4856b67750ce7a4f6d160c6a/execroot/__main__/bazel-out/darwin-fastbuild/testlogs
character-encoding: file.encoding = ISO-8859-1, defaultCharset = ISO-8859-1
command_log: /private/var/tmp/_bazel_jgavris/a529821f4856b67750ce7a4f6d160c6a/command.log
committed-heap-size: 888MB
execution_root: /private/var/tmp/_bazel_jgavris/a529821f4856b67750ce7a4f6d160c6a/execroot/__main__
gc-count: 17
gc-time: 1010ms
install_base: /var/tmp/_bazel_jgavris/install/79d9f22886570ca416e6ffca28ab7725
java-home: /private/var/tmp/_bazel_jgavris/install/79d9f22886570ca416e6ffca28ab7725/_embedded_binaries/embedded_tools/jdk
java-runtime: OpenJDK Runtime Environment (build 9.0.7.1+1) by Azul Systems, Inc.
java-vm: OpenJDK 64-Bit Server VM (build 9.0.7.1+1, mixed mode) by Azul Systems, Inc.
max-heap-size: 3817MB
output_base: /private/var/tmp/_bazel_jgavris/a529821f4856b67750ce7a4f6d160c6a
output_path: /private/var/tmp/_bazel_jgavris/a529821f4856b67750ce7a4f6d160c6a/execroot/__main__/bazel-out
package_path: %workspace%
release: release 0.17.1
repository_cache: /var/tmp/_bazel_jgavris/cache/repos/v1
server_pid: 48463
used-heap-size: 148MB
workspace: /Users/jgavris/code/examples/android/ndk

@jin ?

@jgavris jgavris changed the title Unable to deploy example NDK app Unable to deploy example NDK app remote secure_mkdirs failed: Operation not permitted Sep 18, 2018
@jgavris jgavris changed the title Unable to deploy example NDK app remote secure_mkdirs failed: Operation not permitted Unable to deploy example NDK app 'remote secure_mkdirs failed: Operation not permitted' Sep 18, 2018
@jin jin self-assigned this Oct 11, 2018
@jgavris jgavris changed the title Unable to deploy example NDK app 'remote secure_mkdirs failed: Operation not permitted' Unable to deploy example NDK app to Android 9: 'remote secure_mkdirs failed: Operation not permitted' Oct 31, 2018
@jin
Copy link
Member

jin commented Nov 17, 2018

Does regular adb install work? Looks like adb push under Bazel doesn't have the correct permissions.

As an aside and mentioned in the Slack chat, we’re in the process of open sourcing mobile-install v2. It’s a complete rewrite of mobile-install in Starlark, and thereafter we will deprecate the native mobile-install in Bazel. AFAIUC, mi-v2 will solve this issue.

@pandasyr
Copy link

I had this happen before and for me it was because the apk signature mismatch (because I switched computer), which was solved by uninstalling the old apk.

@jgavris
Copy link
Author

jgavris commented Nov 29, 2018

A regular install works, yes. That's what we're using in Android Studio.

@jin
Copy link
Member

jin commented Dec 11, 2018

Update: I managed to repro the issue and found the root cause.

Somewhere between 28 and 29, when creating directories as part of adb push, the behavior changed w.r.t. directory permissions.

On 28, the created directories via adb push have the permissions drwxrwxr-x.
On 29, the permissions are drwxrwx--x. The difference is the read permission for others. For some reason, this causes the adb push to fail.

It turns out that inserting a adb shell mkdir -p /data/local/tmp/incrementaldeployment/com.example.android.bazel/native/ before pushing the files creates the directory with the correct permissions, and native_manifest can be pushed correctly.

bazel-io pushed a commit to bazelbuild/bazel that referenced this issue Jan 28, 2019
Baseline: deb028e

Cherry picks:

   + a3a5975:
     Fix a race condition in remote cache
   + b8d0e1b:
     Use a new GitHub token and KMS key for the release process.
   + 3759e38:
     remote: fix unexpected IO error (not a directory)
   + 4473bb1:
     Fix a race condition in Bazel's Windows process management.
   + 9137fb9:
     undo flag flip of --incompatible_strict_action_env
   + 12ab12e:
     Revert "Enabling Bazel to generate input symlinks as defined by
     RE AP?
   + 6345c74:
     Automated rollback of commit
     30536ba.

New features:

  - Add inputs filtering for aquery
  - https://docs.bazel.build now supports versioned
    documentation. Use the selector at the top of the navigation bar
    to
    switch between documentation for different Bazel releases.
  - build_tar.py in tools/build_defs/pkg now supports a json manifest
    that can be used to add paths that have symbols that can't be
    specified via the command line

Important changes:

  - Added `--incompatible_dont_emit_static_libgcc`
    (#6825)
    Added `--incompatible_linkopts_in_user_link_flags`
    (#6826)
  - mobile-install now works with aapt2. Try it out with `bazel
    mobile-install --android_aapt=aapt2 //my:target`
  - Fixed a mobile-install v1 bug when deploying to Android 9 Pie
    devices. #6814
  - Add a new option --xbinary_fdo to pass xbinary profile.
  - --runs_per_test: place in TESTING documentation category.
  - Adds a clarifying message to test case summary output when all
    test cases pass but the target fails.
  - Fixed mobile-install v1 error when installing an app with native
    libraries onto an Android 9 (Pie) device. See
    bazelbuild/examples#77
  - Fixed issue where error messages from Android manifest merging
    actions were not propagated fully.
  - Add outputs and mnemonic filtering to aquery
  - New incompatible change flag for defaulting to aapt2 in Android
    builds: `--incompatible_use_aapt2_by_default`. To build with
    aapt2 today, pass the flag
    `--incompatible_use_aapt2_by_default=true` or
    `--android_aapt=aapt2`, or set the `aapt_version`  to `aapt2` on
    your `android_binary` or `android_local_test` target.
  - set projectId in all PublishBuildToolEventStreamRequest
  - Flip flag --incompatible_string_is_not_iterable
    (#5830)
  - cc_toolchain.(static|dynamic)_runtime_libs attributes are now
    optional
  - Added --incompatible_disable_runtimes_filegroups
    (#6942).
  - objc_bundle has been removed. Please migrate to rules_apple's
    [apple_bundle_import](https://github.com/bazelbuild/rules_apple/bl
    ob/master/doc/rules-resources.md#apple_bundle_import).
  - The apple_stub_binary rule has been deleted.
  - Incompatible flag `--incompatible_dont_emit_static_libgcc` has
    been flipped (#6825)
  - Incompatible flag `--incompatible_linkopts_in_user_link_flags`
    has been flipped (#6826)
  - Open source aquery & cquery query2 tests
  - Fixed a mobile-install bug where `arm64-v8a` libraries were not
    deployed correctly on `arm64` devices. This was done by enabling
    incremental native lib deployment by default. A previously
    undocumented `--android_incremental_native_libs` flag is removed,
    and is now the regular behavior. See
    #2239
  - Incompatible flag `--incompatible_linkopts_in_user_link_flags`
    has been flipped (#6826)
  - Incompatible flag `--incompatible_dont_emit_static_libgcc` has
    been flipped (#6825)
  - Added --incompatible_disable_legacy_crosstool_fields. See the
    migration notes at
    #6861.
  - In the Query HowTo, recommend ":*" instead of ":all". "all" might
    be the name of a target.
  - The default value for --incompatible_strict_action_env has been
    flipped to 'false' again, as we discovered breakages for local
    execution users. We'll need some more time to figure out the best
    way to make this work for local and remote execution. Follow
    #7026 for more details.

This release contains contributions from many people at Google, as well as Benjamin Peterson, Dave Lee, George Gensure, Gert van Dijk, Gustavo Storti Salibi, Keith Smiley, Loo Rong Jie, Lukasz Tekieli, Mikhail Mazurskiy, Thi, Travis Cline, Vladimir Chebotarev, Yannic.
weixiao-huang pushed a commit to weixiao-huang/bazel that referenced this issue Jan 31, 2019
Baseline: deb028e

Cherry picks:

   + a3a5975:
     Fix a race condition in remote cache
   + b8d0e1b:
     Use a new GitHub token and KMS key for the release process.
   + 3759e38:
     remote: fix unexpected IO error (not a directory)
   + 4473bb1:
     Fix a race condition in Bazel's Windows process management.
   + 9137fb9:
     undo flag flip of --incompatible_strict_action_env
   + 12ab12e:
     Revert "Enabling Bazel to generate input symlinks as defined by
     RE AP?
   + 6345c74:
     Automated rollback of commit
     30536ba.

New features:

  - Add inputs filtering for aquery
  - https://docs.bazel.build now supports versioned
    documentation. Use the selector at the top of the navigation bar
    to
    switch between documentation for different Bazel releases.
  - build_tar.py in tools/build_defs/pkg now supports a json manifest
    that can be used to add paths that have symbols that can't be
    specified via the command line

Important changes:

  - Added `--incompatible_dont_emit_static_libgcc`
    (bazelbuild#6825)
    Added `--incompatible_linkopts_in_user_link_flags`
    (bazelbuild#6826)
  - mobile-install now works with aapt2. Try it out with `bazel
    mobile-install --android_aapt=aapt2 //my:target`
  - Fixed a mobile-install v1 bug when deploying to Android 9 Pie
    devices. bazelbuild#6814
  - Add a new option --xbinary_fdo to pass xbinary profile.
  - --runs_per_test: place in TESTING documentation category.
  - Adds a clarifying message to test case summary output when all
    test cases pass but the target fails.
  - Fixed mobile-install v1 error when installing an app with native
    libraries onto an Android 9 (Pie) device. See
    bazelbuild/examples#77
  - Fixed issue where error messages from Android manifest merging
    actions were not propagated fully.
  - Add outputs and mnemonic filtering to aquery
  - New incompatible change flag for defaulting to aapt2 in Android
    builds: `--incompatible_use_aapt2_by_default`. To build with
    aapt2 today, pass the flag
    `--incompatible_use_aapt2_by_default=true` or
    `--android_aapt=aapt2`, or set the `aapt_version`  to `aapt2` on
    your `android_binary` or `android_local_test` target.
  - set projectId in all PublishBuildToolEventStreamRequest
  - Flip flag --incompatible_string_is_not_iterable
    (bazelbuild#5830)
  - cc_toolchain.(static|dynamic)_runtime_libs attributes are now
    optional
  - Added --incompatible_disable_runtimes_filegroups
    (bazelbuild#6942).
  - objc_bundle has been removed. Please migrate to rules_apple's
    [apple_bundle_import](https://github.com/bazelbuild/rules_apple/bl
    ob/master/doc/rules-resources.md#apple_bundle_import).
  - The apple_stub_binary rule has been deleted.
  - Incompatible flag `--incompatible_dont_emit_static_libgcc` has
    been flipped (bazelbuild#6825)
  - Incompatible flag `--incompatible_linkopts_in_user_link_flags`
    has been flipped (bazelbuild#6826)
  - Open source aquery & cquery query2 tests
  - Fixed a mobile-install bug where `arm64-v8a` libraries were not
    deployed correctly on `arm64` devices. This was done by enabling
    incremental native lib deployment by default. A previously
    undocumented `--android_incremental_native_libs` flag is removed,
    and is now the regular behavior. See
    bazelbuild#2239
  - Incompatible flag `--incompatible_linkopts_in_user_link_flags`
    has been flipped (bazelbuild#6826)
  - Incompatible flag `--incompatible_dont_emit_static_libgcc` has
    been flipped (bazelbuild#6825)
  - Added --incompatible_disable_legacy_crosstool_fields. See the
    migration notes at
    bazelbuild#6861.
  - In the Query HowTo, recommend ":*" instead of ":all". "all" might
    be the name of a target.
  - The default value for --incompatible_strict_action_env has been
    flipped to 'false' again, as we discovered breakages for local
    execution users. We'll need some more time to figure out the best
    way to make this work for local and remote execution. Follow
    bazelbuild#7026 for more details.

This release contains contributions from many people at Google, as well as Benjamin Peterson, Dave Lee, George Gensure, Gert van Dijk, Gustavo Storti Salibi, Keith Smiley, Loo Rong Jie, Lukasz Tekieli, Mikhail Mazurskiy, Thi, Travis Cline, Vladimir Chebotarev, Yannic.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants