Gradle失败:无法解决:删除kotlintest之后的io [英] Gradle fails: Failed to resolve: io after removing kotlintest
问题描述
我创建了一个新的Android项目,并在Intrument测试和Unit测试中设置了模拟:
I've created a new Android Project and set up mockk in Intrument test and Unit test:
androidTestImplementation "io.mockk:mockk:{1.9.3}"
testImplementation "io.mockk:mockk:{1.9.3}"
分级同步良好.
如果我添加kotlintest并再次同步,则一切正常:
If I add kotlintest and sync again everything works:
android {
compileSdkVersion 29
buildToolsVersion "29.0.1"
defaultConfig {
applicationId "com.example.testing"
minSdkVersion 15
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
testOptions {
unitTests.all {
useJUnitPlatform()
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.core:core-ktx:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
//Mocking framework
androidTestImplementation "io.mockk:mockk:{1.9.3}"
testImplementation "io.mockk:mockk:{1.9.3}"
//Testing framework
androidTestImplementation 'io.kotlintest:kotlintest-runner-junit5:3.3.0'
testImplementation 'io.kotlintest:kotlintest-runner-junit5:3.3.0'
}
但是,如果我删除kotlintest,并且像添加kotlintest之前一样保留gradle文件,则会收到错误消息:
But if I remove kotlintest and I leave the gradle file as before adding kotlintest, then I get the error:
Failed to resolve: io
这是我最后的Gradle文件:
This is my final Gradle file:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 29
buildToolsVersion "29.0.1"
defaultConfig {
applicationId "com.example.testing"
minSdkVersion 15
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.core:core-ktx:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
//Mocking framework
androidTestImplementation "io.mockk:mockk:{1.9.3}"
testImplementation "io.mockk:mockk:{1.9.3}"
}
我尝试清理项目并清理gradle.
I tried cleaning the project and cleaning gradle.
知道为什么会这样吗?
谢谢
推荐答案
您的mockk
库版本包含{}
.
我们通常在处理变量或ext
块中的版本时使用它们:
We usually use them when working with a version that is in a variable or in the ext
block:
testImplementation "io.mockk:mockk:${Version.mockkVersion}"
在您的情况下,使用固定值时,请勿使用花括号:
In your case, when working with a fixed value, you shouldn't use the braces:
testImplementation "io.mockk:mockk:1.9.3"
它应该与此更改保持同步
It should sync fine with this change
这篇关于Gradle失败:无法解决:删除kotlintest之后的io的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!