Groovy repository code pasted into a build.gradle.kts file
Unexpected 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.
Fix it fast
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.kts2Match what you see, then jump to its fix
- 1
The 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
The syntax is right but the library still cannot be foundThe repository is in the wrong blockFix - 3
The same error on lines such as implementation 'group:name:1.0'Other Groovy habits that also fail in KotlinFix
- 1
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.kts2Fix
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 helpConfirmed by docs.jitpack.io
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.kts2Fix
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
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.kts2Fix
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 helpConfirmed by docs.gradle.org
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:
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- Nuclear Home VideoA video-streaming Android app built from scratch, engineered for smooth playback.
- Dispatch ProA real-time logistics platform: Flutter apps, Spring Boot services and a Kafka event pipeline on AWS.
Related fixes
Mobile apps
Android Studio cannot resolve a com.github.* library that comes from JitPack or JCenter
Could not find com.github.User:Repo:Tag
Gradle only searches the repositories you list.
3 causes, each with a fixMobile apps
Android build fails because a product flavor has no flavor dimension
The flavor 'flavor_name' is not assigned to a flavor dimension.
Android Gradle plugin refuses to build when a product flavor is not assigned to a flavor dimension.
2 causes, each with a fixMobile apps
AGP 9 marks the android block as deprecated or fails on BaseExtension
java.lang.ClassCastException: class com.android.build.gradle.internal.dsl.ApplicationExtensionImpl$AgpDecorated_Decorated cannot be cast to class com.android.build.gradle.BaseExtension
AGP 9.0 uses only the new public DSL interfaces.
3 causes, each with a fixMobile apps
Android build fails because two libraries ship the same META-INF file
More than one file was found with OS independent path
Two dependencies put a file at the same path inside the APK and the plugin will not guess which one wins.
3 causes, each with a fixMobile apps
The editor cannot find R, so every R.string and R.id turns red
Unresolved reference: R
R is a class that the build generates from your res folder, in the package named by the module's namespace.
4 causes, each with a fixMobile apps
Android Studio says it could not identify the launch activity when you press Run
Run > Edit Configurations > Launch Options is set to Nothing or to a class that no longer exists
Android Studio launches the activity marked with a MAIN action and a LAUNCHER category in the merged manifest.
3 causes, each with a fix