gpt4 book ai didi

android - 使用 vs 代码对 native docker 容器使用react以发布到主机操作系统上的 android 模拟器

转载 作者:行者123 更新时间:2023-12-02 17:49:14 25 4
gpt4 key购买 nike

我正在尝试在 vs 代码上运行一个 react 原生 docker 容器。我能够运行我的代码。但是,容器无法检测到在我的主机上运行的 android 模拟器。I followed along in this tutorial course: https://code.visualstudio.com/docs/remote/containers
&
https://github.com/microsoft/vscode-react-native
正在运行

npx react-native run-androidhowever, I get an error message that my emulator is not running. errorFailed to install the app. Make sure you have an Android emulatorrunning or a device connected. Run CLI with --verbose flag for moredetails. Error: Command failed: ./gradlew app:installDebug-PreactNativeDevServerPort=8081


我的 devcontainer.json:-
{
"name": "React Native Android Container",

// Sets the run context to one level up instead of the .devcontainer folder.
"context": "..",

// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
"dockerFile": "Dockerfile",

"runArgs": [
"--privileged", // give all capabilities to a container, in other words, the container can then do almost everything that the host can do
"--net",
"host", // forwarding all host machine ports
"-v",
"/dev/bus/usb:/dev/bus/usb" // mount connected USB devices to a container
],


"settings": {
// This will ignore your local shell user setting for Linux since shells like zsh are typically
// not in base container images. You can also update this to an specific shell to ensure VS Code
// uses the right one for terminals and tasks. For example, /bin/bash (or /bin/ash for Alpine).
"terminal.integrated.shell.linux": null
},

// Add the IDs of extensions you want to be installed when the container is created in the array below.
"extensions": ["msjsdiag.vscode-react-native"]
}
runArgs“主机”应该转发所有端口。我想我需要一个相反的类似论点?

最佳答案

检查 android/gradlew 的权限.可以使用以下命令检查权限:stat -c "%a %n" android/gradlew权限应为 755。如果不是,请在您的应用根文件夹中将权限更改为 755。chmod 755 android/gradlew然后运行 ​​react-native run-android

关于android - 使用 vs 代码对 native docker 容器使用react以发布到主机操作系统上的 android 模拟器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64411523/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com