From b3f28d3da12ea2d97d838f66765bf21d5dee2f7f Mon Sep 17 00:00:00 2001 From: jingwen Date: Mon, 10 Dec 2018 19:30:57 -0800 Subject: [PATCH] Fix mobile-install v1 error when incrementally installing the native libs' manifest onto the device 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, allowing native_manifest to be pushed correctly. Fixes https://github.com/bazelbuild/examples/issues/77 Fixes https://github.com/bazelbuild/bazel/issues/6814 RELNOTES: Fixed mobile-install v1 error when installing an app with native libraries onto an Android 9 (Pie) device. See https://github.com/bazelbuild/examples/issues/77 PiperOrigin-RevId: 224928364 --- tools/android/incremental_install.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/android/incremental_install.py b/tools/android/incremental_install.py index c07a9b03209424..0638c1b34a4235 100644 --- a/tools/android/incremental_install.py +++ b/tools/android/incremental_install.py @@ -557,6 +557,12 @@ def UploadNativeLibs(adb, native_lib_args, app_dir, full_install): # If we couldn't fetch the device manifest or if this is a non-incremental # install, wipe the slate clean adb.Delete(targetpath.join(app_dir, "native")) + + # From Android 28 onwards, `adb push` creates directories with insufficient + # permissions, resulting in errors when pushing files. `adb shell mkdir` + # works correctly however, so we create the directory here. + # See https://github.com/bazelbuild/examples/issues/77 for more information. + adb.Mkdir(targetpath.join(app_dir, "native")) else: # Otherwise, parse the manifest. Note that this branch is also taken if the # manifest is empty.