I'm trying to launch an Ionic app on my Android device from VS Code, using the vscode-cordova extension.
My launch.json looks like this:
{
"version": "0.2.0",
"configurations": [
{
"name": "Run android on device",
"type": "cordova",
"request": "launch",
"platform": "android",
"target": "device",
"sourceMaps": true,
"cwd": "${workspaceFolder}",
"ionicLiveReload": true
}
]
}
But I get following error message:
[cordova-tools] Error processing "launch": The Ionic live reload server exited
unexpectedly
The debug console does offer a bit more information:
Launching for android (This may take a while)...
Starting Ionic dev server (live reload: true)
The Ionic live reload server exited unexpectedly
How can I overcome this issue?
Trying to run ionic cordova run android -l revealed the issue:
[ERROR] Multiple network interfaces detected!
You must select an external-facing IP for the dev server that your device or emulator has access to with the --address option.
So adding the --address option to the runArguments of my launch.json as lined out in the readme resolved my issue:
{
"version": "0.2.0",
"configurations": [
{
"name": "Run android on device",
"type": "cordova",
"request": "launch",
"platform": "android",
"target": "device",
"sourceMaps": true,
"cwd": "${workspaceFolder}",
"ionicLiveReload": true,
"runArguments": [
"--address 192.168.1.2"
]
}
]
}
Where 192.168.1.2 is the ip address of my dev laptop. Also make sure this ip address is reachable from your device.
Related
flutter emulators
"Unable to find any emulator sources. Please ensure you have some
Android AVD images available." I am using win10, but when I want to connect to emulator with flutter I get this error. How do I introduce my device in genymotion to Visual Studio Code ?
Launch your emulator, then run in terminal
flutter devices
Then in your file launch.json inside .vscode folder in your project, you can create something like the code above and name the emulators and put the deviceId that you see when you write ´flutter devices`
{
"version": "0.2.0",
"configurations": [
{
"name": "budgets",
"request": "launch",
"type": "dart"
},
{
"name": "iPhone 12 Pro Max",
"request": "launch",
"type": "dart",
"deviceId": "007153FC-9053-4A68-851A-20D1B6013518"
},
{
"name": "iPhone 11",
"request": "launch",
"type": "dart",
"deviceId": "73EE2120-4DB0-42FD-AA3A-DD4D417FE40A"
},
{
"name": "Android",
"request": "launch",
"type": "dart",
"deviceId": "emulator-5554"
}
]
}
I solved the problem by uninstalling vs code, genymotion and virtualbox and reinstalling them.
I am new to React Native and trying to get my first React application to run on Android Emulator. I am getting this error message when running the debugger:
Could not debug. Error while executing command
'c:\Users...\weather4\node_modules.bin\react-native.cmd run-android
--no-packager': Error while executing command 'c:\Users...\weather4\node_modules.bin\react-native.cmd run-android
--no-packager' (error code 101)
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Android",
"cwd": "${workspaceFolder}",
"type": "reactnative",
"request": "launch",
"platform": "android"
},
{
"name": "Attach to packager",
"cwd": "${workspaceFolder}",
"type": "reactnative",
"request": "attach"
},
]
}
settings.json
{
"dart.flutterSdkPath": "C:\\src\\flutter",
"react-native.packager.port": 19001
}
Path env variable
C:\Users\...\.vscode\extensions\msjsdiag.vscode-react-native-0.16.0\src\common
I was getting similar errors and found this fix:
Uninstall Flutter (and Dart) extensions from Visual Studio Code.
Close Visual Studio Code, delete the .vscode folder and open Visual Studio Code again.
Configure the "Run and debug" panel again so you can run the app.
Error:
******** Unhandled error in debug adapter: SyntaxError: Unexpected token L in JSON at position 0
at JSON.parse (<anonymous>)
at Pipe.channel.onread (internal/child_process.js:471:28)
Hello Guys,
I had found a lot of other issues/questions like this here and any where else, but no of them includes "Unhandled error in debug adapter". I had tried a lot of workflows, but nothing worked.
Short Introduction:
OS: Windows 64x
IDE: VS Code (version: 1.25.1 / launch.json see below)
vscode-Plugin: React Native Tools (version: 0.6.12)
Language/Framework: React-Native
(React-version: 16.4.1 /RN-version 0.55.4 / cli-version: 2.0.1)
Project: Android App (iOS followed later)
Output of React-Native: Run android
Installing APK 'app-debug.apk' was successful.
Output of React-Native: Starting custom debugger by executing: echo A debugger is not needed: "[project-location]" "[project-location].vscode"
Starting App with react-native run-android via terminal still working.
Try following troubleshooting steps:
comment out all JSON.parse() calls
check all fetch based functions
check older repository revisions
repair vscode
reinstall vscode
update RN to 0.56.0
change mobile device
Existing project is to large to show it here and dosn't exist in a public repo.
launch.json - I'm using "Debug Android"
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Android",
"program": "${workspaceRoot}/.vscode/launchReactNative.js",
"type": "reactnative",
"request": "launch",
"platform": "android",
"sourceMaps": true,
"outDir": "${workspaceRoot}/.vscode/.react",
},
{
"name": "Debug iOS",
"program": "${workspaceRoot}/.vscode/launchReactNative.js",
"type": "reactnative",
"request": "launch",
"platform": "ios",
"sourceMaps": true,
"outDir": "${workspaceRoot}/.vscode/.react"
},
{
"name": "Attach to packager",
"program": "${workspaceRoot}/.vscode/launchReactNative.js",
"type": "reactnative",
"request": "attach",
"sourceMaps": true,
"outDir": "${workspaceRoot}/.vscode/.react"
},
{
"name": "Debug in Exponent",
"program": "${workspaceRoot}/.vscode/launchReactNative.js",
"type": "reactnative",
"request": "launch",
"platform": "exponent",
"sourceMaps": true,
"outDir": "${workspaceRoot}/.vscode/.react"
}
]
}
I don't know where the problem is located:
project
vscode
node
...
Logcat prints only [INFO] no Warnings and no Errors.
Want to debug project with debug terminal of vscode, because debugging with chrome doesn't work with breakpoints.
I'm very new at working with vscode and RN, please explain possible solutions a little bit more detailed.
Thanks in advance.
Chris
The error is in the vscode-react-native extension. There's already been a pull request made to fix this, but if you're feeling adventurous, go to your vscode extensions folder, open the vscode-react-native folder, go to src/debugger/forkedAppWorker.js and replace the following lines:
const nodeArgs = [`--inspect=${port}`, "--debug-brk", scriptToRunPath];
with
const nodeArgs = [`--inspect=${port}`, "--debug-brk"];
and
this.debuggeeProcess = child_process.spawn("node", nodeArgs, {
stdio: ["pipe", "pipe", "pipe", "ipc"],
})
with
this.debuggeeProcess = child_process.fork(scriptToRunPath, nodeArgs)
For more details see the actual file change log (don't worry about it being .ts vs .js, and don't worry about the other two files being changed).
I am trying to setup debug environment for react-native on VS Code on Mac.
This is launch.json :
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Debug iOS",
"program": "${workspaceRoot}/.vscode/launchReactNative.js",
"type": "reactnative",
"request": "launch",
"platform": "ios",
"sourceMaps": true,
"outDir": "${workspaceRoot}/.vscode/.react",
"target": "simulator"
},
{
"name": "Debug Android",
"program": "${workspaceRoot}/.vscode/launchReactNative.js",
"type": "reactnative",
"request": "launch",
"platform": "android",
"sourceMaps": true,
"outDir": "${workspaceRoot}/.vscode/.react"
},
{
"name": "Attach to packager",
"program": "${workspaceRoot}/.vscode/launchReactNative.js",
"type": "reactnative",
"request": "attach",
"sourceMaps": true,
"outDir": "${workspaceRoot}/.vscode/.react"
},
{
"name": "Debug in Exponent",
"program": "${workspaceRoot}/.vscode/launchReactNative.js",
"type": "reactnative",
"request": "launch",
"platform": "exponent",
"sourceMaps": true,
"outDir": "${workspaceRoot}/.vscode/.react"
}
]
}
On debugging I am getting the error - Debug adapter process has terminated unexpectedly. along with one more error.
I have opened an issue on Github as well but haven't received a solution yet.
Update : In response to ShaneG answer, I am adding screenshots of project scheme and info.plist
Check this: in your .vsCode folder, see if you have a .react folder in there.
If you don't, try running code . from the root directory of your project folder. You will need to install the shell command from VSCode if you haven't already (type shift-command-p and search for Shell command: Install code command PATH).
This was my issue, for whatever reason the .react folder was not being created when I opened VSCode from spotlight.
I see its "Debug ios" you ran. Can you make sure its pointing to the correct info.plist file? Many errors can crop up if its pointing to an old info.plist.
I can see on the GitHub issue you posted, when you ran it from the command line it outputted a very useful error.
An application bundle was not found at the provided path.
Provide a valid path to the desired application bundle.
Print: Entry, ":CFBundleIdentifier", Does Not Exist
Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier
build/Build/Products/Debug-iphonesimulator/firstdemo.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist
Its trying to access the bundleIdentifier but it cannot seem to find it. This info should be inside the info.plist file. Your app might be routed to an old info.plist file that does not have this information.
How to check if its pointing to the correct info.plist?
First before we go into the info.plist, in xcode go to Product -> Scheme
-> Edit Scheme. In here go to Run and check what your build config is
set to. The error above is coming from Debug, so if your build config
is set to Release this may be the issue. This may mean Release has the
info.plist and Debug does not have this bundle info because its not
built in it.
In here there is also a "Debug Executable" check box. This may need to
be checked
If none of that works, although it might, maybe check the info.plist inside your project folder in xcode. See if it has a bundle identifier.
I would say the Scheme section is probably the problem so hopefully that helps you!
Delete React Native Tools extension from vs-code and then reinstall it.
It works fine post that.
I searched but I can't find any external sources except for Visual Studio Code docs, and just following those docs don't allow to debug React Native apps both in iOS or Android.
I keep getting the error message (this one for Android, for iOS is similar:
[vscode-react-native] [Warning] Couldn't import script at
http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false.
Debugging won't work: Try reloading the JS from inside the app, or
Reconnect the VS Code debugger: path must be a string
My launch.json file as:
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Android",
"program": "${workspaceRoot}/.vscode/launchReactNative.js",
"type": "reactnative",
"request": "launch",
"platform": "android",
"internalDebuggerPort": 9090,
"sourceMaps": true,
"outDir": "${workspaceRoot}/.vscode/.react"
},
{
"name": "Debug iOS",
"program": "${workspaceRoot}/.vscode/launchReactNative.js",
"type": "reactnative",
"request": "launch",
"platform": "ios",
"target": "iPhone 6s",
"internalDebuggerPort": 9090,
"sourceMaps": true,
"outDir": "${workspaceRoot}/.vscode/.react"
},
{
"name": "Attach to packager",
"program": "${workspaceRoot}/.vscode/launchReactNative.js",
"type": "reactnative",
"request": "attach",
"internalDebuggerPort": 9090,
"sourceMaps": true,
"outDir": "${workspaceRoot}/.vscode/.react"
},
{
"name": "Debug in Exponent",
"program": "${workspaceRoot}/.vscode/launchReactNative.js",
"type": "reactnative",
"request": "launch",
"platform": "exponent",
"internalDebuggerPort": 9090,
"sourceMaps": true,
"outDir": "${workspaceRoot}/.vscode/.react"
}
]
}
I'm trying to debug both in the iOS simulator or in an Android device but the process never attaches to the external JS debugger.
Go to debug option in vscode and select debugging type
select attach to packager
run your react native app by
react-native run-android
-> shake the phone and select Debugg remote JS option
Done...
You can use Vscode extension "React native tools" for debugging react-native apps.