Reputation: 715
I downloaded a project from github and then tried to build it.
But, once Gradle ran, the event log of Android Studio (2.3.3) showed me this:
Gradle sync failed: Cause: com/android/build/gradle/BaseExtension
Consult IDE log for more details (Help | Show Log)
And also
Error:(18, 0) com/android/build/gradle/BaseExtension
<a href="openFile:C:\Users\Gustavo\AndroidStudioProjects\simpletask-android\app\build.gradle">Open File</a>
It seems like Gradle couldn't find Kotlin in the right spot but I don't know how to change this.
Kotlin is installed and updated (to version 1.1.3).
It is also configured as a dependency of the "app" module in the project.
But, as the last image shows, the version of the external library that the project sees is 1.0.6 and not 1.1.3.
Is that the problem? How can I change this external library?
Upvotes: 6
Views: 6297
Reputation: 3
I encountered this error when I wanted to add Hilt dependencies.
Code below was part of my android project's root build.gradle file.
buildscript {
ext.kotlin_version = "1.7.10"
ext.hilt_version = "2.38.1"
repositories {
google()
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.google.dagger:hilt-android-gradle-plugin:$hilt_version"
}
}
for me,after i added classpath 'com.android.tools.build:gradle:7.1.3'
to the dependencies block, the problem was solved.
After adding,below code is the whole buildscript block
buildscript {
ext.kotlin_version = "1.7.10"
ext.hilt_version = "2.38.1"
repositories {
google()
mavenCentral()
}
dependencies {
//you should change the version to the one that suits your project
classpath 'com.android.tools.build:gradle:7.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.google.dagger:hilt-android-gradle-plugin:$hilt_version"
}
}
Upvotes: 0
Reputation: 375
Similar to @mbonnin, but in the opposite direction, I had to move the build tools dependency from app/build.gradle
to the root build.gradle
.
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.android.tools.build:gradle:3.0.0-beta6'
}
Upvotes: 2
Reputation: 7022
In my case, I had to put everything into app/build.gradle
(and not the root build.gradle):
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
If I put the block above in the root build.gradle
, I get the same error as you...
Upvotes: 7
Reputation: 1385
Try this in build.gradle(app level)
first
apply plugin: 'kotlin-android'
Second under dependencies
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
EDIT
Do this is project level gradle
buildscript {
ext.kotlin_version = '1.1.3'
ext.android_plugin_version = '2.2.0-alpha4'
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
and at app level gradle
android {
dataBinding {
enabled = true
}
}
Upvotes: 0