I tried cloning and building this project, https://github.com/mitrejcevski/ui-testing, but upon opening it in Android Studio, I get the following build error:
ERROR: The Android Gradle plugin supports only Kotlin Gradle plugin version 1.3.0 and higher.
The following dependencies do not satisfy the required version:
root project 'ui-testing' -> org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.21
Affected Modules: app
However, when I click the 'app' hyperlink I am led to the module-level build.gradle
file, which reads
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 27
defaultConfig {
applicationId "nl.jovmit"
minSdkVersion 19
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
mock {
flavorDimensions "default"
}
prod {
flavorDimensions "default"
}
}
android.variantFilter { variant ->
if (variant.buildType.name == 'release' && variant.getFlavors().get(0).name == 'mock') {
variant.setIgnore(true)
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation "com.android.support:appcompat-v7:$support_version"
implementation "com.android.support:design:$support_version"
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.21'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
testImplementation 'junit:junit:4.12'
}
Unlike the accepted answer of ERROR: The Android Gradle plugin supports only Kotlin Gradle plugin version 1.3.0 and higher, I don't see any ext.kotlin_version
anywhere in the Gradle file.
I do see this warning, though, that kotlin-stdlib-jre7
is deprecated:
However, I tried changing this but still get the same error. I've also tried adding the line
implementation 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.21'
to dependencies
(as seen in the screenshot above), but that also didn't prevent the error.
Any idea how to fix this? I suspect that the outdated Kotlin version is a 'sub-dependency' of one of the dependencies here, but haven't been able to figure out which one.
Change
org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version
instead of
org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version