我尝试过克隆和构建这个项目,https://github.com/mitrejcevski/ui-testing,但是在Android中打开它时,我会得到以下构建错误:
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但是,当我单击“app”超链接时,我会被引导到模块级的build.gradle文件,该文件读取
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'
}与ERROR: The Android Gradle plugin supports only Kotlin Gradle plugin version 1.3.0 and higher的公认答案不同,我在Gradle文件中没有看到任何ext.kotlin_version。
不过,我确实看到了这样的警告:kotlin-stdlib-jre7是不可取的:

然而,我试图改变这个,但仍然得到相同的错误。我也试着增加了
implementation 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.21'到dependencies (如上面的屏幕截图所示),但这也不能防止错误。
知道怎么解决这个问题吗?我怀疑过时的Kotlin版本是其中一个依赖项的“子依赖项”,但还无法确定是哪个依赖项。
发布于 2019-02-25 02:14:11
变化
org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version
而不是
org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version发布于 2019-02-25 02:30:56
定义您的ext.kotlin_version
您的项目级别build.gradle应该如下所示。
buildscript {
ext.kotlin_version = '1.2.51'
ext.android_plugin_version = '3.2.1'
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:$android_plugin_version"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}发布于 2019-07-18 07:39:53
buildscript {
ext.kotlin_version = '1.3.10' //put the version you just updated to
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}https://stackoverflow.com/questions/54858510
复制相似问题