距离我尝试设置Android环境已经4天了,但仍然出现很多错误。我放弃了重新安装Mac OS的地步,但仍然找不到解决方法
我按照文档建议安装了nativescript,但是运行tns doctor
时出现以下错误:
✔ Getting environment information
TIP: To avoid setting up the necessary environment variables, you can use the Homebrew package manager to install the Android SDK and its dependencies.
There seem to be issues with your configuration.
✔ Getting NativeScript components versions information...
✔ Component nativescript has 4.1.2 version and is up to date.
✔ Component tns-core-modules has 4.1.0 version and is up to date.
✖ Component tns-android is not installed.
✖ Component tns-ios is not installed.
✔ Javac is installed and is configured properly.
✔ The Java Development Kit (JDK) is installed and is configured properly.
✔ Xcode is installed and is configured properly.
✔ xcodeproj is installed and is configured properly.
✔ CocoaPods update is not required.
✔ Your current CocoaPods version is newer than 1.0.0.
✔ Python installed and configured correctly.
✔ The Python 'six' package is found.
✖ 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: 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: 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
✖ Cannot find a compatible Android SDK for compilation. To be able to build for Android, install Android SDK 22 or later.
Run `$ sdkmanager` to manage your Android SDK versions.
✖ You need to have the Android SDK Build-tools installed on your system. You can install any version in the following range: '>=23 <=27'.
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.
✖ You need to have Android SDK 22 or later and the latest Android Support Repository installed on your system.
Run `$ sdkmanager` to manage the Android Support Repository. In case you already have it installed, make sure `ANDROID_HOME` environment variable is set correctly.
✖ WARNING: CocoaPods is not installed or is not configured properly.
You will not be able to build your projects for iOS if they contain plugin with CocoaPod file.
To be able to build such projects, verify that you have installed CocoaPods.
You have nativescript-cloud extension installed, so you can execute cloud builds, but your environment is not configured properly and you will not be able to execute local builds. To continue, choose one of the following options:
Select "Configure for Local Builds" to run the setup script and automatically configure your environment for local builds.
Select "Skip Step and Configure Manually" to disregard this option and install any required components manually.
You have nativescript-cloud extension installed, so you can execute cloud builds, but your environment is not configured properly and you will not be able to execute local builds. To continue, choose one of the following options:
Select "Configure for Local Builds" to run the setup script and automatically configure your environment for local builds.
Select "Skip Step and Configure Manually" to disregard this option and install any required components manually.
? To continue, choose one of the following options: (Use arrow keys)
❯ Try Cloud Operation
Configure for Local Builds
Skip Step and Configure Manually
我检查了每个错误以及每个错误中的每个URL,而没有弄清楚这一点。
我检查了我的〜/ .bash_profile和$ANDROID_HOME
中是否有$JAVA_HOME
。
我的〜/ .bash_profile具有以下两个路径:
export ANDROID_HOME=/usr/local/share/android-sdk
export JAVA_HOME=/Library/Java/Home
当我运行tns doctor并选择“配置本地版本”时,它开始重新下载“ Google Chrome”,“ Homebrew”,“ Java SE”等,即使如此,我仍然遇到相同的错误。
即使在我得到与'tns doctor'命令相同的输出的情况下,我仍然尝试指定仿真器。
答案 0 :(得分:1)
如果您不想安装Android Studio,则可以尝试遵循this step-by-step setup。
在macOS上,根据我的经验,最好的解决方案是install Android Studio。
之后,您可以使用Android Studio来管理SDK版本和android仿真器(在开发过程中更好地调试,分析和查看日志)并接受许可证。
指向Android Studio安装的SDK和构建工具的环境变量(将添加到bash配置文件中)为:
export ANDROID_HOME=/Users/{{ username }}/Library/Android/sdk
export ANDROID_SDK_ROOT=$ANDROID_HOME
然后,重新启动计算机(否则,您可能将无法从Android Studio启动模拟器)。重新启动后,打开终端并输入
echo $ANDROID_HOME
验证路径设置正确。