java - NativeScript HelloWorld build.gradle错误

标签 java android gradle sdk nativescript

我坚持使用此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一起运行以获取完整的见解。
  • https://help.gradle.org上获得更多帮助

  • 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更新nativescript
    npm 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/

    相关文章:

    java - "java.lang.UnsatisfiedLinkError: Native method not found:"去掉头文件可以修复错误吗?

    android - 为 TableView 中的新项目设置动画

    java - 简单的常规程序失败,并出现错误:方法没有签名:java.lang.ProcessBuilder.inheritIO()适用于参数类型:()值:[]

    java - 将两个 JSON 数组的值合并为 JSONObject java

    android - 对 ListView 中的项目使用 setOnItemClickListener

    git - 是否可以通过grgit插件仅提交一个文件进行gradle。

    gradle - 使用 Gradle 时如何从多模块项目构建 jar?

    java - JPA的上下文注入(inject)

    java - 从 ArrayList 中删除对象(帐户)

    java - 如何按字母顺序排序(没有 Comparable 或 Comparator 接口(interface))