gpt4 book ai didi

android - Gradle失败:无法解决:删除kotlintest之后的io

转载 作者:行者123 更新时间:2023-12-03 05:06:30 24 4
gpt4 key购买 nike

我创建了一个新的Android项目,并在Intrument测试和Unit测试中设置了ockk:

    androidTestImplementation "io.mockk:mockk:{1.9.3}"
testImplementation "io.mockk:mockk:{1.9.3}"

Gradle 同步良好。

如果我添加kotlintest并再次同步,则一切正常:
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文件,则会收到错误消息:
Failed to resolve: io

这是我最后的Gradle文件:
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。

知道为什么会这样吗?

谢谢

最佳答案

您的mockk库版本包含{}

我们通常在处理变量或ext块中的版本时使用它们:

testImplementation "io.mockk:mockk:${Version.mockkVersion}"

对于您的情况,使用固定值时,不应使用花括号:
testImplementation "io.mockk:mockk:1.9.3"

它应该与此更改保持同步

关于android - Gradle失败:无法解决:删除kotlintest之后的io,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57325617/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com