首页 > 解决方案 > 带有 vue 和 ts 的 Nativescript 无法构建

问题描述

我创建了一个 nativescript vue 模板:

 sudo vue init nativescript-vue/vue-cli-template project

当我尝试使用 command: 运行它时,tns run出现以下错误:

Gradle build...

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* Where:
Build file '/home/petar/Documents/Workspace/js/project/platforms/android/app/build.gradle' line: 221

* What went wrong:
A problem occurred evaluating project ':app'.
> Invalid revision: undefined

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':app'.
> SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at '/home/petar/Documents/Workspace/js/roomy/roomy/platforms/android/local.properties'.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
==============================================================================

* Get more help at https://help.gradle.org

BUILD FAILED in 6s
Unable to apply changes on device: 2383f95c9f0d7ece. Error is: Command ./gradlew failed with exit code 1.

此外,我在运行命令后收到了几个警告。我安装了 Android Studio,尝试正确设置 JAVA_HOME 变量以及其他一些东西,但没有任何效果。

✖ 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 

标签: nativescript

解决方案


您已经安装了 Android Studio,但可能没有设置 ANDROID_SDK_ROOT 环境变量,如错误 2 和 tns 所指。您使用的是什么操作系统?


推荐阅读