Gradle获取意外令牌,编译文件 [英] Gradle gets unexpected token, compile files

查看:85
本文介绍了Gradle获取意外令牌,编译文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在做什么错?我指的是

What am I doing wrong ? I am referring to this

build.gradle

compile files('libs/redisson-1.3.2-SNAPSHOT.jar')

ls libs /

$ ls libs/
redisson-1.3.2-SNAPSHOT.jar

错误

* Where:
Build file '/myfolder/myproject/build.gradle' line: 162

* What went wrong:
Could not compile build file '/myfolder/myproject/build.gradle'.
> startup failed:
  build file '/myfolder/myproject/build.gradle': 162: unexpected token: redisson @ line 162, column 23.
            compile files('libs/redisson-1.3.2-SNAPSHOT.jar')
                           ^

  1 error


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

BUILD FAILED

Total time: 1.942 secs


推荐答案

我遇到了相同的问题,并已解决。

I got the same issue and fixed it.

原因:此问题是由于build.gradle文件中的未解决依赖性而引起的。 。下面的示例将更加清楚:
示例:我在build.gradle文件中给出了json-simple依赖关系,这将导致下一行的构建错误。
1.

Cause: This issue comes because of unresolved dependency in build.gradle file. It would be more clear by below example: Example: I have given a json-simple dependency in build.gradle file which will result in build error at next line. 1.


compile( com.googlecode.json-simple:json-simple:1.1

compile( org.springframework.boot:spring-boot-starter-parent:$ {springBootVersion})

compile("com.googlecode.json-simple:json-simple:1.1"
compile("org.springframework.boot:spring-boot-starter-parent:${springBootVersion}")

生成结果:



  • 其中:
    构建文件'C:\Users\singha \文档\GitHub\coalition-services\build.gradle'
    行:52

  • Where: Build file 'C:\Users\singha\Documents\GitHub\coalition-services\build.gradle' line: 52


  • 出了什么问题:
    无法编译生成文件'C:\Users\singha\Documents\GitHub\coalition-services\build.gradle'。

  • What went wrong: Could not compile build file 'C:\Users\singha\Documents\GitHub\coalition-services\build.gradle'.

启动失败:
构建文件'C:\Users\singha\Documents\GitHub\coalition-services\build.gradle':
52:意外令牌:编译@第52行,第4列。
compile( org.springframework.boot:spring-boot-starter-parent:$ {springBootVersion})

startup failed: build file 'C:\Users\singha\Documents\GitHub\coalition-services\build.gradle': 52: unexpected token: compile @ line 52, column 4. compile("org.springframework.boot:spring-boot-starter-parent:${springBootVersion}")





  1. 试图将相同的未解决的依赖关系放在构建文件的不同位置




compile( com.googlecode.json-simple:json-simple:1.1编译
文件('libs / google-http-client-1.18.0-rc.jar')

compile("com.googlecode.json-simple:json-simple:1.1" compile files('libs/google-http-client-1.18.0-rc.jar')

结果:



  • 出了什么问题:无法编译构建文件'C:\Users\singha\Documents\GitHub\coalition-services\build.gradle'。

  • What went wrong: Could not compile build file 'C:\Users\singha\Documents\GitHub\coalition-services\build.gradle'.

启动失败:构建文件'C:\Users\singha\Documents\GitHub\coalition-services\build.gradle':
68:意外令牌:在第68行第2列进行编译。
编译文件('libs / google-http-client-1.18.0-rc.jar')

startup failed: build file 'C:\Users\singha\Documents\GitHub\coalition-services\build.gradle': 68: unexpected token: compile @ line 68, column 2. compile files('libs/google-http-client-1.18.0-rc.jar')


解决方案:只需删除出现错误的上一行可能是造成问题的原因。对于您的情况,请尝试删除给定的161行或上一行依赖项。

Solution: Just delete the previous line where the given error is coming as that could be causing the issue. In your case, try deleting the 161 line or previous line of dependency given.

请让我知道它是否解决了问题。

Please let me know if it resolved the problem.

这篇关于Gradle获取意外令牌,编译文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆