我坚持使用此https://docs.nativescript.org/start/cli-basics NativeScript HelloWorld示例。
当我运行“tns doctor”时,一切似乎都很好,当我运行“tns device”时,我可以看到处于已连接状态的avd。
但是,当我尝试使用“tns run android”运行我的项目时,我收到了gradle错误。我以前从未使用过gradle,而且Im对移动开发来说真的很陌生,所以我不知道我可以做些什么来解决这个问题。消息:
$ tns run android
Skipping node_modules folder! Use the syncAllFiles option to sync files from this folder.
Searching for devices...
Skipping prepare.
Building project...
Gradle build...
FAILURE: Build failed with an exception.
构建文件'/home/lars/Projects/app/Test/platforms/android/app/build.gradle'行:24
评估项目':app'时发生问题。
Could not initialize class com.android.build.gradle.internal.crash.PluginCrashReporter
使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行,以获取更多日志输出。与--scan一起运行以获取完整的见解。
1秒内失败
无法在设备上应用更改:emulator-5554。错误是:命令./gradlew失败,退出代码为1。
停止webpack监视
我正在使用Ubuntu版本18.04(Kubuntu),Java版本“1.8.0_201”和
tns info
给出以下信息:✔ Getting NativeScript components versions information...
✔ Component nativescript has 5.2.2 version and is up to date.
✔ Component tns-core-modules has 5.2.2 version and is up to date.
✔ Component tns-android has 5.2.1 version and is up to date.
✔ Component tns-ios has 5.2.0 version and is up to date.
我已经试图解决这个问题好几天了,却不知道该怎么办。
最佳答案
我不知道它是否有用,但我注意到新的NativeScript 6.0版在构建gradle时存在许多问题。错误控制台类似于以下错误:
Build file 'D:\NativeScriptApps\<MyAppName>\platforms\android\app\build.gradle' line: 254
A problem occurred evaluating project ':app'.
我按照以下步骤解决了:1.如果未从官方站点下载,请安装新版本的Node.js。您应该收到以下消息:
Support for Node.js 8.0.0.0 is deprecated and will be removed in one of the next releases of NativeScript. Upgrade to the next LTS version.
2.然后使用CLI更新nativescriptnpm install -g nativescript
3.添加带有CLI的Android Platform 5.2.0(以防万一,更改当前版本)tns platform add android@5.2.0
4.迁移到新版本的{N}和依赖项(将平台报告给预览版)tns migrate
tns run android [ios]
tns run android
,则使用tns update
制作android / ios 希望一切顺利。
问候。
关于java - NativeScript HelloWorld build.gradle错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55110335/