gpt4 book ai didi

android - 多模块 Kotlin 项目无法解决 : org. jetbrains.kotlin :kotlin-stdlib-jre8:1. 2.71 错误

转载 作者:行者123 更新时间:2023-11-29 23:32:06 28 4
gpt4 key购买 nike

我使用的是 Android Studio 版本 3.2,并且我有一个多模块 Gradle 构建。

我有一个名为 dependencies.gradle 的文件,如下所示:

   ext{
//Android
androidBuildToolsVersion = "26.0.0"
androidMinSdkVersion = 21
androidTargetSdkVersion = 26
androidCompileSdkVersion = 26
kotlinVersion = '1.2.71'

//Libraries
supportLibraryVersion = '26.1.0'
rxJavaVersion = '2.2.0'
javaxAnnotationVersion = '1.0'
javaxInjectVersion = '1'
rxKotlinVersion = '2.2.0'
androidAnnotationsVersion='21.0.3'
daggerVersion = '2.14.1'


//Testing
jUnitVersion = '4.12'
assertJVersion = '3.11.0'
mockitoKotlinVersion ='2.0.0-RC2'
robolectricVersion = '3.4.2'

domainDependencies = [
javaxAnnotation: "javax.annotation:jsr250-api:${javaxAnnotationVersion}",
javaxInject: "javax.inject:javax.inject:${javaxInjectVersion}",
rxJava: "io.reactivex.rxjava2:rxkotlin:${rxJavaVersion}"
]

domainTestDependencies = [
junit: "junit:junit:${jUnitVersion}",
mockito: "com.nhaarman.mockitokotlin2:mockito-kotlin:${mockitoKotlinVersion}",
assertj: "org.assertj:assertj-core:${assertJVersion}"
]

dataDependencies = [
rxKotlin: "io.reactivex.rxjava2:rxkotlin:${rxKotlinVersion}",
javaxAnnotation: "javax.annotation:jsr250-api:${javaxAnnotationVersion}",
kotlin: "org.jetbrains.kotlin:kotlin-stdlib-jre8:${kotlinVersion}",
javaxInject: "javax.inject:javax.inject:${javaxInjectVersion}",
]

dataTestDependencies = [
junit: "junit:junit:${jUnitVersion}",
kotlinJUnit: "org.jetbrains.kotlin:kotlin-test-junit:${kotlinVersion}",
mockito: "com.nhaarman.mockitokotlin2:mockito-kotlin:${mockitoKotlinVersion}",
assertj: "org.assertj:assertj-core:${assertJVersion}",
robolectric: "org.robolectic:robolectric:${robolectricVersion}"
]

}

我想在我的应用程序中为数据模块编写测试,我的数据模块的 build.gradle 如下。

apply plugin: 'kotlin'

dependencies {
compile project(':Domain')

def dataDependencies = rootProject.ext.dataDependencies
def dataTestDependencies = rootProject.ext.dataTestDependencies



implementation dataDependencies.javaxAnnotation
implementation dataDependencies.javaxInject
implementation dataDependencies.rxKotlin
implementation dataDependencies.kotlin

testImplementation dataTestDependencies.junit
testImplementation dataTestDependencies.mockito
testImplementation dataTestDependencies.assertj
testImplementation dataTestDependencies.kotlinJUnit


}

sourceCompatibility = "1.8"
targetCompatibility = "1.8"

但是当我同步我的 Gradle 文件时,我从 Android Studio 收到以下错误。

  • 解析失败:org.jetbrains.kotlin:kotlin-stdlib-jre8:1.2.71
  • 解析失败:org.jetbrains.kotlin:kotlin-test-junit:1.2.71

非常感谢对此提供一些帮助,因为我确定我有正确的包名称。提前致谢

最佳答案

将其添加到app文件夹中的build.gradle实现组:'org.jetbrains.kotlin',名称:'kotlin-stdlib',版本:'1.2.0'这解决了我的问题..

在你的情况下更改版本:实现组:'org.jetbrains.kotlin',名称:'kotlin-stdlib',版本:'1.2.71'

关于android - 多模块 Kotlin 项目无法解决 : org. jetbrains.kotlin :kotlin-stdlib-jre8:1. 2.71 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52543738/

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