Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

Groovy repository code pasted into a build.gradle.kts file

ErrorUnexpected tokens (use ';' to separate expressions on the same line)

Short answer

Build files ending in .kts are Kotlin, not Groovy. The JitPack line from many READMEs, maven { url 'https://jitpack.io' }, is Groovy: single quotes and no equals sign do not parse in Kotlin. Write maven { url = uri("https://jitpack.io") } and put it in the settings repositories block.

  • Applies to Gradle 8.x, Android Gradle plugin 8.x, Kotlin DSL
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Check the file extension of the build file the error points at. .kts means Kotlin DSL, and Groovy snippets must be rewritten.

    ls *.gradle *.gradle.kts
  2. 2Match what you see, then jump to its fix

    1. 1The error is on the line with url 'https://jitpack.io' in a .gradle.kts fileA Groovy snippet was pasted into a Kotlin DSL fileFix
    2. 2The syntax is right but the library still cannot be foundThe repository is in the wrong blockFix
    3. 3The same error on lines such as implementation 'group:name:1.0'Other Groovy habits that also fail in KotlinFix

What does the error look like?

  • Unexpected tokens (use ';' to separate expressions on the same line)

Cause 1 of 3

A Groovy snippet was pasted into a Kotlin DSL file

1Check

Kotlin writes strings in double quotes. Single quotes mean a one-character Char, so a long URL in single quotes is not valid Kotlin.

grep -n "jitpack" settings.gradle.kts build.gradle.kts app/build.gradle.kts

2Fix

Use the Kotlin form: an assignment with the equals sign, the uri() function and double quotes.

maven { url = uri("https://jitpack.io") }

3Verify

Sync the project; the parse error is gone.

./gradlew help

Confirmed by docs.jitpack.io

Did this fix it?

Cause 2 of 3

The repository is in the wrong block

1Check

JitPack's Android guide puts the repository in the repositories block of dependencyResolutionManagement in the settings file, next to google() and mavenCentral(), and says not to add it under buildscript.

grep -n -B3 -A6 "dependencyResolutionManagement" settings.gradle.kts

2Fix

Move the line into the settings file repositories block.

// settings.gradle.kts
dependencyResolutionManagement {
    repositories {
        google()
        mavenCentral()
        maven { url = uri("https://jitpack.io") }
    }
}

3Verify

Add the dependency in the module file (double quotes, parentheses) and sync.

// app/build.gradle.kts
dependencies {
    implementation("com.github.jitpack:android-example:1.0.1")
}

Confirmed by docs.jitpack.io

Did this fix it?

Cause 3 of 3

Other Groovy habits that also fail in Kotlin

1Check

Kotlin calls need parentheses and use = for property assignment. The Gradle Kotlin DSL guide shows calls like id("java") and assignments like sourceCompatibility = JavaVersion.VERSION_11.

grep -n -E "implementation '|api '|classpath '" *.gradle.kts */*.gradle.kts

2Fix

Rewrite each dependency line with parentheses and double quotes.

dependencies {
    implementation("com.example:library:1.0.0")
}

3Verify

Sync again until no parse error remains.

./gradlew help

Confirmed by docs.gradle.org

Did this fix it?

How do I stop it coming back?

  • When a README shows Groovy, convert it before pasting: double quotes, parentheses, url = uri(...).
  • Keep repositories in settings.gradle.kts, not scattered across module files.
  • Use a library README's Kotlin tab when one exists.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.