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エミュレータを起動し、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 emulate android」を呼び出して実行することはできます。

私の疑いは、VSCODE が環境を正しく認識できないか、拡張機能に問題またはバグがあるのではないかということです。

ご協力いただければ幸いです。

答え1

さて、検索中に興味深いものを見つけました。「Ubuntu のすべてのユーザーの環境変数を設定する」そしてこのウェブサイト

次に、その指示に従って設定しANDROID_HOME、システムを再起動しました。すると、NativeScript が環境を見つけ、実行中のエミュレーターでプロジェクトを実行しました。

また、cordova でも環境を見つけることができましたが、別の問題が発生しました。

cordova の答えが見つかったら、別の質問を投稿します。

これを正しく設定するために、3日間頭を悩ませてきました。

関連情報