Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unexpected tokens (use ';' to separate expressions on the same line) in build.gradle.kts

that is a screen shot of the error message

I can't add jitpack to build.gradle.kts it shows an error " Unexpected tokens (use ';' to separate expressions on the same line) "

allprojects {
repositories {
    google()
    jcenter()
    maven { url "https://jitpack.io" }
}

}

like image 461
ahmed mostafa Avatar asked Aug 09 '20 23:08

ahmed mostafa


People also ask

What are the different types of tasks in Gradle?

This type of task is good for implementing one-off tasks in your build script. The other type of task is the enhanced task, where the behaviour is built into the task, and the task provides some properties which you can use to configure the behaviour. We have seen these in Authoring Tasks. Most Gradle plugins use enhanced tasks.

What happens when a task is executed non-incrementally in Gradle?

If for some reason the task is executed non-incrementally, for example by running with --rerun-tasks, all files are reported as ADDED, irrespective of the previous state. In this case, Gradle automatically removes the previous outputs, so the incremental task only needs to process the given files.

How to enable JUnit test run in Gradle using @tag annotation?

Gradle uses includeTags and excludeTags to filter tags. To enable JUnit test run in Gradle, it provides useJUnitPlatform () . Here on this page we will create some test classes using @Tag annotation and then we will create a Gradle file and filter tests.

Should I use Kotlin or Groovy for Gradle?

Groovy, Java or Kotlin are all good choices as the language to use to implement a task class, as the Gradle API has been designed to work well with these languages. In general, a task implemented using Java or Kotlin, which are statically typed, will perform better than the same task implemented using Groovy.


1 Answers

Support for Kotlin Gradle scripts is fairly new in Android — for example, Android Studio only added support for it in version 4.0. Most of the instructions that you will see online will be for Groovy Gradle scripts, and you will need to make some minor conversions.

In this case, this Groovy:

maven { url "https://jitpack.io" }

...turns into this Kotlin:

maven { url = uri("https://jitpack.io") }
like image 187
CommonsWare Avatar answered Oct 13 '22 15:10

CommonsWare