Trouble with Android Attach #47

Open
opened 2025-08-09 17:13:07 +00:00 by fergalmoran · 0 comments
Owner

Originally created by @paullmullen on 4/13/2021

Setup

I have Adelphes.android-dev-ext installed in VSCode version 1.55.0 on Windows.

Version: 1.55.0 (system setup)
Commit: c185983a683d14c396952dd432459097bc7f757f
Date: 2021-03-30T16:01:55.261Z
Electron: 11.3.0
Chrome: 87.0.4280.141
Node.js: 12.18.3
V8: 8.7.220.31-electron.0
OS: Windows_NT x64 10.0.19042

I also have AndroidStudio installed and have installed the SDK Platform Tools installed for Android 11

I have pastedmy launch.json file and my tasks.json file

Problem

When I pick Android Attach from the debug menu, I always get this error: Running the contributed command: 'PickAndroidProcess' failed.

Am I missing a setup step?

Is it possible that I have the .json files installed in the wrong directory?

Am I missing something else simple?

tasks.json

{
  "version": "2.0.0",
  "tasks": [
      {
          "label": "run gradle",
          "type": "shell",
          "command": "${workspaceFolder}/gradlew",
          "args": [
              "assembleDebug"
          ],
          "presentation": {
              "echo": true,
              "reveal": "always",
              "focus": false,
              "panel": "shared",
              "showReuseMessage": true,
              "clear": false
          },
          "problemMatcher": [],
          "group": {
              "kind": "build",
              "isDefault": true
          }
      }
  ]
}

launch.json

{
    "version": "0.2.0",
    "configurations": [

        {
            "type": "android",
            "request": "attach",
            "name": "Android Attach",
            "appSrcRoot": "${workspaceRoot}/app/src/main",
            "adbPort": 5037,
            "processId": "${command:PickAndroidProcess}",
            "preLaunchTask": "run gradle"

        },
        {
            // configuration type, request  and name. "launch" is used to deploy the app
            // to your device and start a debugging session.
            "type": "android",
            "request": "launch",
            "name": "Launch App",

            // Location of the App source files. This value must point to the root of
            // your App source tree (containing AndroidManifest.xml).
            "appSrcRoot": "${workspaceRoot}/app/src/main",

            // Fully qualified path to the built APK (Android Application Package).
            "apkFile": "${workspaceRoot}/app/build/outputs/apk/app-debug.apk",

            // `host:port` configuration for connecting to the ADB (Android Debug Bridge) server instance.
            // Default: localhost:5037
            "adbSocket": "localhost:5037",

            // Automatically launch 'adb start-server' if not already started.
            // Default: true
            "autoStartADB": true,

            // Launch behaviour if source files have been saved after the APK was built.
            // One of: [ ignore warn stop ]. Default: warn
            "staleBuild": "warn",

            // Target Device ID (as indicated by 'adb devices').
            // Use this to specify which device is used for deployment
            // when multiple devices are connected.
            "targetDevice": "",

            // Fully qualified path to the AndroidManifest.xml file compiled into the APK.
            // Default: "${appSrcRoot}/AndroidManifest.xml"
            "manifestFile": "${workspaceRoot}/app/src/main/AndroidManifest.xml",

            // Custom arguments passed to the Android package manager to install the app.
            // Run 'adb shell pm' to show valid arguments. Default: ["-r"]
            "pmInstallArgs": ["-r"],

            // Custom arguments passed to the Android application manager to start the app.
            // Run `adb shell am` to show valid arguments.
            // Note that `-D` is required to enable debugging.
            "amStartArgs": [
                "-D",
                "--activity-brought-to-front",
                "-a android.intent.action.MAIN",
                "-c android.intent.category.LAUNCHER",
                "-n package.name/launch.activity"
            ],

            // Manually specify the activity to run when the app is started. This option is
            // mutually exclusive with "amStartArgs".
            "launchActivity": ".MainActivity",

            // Time in milliseconds to wait after launching an app before attempting to attach
            // the debugger. Default: 1000ms
            "postLaunchPause": 1000,

            // Set to true to output debugging logs for diagnostics.
            "trace": false
        }
    ]
}

Building your app automatically
This extension will not build your App. If you would like to run a build each time a debug session is started, you can add a preLaunchTask option to your launch.json configuration which invokes a build task.

.vscode/launch.json
Add a preLaunchTask item to the launch configuration:

{
"version": "0.2.0",
"configurations": [
    {
        "type": "android",
        "request": "launch",
        "name": "App Build & Launch",
        "preLaunchTask": "run gradle",
        ...
    }
]
}
*Originally created by @paullmullen on 4/13/2021* ### Setup I have Adelphes.android-dev-ext installed in VSCode version 1.55.0 on Windows. ``` Version: 1.55.0 (system setup) Commit: c185983a683d14c396952dd432459097bc7f757f Date: 2021-03-30T16:01:55.261Z Electron: 11.3.0 Chrome: 87.0.4280.141 Node.js: 12.18.3 V8: 8.7.220.31-electron.0 OS: Windows_NT x64 10.0.19042 ``` I also have AndroidStudio installed and have installed the SDK Platform Tools installed for Android 11 I have pastedmy launch.json file and my tasks.json file ### Problem When I pick Android Attach from the debug menu, I always get this error: **Running the contributed command: 'PickAndroidProcess' failed.** **Am I missing a setup step?** Is it possible that I have the .json files installed in the wrong directory? Am I missing something else simple? tasks.json ``` { "version": "2.0.0", "tasks": [ { "label": "run gradle", "type": "shell", "command": "${workspaceFolder}/gradlew", "args": [ "assembleDebug" ], "presentation": { "echo": true, "reveal": "always", "focus": false, "panel": "shared", "showReuseMessage": true, "clear": false }, "problemMatcher": [], "group": { "kind": "build", "isDefault": true } } ] } ``` launch.json ``` { "version": "0.2.0", "configurations": [ { "type": "android", "request": "attach", "name": "Android Attach", "appSrcRoot": "${workspaceRoot}/app/src/main", "adbPort": 5037, "processId": "${command:PickAndroidProcess}", "preLaunchTask": "run gradle" }, { // configuration type, request and name. "launch" is used to deploy the app // to your device and start a debugging session. "type": "android", "request": "launch", "name": "Launch App", // Location of the App source files. This value must point to the root of // your App source tree (containing AndroidManifest.xml). "appSrcRoot": "${workspaceRoot}/app/src/main", // Fully qualified path to the built APK (Android Application Package). "apkFile": "${workspaceRoot}/app/build/outputs/apk/app-debug.apk", // `host:port` configuration for connecting to the ADB (Android Debug Bridge) server instance. // Default: localhost:5037 "adbSocket": "localhost:5037", // Automatically launch 'adb start-server' if not already started. // Default: true "autoStartADB": true, // Launch behaviour if source files have been saved after the APK was built. // One of: [ ignore warn stop ]. Default: warn "staleBuild": "warn", // Target Device ID (as indicated by 'adb devices'). // Use this to specify which device is used for deployment // when multiple devices are connected. "targetDevice": "", // Fully qualified path to the AndroidManifest.xml file compiled into the APK. // Default: "${appSrcRoot}/AndroidManifest.xml" "manifestFile": "${workspaceRoot}/app/src/main/AndroidManifest.xml", // Custom arguments passed to the Android package manager to install the app. // Run 'adb shell pm' to show valid arguments. Default: ["-r"] "pmInstallArgs": ["-r"], // Custom arguments passed to the Android application manager to start the app. // Run `adb shell am` to show valid arguments. // Note that `-D` is required to enable debugging. "amStartArgs": [ "-D", "--activity-brought-to-front", "-a android.intent.action.MAIN", "-c android.intent.category.LAUNCHER", "-n package.name/launch.activity" ], // Manually specify the activity to run when the app is started. This option is // mutually exclusive with "amStartArgs". "launchActivity": ".MainActivity", // Time in milliseconds to wait after launching an app before attempting to attach // the debugger. Default: 1000ms "postLaunchPause": 1000, // Set to true to output debugging logs for diagnostics. "trace": false } ] } Building your app automatically This extension will not build your App. If you would like to run a build each time a debug session is started, you can add a preLaunchTask option to your launch.json configuration which invokes a build task. .vscode/launch.json Add a preLaunchTask item to the launch configuration: { "version": "0.2.0", "configurations": [ { "type": "android", "request": "launch", "name": "App Build & Launch", "preLaunchTask": "run gradle", ... } ] } ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/android-dev-ext#47
No description provided.