Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Cannot launch "Debug Android" (error code 303) #1666

Closed
Elias-Graf opened this issue Sep 17, 2021 · 9 comments
Closed

[Bug] Cannot launch "Debug Android" (error code 303) #1666

Elias-Graf opened this issue Sep 17, 2021 · 9 comments

Comments

@Elias-Graf
Copy link

🐛 What is the bug? How can we reproduce it?

When pressing the play button it just shows [Info] Starting Packager, and after a long time it fails with Could not start the packager. (error code 303). I normally launch the app with: npm start and then in a different terminal npm run android.

Steps:

  1. npx react-native init test
  2. open the project with code
  3. create the default launch.json for debug android & run that

Expected behavior

The packager to start

Debug output

Debug Console
Launching the application
An error occurred while launching the application. Could not start the packager. (error code 303)
React Native output channel
[Info] Starting Packager

[Error] Error: Could not start the packager.
Developer Tools console
console.ts:137 [Extension Host] (node:9562) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
(Use `code-insiders --trace-deprecation ...` to show where the warning was created) (at writeOut (internal/process/warning.js:43:3))
mainThreadExtensionService.ts:63 [[object Object]]s.tmpDir is not a function
mainThreadExtensionService.ts:64 TypeError: s.tmpDir is not a function
	at e._sendFirstFileOnDisk (vscode-file://vscode…t/rn-extension.js:1)
	at Timeout._onTimeout (vscode-file://vscode…t/rn-extension.js:1)
	at listOnTimeout (internal/timers.js:554)
	at processTimers (internal/timers.js:497)
mainThreadExtensionService.ts:63 [[object Object]]s.tmpDir is not a function
mainThreadExtensionService.ts:64 TypeError: s.tmpDir is not a function
	at e._sendFirstFileOnDisk (vscode-file://vscode…t/rn-extension.js:1)
	at Timeout._onTimeout (vscode-file://vscode…t/rn-extension.js:1)
	at listOnTimeout (internal/timers.js:554)
	at processTimers (internal/timers.js:497)
console.ts:137 [Extension Host] An error occurred while launching the application. Could not start the packager. (error code 303) (at u.log (/home/elias/.vscode-insiders/extensions/msjsdiag.vscode-react-native-1.6.1/dist/rn-extension.js:21:28847))

Environment

Please tell us about your system and your project:

  • npx react-native doctor or npx expo doctor if your project is using Expo:
Common
 ✖ Node.js
   - Version found: N/A
   - Version supported: >= 8.3
 ✖ npm
   - Version found: N/A
   - Version supported: >= 4.x

Android
 ✖ JDK
   - Version found: 1.8.0_292
   - Version supported: >= 8
 ✖ Android Studio - Required for building and installing your app on Android
 ✖ Android SDK - Required for building and installing your app on Android
   - Versions found: N/A
   - Version supported: 29.0.2
 ✖ ANDROID_HOME
  • envinfo:
  System:
    OS: Linux 5.11 Ubuntu 21.04 (Hirsute Hippo)
    CPU: (24) x64 AMD Ryzen 9 3900X 12-Core Processor
    Memory: 15.60 GB / 31.33 GB
    Container: Yes
    Shell: 5.8 - /usr/bin/zsh
  Managers:
    Apt: 2.2.4 - /usr/bin/apt
  Utilities:
    Make: 4.3
    GCC: 10.3.0
    Git: 2.30.2
    FFmpeg: 4.3.2 - /usr/bin/ffmpeg
  Virtualization:
    Docker: 20.10.8 - /usr/bin/docker
  IDEs:
    Nano: 5.4
  Languages:
    Bash: 5.1.4 - /usr/bin/bash
    Java: 1.8.0_292
    Perl: 5.32.1 - /usr/bin/perl
    Python3: 3.9.5
  Databases:
    MySQL: 0.21.04.3 - /usr/bin/mysql
    SQLite: 3.32.2 - /home/elias/Android/Sdk/platform-tools/sqlite3
  • React Native Tools extension version: v1.6.1
  • Expo SDK version (if applicable): -
@Elias-Graf Elias-Graf added the bug label Sep 17, 2021
@Elias-Graf Elias-Graf changed the title [Bug] Bug description [Bug] Cannot launch "Debug Android" (error code 303) Sep 17, 2021
@RedMickey
Copy link
Contributor

Hi @Elias-Graf and thanks for reaching us. According to your system environment information, it seems that there are no Node.js, Android SDK and ANDROID_HOME variable in the PATH.
Could you please tell us if you have completely set up your development environment according to the official React Native guide?
Could you please also tell us if you ran npx react-native doctor and envinfo commands in the system terminal or in the terminal in VS Code editor?

@Elias-Graf
Copy link
Author

Elias-Graf commented Sep 17, 2021

it seems that there are no Node.js

I wouldn't trust this doctor tool if it can't even run node -v and npm -v, I mean I'm clearly running npx react-native doctor, would be quite impressive if I managed that without node ;)

This might be interesting as well:

❯ which node
/snap/bin/node
❯ which npm
/usr/local/bin/npm
❯ which npx
/usr/local/bin/npx
❯ node -v
v14.17.6
❯ npm -v
7.20.0

Android SDK and ANDROID_HOME

Yeah, I have that inside a local.properties file, e.g.: sdk.dir=/home/elias/Android/Sdk

Could you please tell us if you have completely set up your development environment according to the official React Native guide?

Uh, sure, I've read through it and added the following "missing" configuration

export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools

to my .zshrc.

I've also installed the android Q SDK.

Is there more configuration I'm missing? (It seems weird that npm start and npm run android are working if it couldn't find something of that significance though).

Could you please also tell us if you ran npx react-native doctor and envinfo commands in the system terminal or in the terminal in VS Code editor?

I actuall don't remember, so here is both 😉

System terminal emulator:


 ✖ Node.js
   - Version found: N/A
   - Version supported: >= 8.3
 ✖ npm
   - Version found: N/A
   - Version supported: >= 4.x

Android
 ✖ JDK
   - Version found: 1.8.0_292
   - Version supported: >= 8
 ✖ Android Studio - Required for building and installing your app on Android
 ✓ Android SDK - Required for building and installing your app on Android
 ✓ ANDROID_HOME
  System:
    OS: Linux 5.11 Ubuntu 21.04 (Hirsute Hippo)
    CPU: (24) x64 AMD Ryzen 9 3900X 12-Core Processor
    Memory: 12.78 GB / 31.33 GB
    Container: Yes
    Shell: 5.8 - /usr/bin/zsh
  Managers:
    Apt: 2.2.4 - /usr/bin/apt
  Utilities:
    Make: 4.3
    GCC: 10.3.0
    Git: 2.30.2
    FFmpeg: 4.3.2 - /usr/bin/ffmpeg
  Virtualization:
    Docker: 20.10.8 - /usr/bin/docker
  SDKs:
    Android SDK:
      API Levels: 29, 30
      Build Tools: 29.0.2, 30.0.3
      System Images: android-30 | Google APIs Intel x86 Atom
  IDEs:
    Nano: 5.4
  Languages:
    Bash: 5.1.4 - /usr/bin/bash
    Java: 1.8.0_292
    Perl: 5.32.1 - /usr/bin/perl
    Python3: 3.9.5
  Databases:
    MySQL: 0.21.04.3 - /usr/bin/mysql
    SQLite: 3.32.2 - /home/elias/Android/Sdk/platform-tools/sqlite3

Integrated terminal:

 ✖ Node.js
   - Version found: N/A
   - Version supported: >= 8.3
 ✖ npm
   - Version found: N/A
   - Version supported: >= 4.x

Android
 ✖ JDK
   - Version found: 1.8.0_292
   - Version supported: >= 8
 ✖ Android Studio - Required for building and installing your app on Android
 ✓ Android SDK - Required for building and installing your app on Android
 ✓ ANDROID_HOME
  System:
    OS: Linux 5.11 Ubuntu 21.04 (Hirsute Hippo)
    CPU: (24) x64 AMD Ryzen 9 3900X 12-Core Processor
    Memory: 12.80 GB / 31.33 GB
    Container: Yes
    Shell: 5.8 - /usr/bin/zsh
  Managers:
    Apt: 2.2.4 - /usr/bin/apt
  Utilities:
    Make: 4.3
    GCC: 10.3.0
    Git: 2.30.2
    FFmpeg: 4.3.2 - /usr/bin/ffmpeg
  Virtualization:
    Docker: 20.10.8 - /usr/bin/docker
  SDKs:
    Android SDK:
      API Levels: 29, 30
      Build Tools: 29.0.2, 30.0.3
      System Images: android-30 | Google APIs Intel x86 Atom
  IDEs:
    Nano: 5.4
  Languages:
    Bash: 5.1.4 - /usr/bin/bash
    Java: 1.8.0_292
    Perl: 5.32.1 - /usr/bin/perl
    Python3: 3.9.5
  Databases:
    MySQL: 0.21.04.3 - /usr/bin/mysql
    SQLite: 3.32.2 - /home/elias/Android/Sdk/platform-tools/sqlite3

In both cases the command was executed inside the projects working directory :)

@RedMickey
Copy link
Contributor

@Elias-Graf Thanks for the outputs.
Could you please tell if you installed VS Code using snap store or from the .deb package? We had a similar issue with VS Code installed from snap store, and it was resolved after reinstallation of the editor from the .deb package.

@Elias-Graf
Copy link
Author

Elias-Graf commented Sep 17, 2021

❯ which code
/snap/bin/code
❯ which code-insiders
/snap/bin/code-insiders

@RedMickey It is indeed installed via snap, but I'm being honest here, I'm not really happy with the fix of installing another package :/.

VSCode has to be installed in classic (this is perhaps a better reference) mode, so there shouldn't be any difference.

@Elias-Graf
Copy link
Author

Elias-Graf commented Sep 17, 2021

Is this issue being tracked in the vscode repo or is it only happening with this extension?

@RedMickey
Copy link
Contributor

RedMickey commented Sep 22, 2021

@Elias-Graf While investigating this issue we found two similar issues in VS Code repo (issue1, issue2). The problem occurs if both Node.js and VS Code are installed from snap store. According to these comments (comment1, comment2, comment3) the issue could be in Node.js distributed via snap store.
Under the hood, in the extension we use Node.js child processes to run React Native CLI and npm commands. To start Node.js child processes we use spawn and exec functions which could work incorrectly and cause errors (if Node.js is installed from snap store). We found the open issue in nodejs/snap repo about this problem. So, the original issue could be on Node.js side. We also found out an interesting fact, that if one of VS Code and Node.js isn't installed from snap store, everything works fine, but installation of both of them via snap causes issues.
Thus, we would recommend to install Node.js from other sources than snap store to avoid incorrect behavior of Node.js spawn functions.

@Elias-Graf
Copy link
Author

Huh, how interesting. Is there anything I can do to help you and the node.js guys?

And good one on the investigation, very thorough 👍.

@etatanova
Copy link
Contributor

Hi @Elias-Graf We have reported about this issue to the nodejs/node and nodejs/snap repositories. So, we will track these issues and test proposed fixes. Since it's a Node.js issue, we don't think there's anything actionable from the React Native Tools side on this. Thank you for your assistance!
Until the issues in Node.js are fixed, as the workaround we would recommend to install Node.js from other source than the Snap Store.

@etatanova
Copy link
Contributor

etatanova commented Sep 27, 2021

@Elias-Graf I am closing this issue because this is an external issue (Node.js related). Please feel free to open new ones if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants