问题描述
我正在开发Nativescript应用,并希望通过USB在我的物理Android设备(Huawei P10 lite)上运行它。
我下载了Android SDK CLI工具,并将其解压缩到我的~/Android/
目录中,并将环境变量ANDROID_HOME
设置为/home/<username>/Android
。当我运行tns run android
时,我希望该应用程序可以在手机上启动,但是会打印出来:
✔ Your ANDROID_HOME environment variable is set and points to correct directory. ✔ Your adb from the Android SDK is correctly 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. ✖ 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 Your environment is not configured properly and you will not be able to execute local builds.
没有迹象表明配置不正确。所以我不知道下一步该怎么做?
我正在Ubuntu 18.04.5上运行。我的~/Android/
目录看起来像
-rwxr--r-- android drwxr-xr-x bin/ drwxr-xr-x build-tools/ -rwxr--r-- emulator -rwxr--r-- emulator-check -rw-r--r-- .kNownPackages drwxr-xr-x lib/ drwxr-xr-x licenses/ -rwxr--r-- mksdcard -rwxr--r-- monitor -rw-r--r-- NOTICE.txt drwxr-xr-x platforms/ drwxr-xr-x platform-tools/ drwxr-xr-x proguard/ -rw-r--r-- source.properties drwxr-xr-x support/
我已经为adb
-> /home/<username>/Android/platform-tools/adb
和emulator
-> /home/<username>/Android/platform-tools/emulator
建立了符号链接,并将链接放置在~/.bin/
目录中。搜索终端命令时,将检查此目录,并且我可以通过这种方式从任何目录成功运行它们。
解决方法
经过一番摸索,我发现了问题所在。下载的Android CLI工具已提取到我的顶级CTRL+X
目录中。 CLI工具实际上应该放在~/Android/
目录中。进行此更改后,~/Android/tools/
没有发现问题,我可以成功运行tns doctor
。
我的tns run android
目录结构现在看起来像这样:
build-tools/ .knownPackages licenses/ platforms/ platform-tools/ tools/
~/Android/
目录现在看起来像这样:
android bin/ emulator emulator-check lib/ mksdcard monitor NOTICE.txt proguard/ source.properties support/
Part of the android setup that I missed 它说
您刚刚提取的存档是tools文件夹,因此在这种情况下,它将位于:/ usr / local / android / sdk / tools
在我的情况下,~/Android/tools/
是/usr/local/android/sdk
。