Code Monkey home page Code Monkey logo

Comments (9)

mpotthoff avatar mpotthoff commented on July 16, 2024

Hey!

So this sounds really weird to me. I can't say that I have ever heard of an issue like that. Have you verified that you have setup your android sdk installation correctly?

What happens when you run adb devices in the VSCode terminal? If it shows the same error then there is probably something wrong with your android platform tools installation.

from vscode-android-webview-debug.

ramikhafagi96 avatar ramikhafagi96 commented on July 16, 2024

@mpotthoff running adb devices in vscode terminal lists the emulator and works fine, and Android SDK is included properly in the environment variables

from vscode-android-webview-debug.

mpotthoff avatar mpotthoff commented on July 16, 2024

Hmhhh. Weird. Have you tried setting the android-webview-debug.adbPath configuration parameter to the exact location of adb executable just to go sure that nothing weird is going on with the PATH env variable? (preferably the same location reported by which adb and type adb)

from vscode-android-webview-debug.

ramikhafagi96 avatar ramikhafagi96 commented on July 16, 2024

@mpotthoff yes at first when I installed the extension I had to set this configuration parameter because I had this error failed to load adb executable when I set it I got the error I mentioned after it. However, I managed to put android platform tools to my environment variables and I didn't need to set android-webview-debug.adbPath myself.

from vscode-android-webview-debug.

mpotthoff avatar mpotthoff commented on July 16, 2024

Okay and just to go sure - You have also removed the parameter from your settings.json again? (Just uninstalling and reinstalling won't remove the setting). Because the error can also be caused by an invalid path to the adb executable.

Otherwise you could also try running sudo chmod a+x <path-to>/adb.

from vscode-android-webview-debug.

ramikhafagi96 avatar ramikhafagi96 commented on July 16, 2024

@mpotthoff yes I removed the parameter from settings.json after including the path in my environment variables, I also gave the path executable permission using sudo chmod -R a+rwx <path-to>/adb

from vscode-android-webview-debug.

mpotthoff avatar mpotthoff commented on July 16, 2024

Okay. What happens when you create a script with the content

const child_process = require("child_process");

let outBuff = Buffer.alloc(0);
let errBuff = Buffer.alloc(0);

const process = child_process.spawn("adb", ["devices", "-l"]);

process.stdout.on("data", (data) => {
    outBuff = Buffer.concat([outBuff, Buffer.from(data)]);
});
process.stderr.on("data", (data) => {
    errBuff = Buffer.concat([errBuff, Buffer.from(data)]);
});

process.on("error", (err) => {
    console.log("error");
    console.log("err", err);
    console.log("stdout");
    console.log(outBuff.toString("UTF-8"));
    console.log("stderr");
    console.log(errBuff.toString("UTF-8"));
});
process.on("close", (code) => {
    console.log("close");
    console.log("code", code);
    console.log("stdout");
    console.log(outBuff.toString("UTF-8"));
    console.log("stderr");
    console.log(errBuff.toString("UTF-8"));
});

and run it with node in your terminal? What is the exact output? This is basically the same way I execute adb in the extension.

from vscode-android-webview-debug.

ramikhafagi96 avatar ramikhafagi96 commented on July 16, 2024

@mpotthoff This is the output I got:

close
code 0
stdout
List of devices attached
emulator-5554          device product:sdk_phone_x86 model:Android_SDK_built_for_x86 device:generic_x86 transport_id:3


stderr


from vscode-android-webview-debug.

ramikhafagi96 avatar ramikhafagi96 commented on July 16, 2024

I modified the process.on("error") inside adb(options, ...args) method in adb.js to the following:

process.on("error", (err) => {
            reject(new Error(JSON.stringify(options)));
}); 

in order to see the path printed and what I got is /Users/ramikh96/Library/Android/sdk/platform-tools so it was missing /adb. I tried adding the path again to the configuration parameter android-webview-debug.adbPath as /Users/ramikh96/Library/Android/sdk/platform-tools/adb but it also resulted in the same error. So what I did is I've put an if condition before const process = child_process.spawn(options.executable, [...options.arguments, ...args]); to check if the path is missing /adb and the extension worked just fine.

if (options.executable.split('/').pop() !== 'adb') {
     options.executable = options.executable.concat('/adb');
}

UPDATE:
I found out that I added this path /Users/ramikh96/Library/Android/sdk/platform-tools in User settings on vscode and I only removed the path in configuration from Workspace settings, so it seems that getting the configuration value was from User settings, so It was my fault not removing it from User settings as well.

from vscode-android-webview-debug.

Related Issues (10)

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.