0

I'm having an issue building an app for Android that runs fine on iOS. The error reads:

* What went wrong: A problem occurred evaluating project ':app'.

Could not find method classpath() for arguments [org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

Here are my dependencies in the build.gradle in the app module:

dependencies {
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'}

Thank you for your help!

2 Answers 2

2

To include a var inside a string, you need double quotes:

classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

Just as you can see here: https://kotlinlang.org/docs/reference/using-gradle.html

Sign up to request clarification or add additional context in comments.

Comments

-1

The classpath configuration is a special one defined at the buildscript level which allows to tweak the classpath of the build script.

So in order to add the gradle-kotlin-plugin, you need to do the following:

buildscript {
    dependencies {
        classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version'
    }
}

See the relevant documentation for more details.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.