VSCODE Ubuntu 看不到$ANDROID_HOME

VSCODE Ubuntu 看不到$ANDROID_HOME

我是新来的,我决定全职转向 Ubuntu,将开发应用程序作为一种爱好。

因为我有一个 AMD CPU“RYZEN”仿真,所以发现在 Ubuntu 中运行良好,因为它有硬件模拟,然后继续安装 Android Studio 等,Java 并设置环境变量..

然后安装NativeScript,并运行环境测试tns doctor,结果如下:

✔ Getting environment information 

No issues were detected.
✔ Your ANDROID_HOME environment variable is set and points to correct directory.
✔ Your adb from the Android SDK is correctly installed.
✔ The Android SDK is installed.
✔ A compatible Android SDK for compilation is found.
✔ Javac is installed and is configured properly.
✔ The Java Development Kit (JDK) is installed and is configured properly.
✔ Local builds for iOS can be executed only on a macOS system. To build for iOS on a different operating system, you can use the NativeScript cloud infrastructure.
✔ Getting NativeScript components versions information...
✔ Component nativescript has 6.0.3 version and is up to date.

然后我安装了 VSCODE,然后创建了一个测试 Nativescript 项目,并且创建正确,在 VSCODE 中打开它并创建一个调试配置

然后启动 Android 模拟器,然后尝试运行 id did Launch on Android 并得到

WARNING: The ANDROID_HOME environment variable is not set or it points to a non-existent directory. You will not be able to perform any build-related operations for Android. 
 To be able to perform Android build-related operations, set the `ANDROID_HOME` variable to point to the root of your Android SDK installation directory. 


WARNING: WARNING: adb from the Android SDK is not installed or is not configured properly.  
 For Android-related operations, the NativeScript CLI will use a built-in version of adb.
To avoid possible issues with the native Android emulator, Genymotion or connected
Android devices, verify that you have installed the latest Android SDK and
its dependencies as described in http://developer.android.com/sdk/index.html#Requirements 

WARNING: WARNING: The Android SDK is not installed or is not configured properly. 
 You will not be able to run your apps in the native emulator. To be able to run apps
in the native Android emulator, verify that you have installed the latest Android SDK 
and its dependencies as described in http://developer.android.com/sdk/index.html#Requirements 

WARNING: Cannot find a compatible Android SDK for compilation. To be able to build for Android, install Android SDK 28 or later. 
 Run `$ sdkmanager` to manage your Android SDK versions. 

WARNING: You need to have the Android SDK Build-tools installed on your system. You can install any version in the following range: '>=23 <=28'. 
 Run `$ sdkmanager` from your command-line to install required `Android Build Tools`. In case you already have them installed, make sure `ANDROID_HOME` environment variable is set correctly. 

Javac is installed and is configured properly.
The Java Development Kit (JDK) is installed and is configured properly.
Local builds for iOS can be executed only on a macOS system. To build for iOS on a different operating system, you can use the NativeScript cloud infrastructure.

如果我以普通用户身份运行终端,tns run应用程序就会被创建并附加到Android模拟器。

我在 Cordova 中遇到了同样的问题,给出了类似的错误 $ANDROID_HOME 未正确设置错误,但我仍然可以运行调用“cordova 模拟 android”。

我怀疑 VSCODE 无法正确看到环境,或者扩展存在问题或错误?

感谢任何给予的帮助。

答案1

好的,我在搜索时发现了一些有趣的东西,“为 Ubuntu 中的所有用户设置环境变量”并得到本网站

然后我按照它的说明,ANDROID_HOME在那里进行设置并重新启动系统..现在 NativeScript 找到了环境并在运行模拟器中运行了该项目..

此外,cordova 也能够找到环境,但却给我带来了不同的问题。

如果我能找到 cordova 的答案,将会发布另一个问题。

三天来我一直在绞尽脑汁……为了正确地设置它。

相关内容