intellij icon indicating copy to clipboard operation
intellij copied to clipboard

[ASWB] Mobile-install run configuration failed

Open ThomasCJY opened this issue 4 years ago • 9 comments

Background Running mobile-install from bazel configuration doesn't work. This issue is regressed from https://github.com/bazelbuild/intellij/pull/1895/commits/12d8faf1cd404840acc9e2f4c1416dade89a05db

Screenshot from 2021-01-28 17-59-36

Waiting for target device...
Invoking mobile-install...
Command: /home/tchen/01_Projects/android/app/bazelisk mobile-install --tool_tag=ijwb:AndroidStudio "--adb_arg=-s " --adb_arg=801KPSL1432918 --adb /home/tchen/Android/Sdk/platform-tools/adb --device 801KPSL1432918:tcp:5037 --curses=no --color=yes --progress_in_terminal_title=no --build_event_binary_file=/tmp/intellij-bep-7b690874-d9b7-460d-805e-fb6de61ce23e --nobuild_event_binary_file_path_conversion -- //platform/core-ui/samples/playground:playground-apk --nolaunch_app

ANDROID_SDK is not set! This must point to the root directory of the Android SDK
2021/01/28 17:58:52 Using unreleased version 114 from gs://snap-bazel-releases
2021/01/28 17:58:52 Authenticating against GCS using default application credentials
INFO: Invocation ID: 35b58e51-d73a-4b4d-ac93-124359378e14
Loading:  (0 packages loaded)
Loading: 0 packages loaded
ERROR: Skipping '-nolaunch_app': no such target '//:-nolaunch_app': target '-nolaunch_app' not declared in package '' defined by /home/tchen/01_Projects/android/app/BUILD.bazel
WARNING: Target pattern parsing failed.
ERROR: no such target '//:-nolaunch_app': target '-nolaunch_app' not declared in package '' defined by /home/tchen/01_Projects/android/app/BUILD.bazel
INFO: Elapsed time: 3.468s (0.06m)
INFO: 0 processes (0.00%).
FAILED: Build did NOT complete successfully (0 packages loaded)
FAILED: Build did NOT complete successfully (0 packages loaded)
INFO: Build Event Protocol files produced successfully.
FAILED: Build did NOT complete successfully (0 packages loaded)

ThomasCJY avatar Jan 29 '21 02:01 ThomasCJY

This is the PR that added the --nolaunch_app flag https://github.com/bazelbuild/intellij/pull/1895, which is added at the end of the command, but seems to be being picked up by bazel

rogchap avatar Jan 24 '22 02:01 rogchap

There's a pr open claiming to fix this issue, https://github.com/bazelbuild/intellij/pull/3202/files, which is linked to an issue over at the mediapipe repo, https://github.com/google/mediapipe/issues/1132. After testing the proposed pr fix out locally, against AS Arctic Fox, I've found the issue still persists.

Personally, deleting this line https://github.com/bazelbuild/intellij/blob/281e811fecee6a50e7a4bd2f80d4b6352ca22af2/aswb/src/com/google/idea/blaze/android/run/binary/mobileinstall/MobileInstallBuildStep.java#L200, and omitting the --nolaunch_app argument has been working without issue or any side effects for a few months now. Unfortunately though, I did have to build and distribute a locally amended version of the plugin internally to get it working.

Happy to propose a change and open a pr to delete that line upstream. I can't see how or where it's needed within the implementation Bazel of mobile-install 🤯 I wonder if it's something supported by Google internally within Blaze only 🤔

jimmyhoran avatar Jan 24 '22 05:01 jimmyhoran

Also, for anyone that comes by this, this issue is a duplicate of https://github.com/bazelbuild/intellij/issues/2084 👍

jimmyhoran avatar Jan 24 '22 06:01 jimmyhoran

My "workaround" is to uncheck use mobile-install which is obviously not ideal for incremental builds.

It does seem that the --nolaunch_app is in the wrong place; and requires BlazeAndroidLaunchTasksProvider which suggests a blaze internal thing 🤷‍♂️🤔, but then again, most of this plugin references "blaze".

A PR to remove the flag makes sense, easy change and may highlight the reasons for it's existence by any of the reviewers (maybe)

Ps. Good to see you here @jimmyhoran hope you are doing well?

rogchap avatar Jan 24 '22 10:01 rogchap

I am currently running into this issue using the Bazel plugin for Android. Is the only way to launch a mobile install via the command line now? Or dragging the build into the emulator?

VegetarianZombie avatar Mar 30 '22 18:03 VegetarianZombie

You can add/merge this to your tools/bazel wrapper to filter out the offending flag:

args=("$@")
for index in "${!args[@]}"; do
  [[ "${args[index]}" == "--nolaunch_app" ]] && unset 'args[index]'
done
exec "$BAZEL_REAL" "${args[@]}"

jlaxson avatar Apr 04 '22 22:04 jlaxson

Facing the same issue :( @jlaxson could you please advise where I should add your code snippet?

kaplad avatar May 02 '22 00:05 kaplad

@kaplad Create an executable file in /tools/bazel with first line #!/bin/bash and remainder the script as above. Then when you run bazel as usual, it will first use that script to modify the command line.

jlaxson avatar May 02 '22 15:05 jlaxson

Fixed in version v2022.08.24

https://github.com/bazelbuild/intellij/releases/tag/v2022.08.24-stable

TylerCarberry avatar Sep 09 '22 01:09 TylerCarberry