gpt4 book ai didi

node.js - React native 与 Windows Ubuntu 子系统无法找到 Android Studio

转载 作者:行者123 更新时间:2023-12-04 19:26:52 25 4
gpt4 key购买 nike

我是一名初学者,正在尝试使用 React Native 学习跨平台应用程序开发,并且正在使用我最熟悉的开发环境——Ubuntu。但是,我使用的是 Windows 11 的内置 Ubuntu 子系统,这常常让我头疼。
对于 React Native,要求是:JDK、Android Studio 和 Android SDK。我用 apt 安装了 JDK(尽管 Windows 已经安装了 Java 8?),并且已经为 Windows 下载了 Android Studio。当我运行 React Native 的医生命令时,它告诉我 Android Studio 和 SDK 没有安装——大概是因为它们不是 React Native 期望它们安装的地方。我尝试了各种方法,将二进制位置添加到 PATH,将符号链接(symbolic link)添加到/usr/local 中的二进制文件,安装 Android 命令行工具,查看 React Native 医生源代码……等等,但坦率地说,我没有不知道该怎么办。有任何想法吗?
react-native doctor
Android binaries
React Native 医生 Android Studio“健康检查”的源码:

"use strict";

Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;

function _path() {
const data = require("path");

_path = function () {
return data;
};

return data;
}

var _downloadAndUnzip = require("../../../tools/downloadAndUnzip");

var _executeWinCommand = require("../../../tools/windows/executeWinCommand");

var _androidWinHelpers = require("../../../tools/windows/androidWinHelpers");

var _createShortcut = require("../../../tools/windows/create-shortcut");

var _default = {
label: 'Android Studio',
description: 'Required for building and installing your app on Android',
getDiagnostics: async ({
IDEs
}) => {
const needsToBeFixed = IDEs['Android Studio'] === 'Not Found';
const missing = {
needsToBeFixed,
version: IDEs['Android Studio']
}; // On Windows `doctor` installs Android Studio locally in a well-known place

if (needsToBeFixed && process.platform === 'win32') {
const androidStudioPath = (0, _path().join)((0, _androidWinHelpers.getUserAndroidPath)(), 'android-studio', 'bin', 'studio.exe').replace(/\\/g, '\\\\');
const {
stdout
} = await (0, _executeWinCommand.executeCommand)(`wmic datafile where name="${androidStudioPath}" get Version`);
const version = stdout.replace(/(\r\n|\n|\r)/gm, '').trim();

if (version === '') {
return missing;
}

return {
needsToBeFixed: false,
version
};
}

return missing;
},
win32AutomaticFix: async ({
loader
}) => {
// Need a GitHub action to update automatically. See #1180
const androidStudioUrl = 'https://redirector.gvt1.com/edgedl/android/studio/ide-zips/3.6.3.0/android-studio-ide-192.6392135-windows.zip';
const installPath = (0, _androidWinHelpers.getUserAndroidPath)();
await (0, _downloadAndUnzip.downloadAndUnzip)({
loader,
downloadUrl: androidStudioUrl,
component: 'Android Studio',
installPath: installPath
});
const prefix = process.arch === 'x64' ? '64' : '';
const binFolder = (0, _path().join)(installPath, 'android-studio', 'bin');
await (0, _createShortcut.createShortcut)({
path: (0, _path().join)(binFolder, `studio${prefix}.exe`),
name: 'Android Studio',
ico: (0, _path().join)(binFolder, 'studio.ico')
});
loader.succeed(`Android Studio installed successfully in "${installPath}".`);
},
runAutomaticFix: async ({
loader,
logManualInstallation
}) => {
loader.fail();
return logManualInstallation({
healthcheck: 'Android Studio',
url: 'https://reactnative.dev/docs/environment-setup'
});
}
};
exports.default = _default;

//# sourceMappingURL=androidStudio.js.map

最佳答案

在/opt 中向 Android Studio 导向器添加符号链接(symbolic link)就可以了!然后我不得不在 $ANDROID_HOME/platform_tools 中将 adb.exe 的副本重命名为 adb .

关于node.js - React native 与 Windows Ubuntu 子系统无法找到 Android Studio,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70022740/

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