Giter Site home page Giter Site logo

nisargjhaveri / vscode-android-debug Goto Github PK

View Code? Open in Web Editor NEW
13.0 4.0 8.0 293 KB

Android Native Debugging support in VS Code

Home Page: https://marketplace.visualstudio.com/items?itemName=nisargjhaveri.android-debug

License: MIT License

TypeScript 100.00%

vscode-android-debug's Introduction

android-debug ยท Android Debugging in VS Code

This is still work-in-progress. Please find or create issues on GitHub if you find something is not working as expected.

Debug Android apps in VS Code, with Native, Java or Dual debugging.

Features

  • Launch/Attach Android apps
  • Java, Native or Dual debugging.
  • Specify one or more locations to search for your so files, or source paths for Java.
  • Dynamic support for specifying and selecting ABIs to support various fat and split apk configurations.
  • Select from connected devices or start an existing emulator for debugging.

Requirements

Quick Start

For a simple Android app with both Java and Native code, the following config should get you started. See Launch Configuration Options for more details.

{
    "version": "0.2.0",
    "configurations": [
        // Launch app for debugging
        {
            "name": "Android",
            "type": "android-debug",
            "request": "launch",
            "target": "select",
            "mode": "dual", // Change to `java` or `native` to attach only Java or Native debugger.
            "packageName": "com.example.sampleapplication", // Package name for your app.
            "launchActivity": ".MainActivity",  // Activity to launch
            "native": {
                "symbolSearchPaths": [
                    "${workspaceFolder}/app/build/intermediates/cmake/debug/obj/${command:abi}/",
                ],
            },
            "java": {
                "sourcePaths": ["${workspaceFolder}/app/src/main/java"]
            }
        },

        // Attach to running app
        {
            "name": "Android",
            "type": "android-debug",
            "request": "attach",
            "target": "select",
            "pid": "${command:pickAndroidProcess}",
            "mode": "dual", // Change to `java` or `native` to attach only Java or Native debugger.
            "packageName": "com.example.sampleapplication", // Package name for your app.
            "native": {
                "symbolSearchPaths": [
                    "${workspaceFolder}/app/build/intermediates/cmake/debug/obj/${command:abi}/",
                ],
            },
            "java": {
                "sourcePaths": ["${workspaceFolder}/app/src/main/java"]
            }
        }
    ]
}

How to use

Create a launch configuration in your launch.json file with type: android-debug to use this extension.

Launch Configuration Options

Here are all the options supported with explanation and example values.

{
    // Set the name of the launch config.
    "name": "Android",

    // Set type to `android-debug` to use this extension.
    "type": "android-debug",

    // Request.
    // `launch` for launching and debugging the app.
    // `attach` for attaching to already running app.
    "request": "launch" or "attach",

    // Target device for debugging.
    // This can `select`, `last-selected` or serial of the connected android device as shown in 'adb devices'
    "target": "select",

    // Process id of the app.
    // Set to `${command:pickAndroidProcess}` to pick the process when you start the debugging.
    // Required and only applicable for `attach` request.
    "pid": "${command:pickAndroidProcess}",

    // Full path to the built APK.
    // If available this apk will be installed first to the target device.
    // At least one of `apkPath` or `packageName` is required for `launch` request.
    "apkPath": "${workspaceFolder}/app/build/outputs/apk/debug/app-debug.apk",

    // Package name of your app.
    // At least one of `apkPath` or `packageName` is required for `launch` request.
    "packageName": "com.example.sampleapplication",

    // Specify the activity you'd want to launch for debugging
    // The activity is launched with the following command:
    // $ adb shell am start -D -a android.intent.action.MAIN -c android.intent.category.LAUNCHER ${packageName}/${launchActivity}
    // Required and only applicable for `launch` request.
    "launchActivity": ".MainActivity",

    // Mode for debugging. One of `java`, `native` or `dual`.
    // Defaults to `java` if not specified.
    "mode": "dual",

    // Resume app process after attaching native debugger in case it is waiting for debugger by attaching a dummy Java debugger.
    // Defaults to `true` for `launch` request, `false` for `attach` request.
    // Only applicable in 'native' mode.
    "resumeProcess": true,

    // Options for native debugging
    "native": {
        // List of supported ABIs for the app.
        // Defaults to `android-debug.abiSupported` configuration if available.
        "abiSupported": ["armeabi-v7a", "arm64-v8a", "x86", "x86_64"],

        // Map of ABI to custom string. To be used with ${command:mappedAbi}.
        // This can be useful if you have custom build system and the location of SO files uses custom strings for ABIs.
        // Defaults to `android-debug.abiMap` configuration if available.
        "abiMap": {
            "armeabi-v7a": "arm",
            "arm64-v8a": "arm64",
            "x86": "x86",
            "x86_64": "x64",
        },

        // ABI to use for the current debug session.
        // This can be set to one of the ABIs directly, or to `select` to show a picker.
        "abi": "select",

        // Paths where to look for the SO files used in your app.
        // You can use `${command:abi}` and `{command:mappedAbi}` when specifying the paths.
        "symbolSearchPaths": [
            "${workspaceFolder}/app/build/intermediates/cmake/debug/obj/${command:abi}/",
        ],

        // All other options specified here are passes as is to the underlying Native debugger. See https://github.com/vadimcn/vscode-lldb/blob/master/MANUAL.md
    },

    // Options for java debugging
    "java": {
        // List of source paths for your java files.
        "sourcePaths": ["${workspaceFolder}/app/src/main/java"]

        // All other options specified here are passes as is to the underlying Java debugger. See https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-debug
    }
}

Configurations

The following settings can be set as per your requirements and setup.

SDK and NDK locations

  • android-debug.sdkRoot: Location for Android SDK on your machine
  • android-debug.ndkRoot: Location for Android NDK on your machine

Defaults for launch configuration

  • android-debug.abiSupported: List of supported ABIs for the app. Used as default when native.abiSupported is not specified in launch config.
  • android-debug.abiMap: Map of ABI to custom string. Used as default when native.abiMap is not specified in launch config.

vscode-android-debug's People

Contributors

nisargjhaveri avatar qhhonx avatar sr-tream avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

vscode-android-debug's Issues

launch error at native mode

When I run the launch in the "native" mode, app is waiting for the debugger to attach shown in the figure.
image

The debug console log is as follows.

Console is in 'commands' mode, prefix expressions with '?'.
Executing script: initCommands
Platform: remote-android
Connected: no

Platform: remote-android
Triple: aarch64-unknown-linux-android
OS Version: 33 (5.15.41-android13-8-00205-gf1bf82c3dacd-ab8747247)
Hostname: localhost
Connected: yes
WorkingDir: /data/user/0/com.carriez.flutter_hbb
Kernel: #1 SMP PREEMPT Sun Jun 19 02:44:07 UTC 2022

Attached to process 9914

The launch.json is as follows.
{
"name": "Android launch",
"type": "android-debug",
"request": "launch",
"target": "select",
//"target": "last-selected",
"mode": "native", // Change to java or native to attach only Java or Native debugger.
"packageName": "com.carriez.flutter_hbb", // Package name for your app.
"launchActivity": ".MainActivity", // Activity to launch
"resumeProcess": true,
"native": {
"symbolSearchPaths": [
// "${workspaceFolder}/flutter/android/app/src/main/jniLibs/arm64-v8a/",
],
},
"java": {
// "sourcePaths": ["${workspaceFolder}/flutter/android/app/src/main/java"]
}

`

ubuntu:"Cannot determine sdk root"

I have set the environment variable, but I still report an error, please help me to see how to deal with it, thank you very much

.bashrc
export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools

attach system_server

i want to attach system_server, but something went wrong
Can you tell me how to configure it?

image

Kotlin support

Do you have any plans to support Kotlin instead of Java?

[NOT A BUG] Magisk compatible

Modern magisk uses zygisk to inject code in applications - it's break loading image list for LLDB.

Possible solutions:

  • Disable zygisk
  • Use MagiskDelta
  • Use module MagiskHide, instead of zygisk

Install built APK to target

Is it possible to add an APK install to selected target option along with the current "launch" and "attach" options?
It would be nice to integrate installing a modified APK before using the dual-debugger ๐Ÿ˜ƒ.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.