
我是新來的,我決定全職切換到 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 模擬器,然後嘗試在 Android 上執行 id did Launch 並取得
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 emulate android」。
我懷疑 VSCODE 無法正確查看環境,或者擴展是否有問題或錯誤?
感謝任何提供的幫助。
答案1
好吧,我在搜尋時發現了一些有趣的東西,“為 Ubuntu 中的所有使用者設定環境變數”並得到了這個網站
然後我按照它的說明進行設定ANDROID_HOME
並重新啟動系統......然後。現在 NativeScript 找到了環境並在運行模擬器中運行了該專案..
此外,科爾多瓦也能夠找到環境,但給我帶來了不同的問題。
如果我能找到科爾多瓦的答案,我會發布另一個問題。
三天來我一直在絞盡腦汁……為了正確地設定它。