kotlin错误:找不到org.jetbrainskotlin:kotlin-stdlib-jre7:1.0.7

p3rjfoxz  于 2021-07-07  发布在  Java
关注(0)|答案(15)|浏览(849)

我将kotlin插件安装到我的应用程序(v。v1.1.1-release-studio2.2-1),然后选择“在项目中配置kotlin”,我选择了编译器和运行时版本1.0.7。kotlin更新了我的gradle文件。现在,当我试图建立在我得到:
错误:配置项目“:app”时出现问题。无法解析配置“:app:\u debugapkcopy”的所有依赖项。找不到org.jetbrains。kotlin:kotlin-stdlib-jre7:1.0.7. 要求人:
myap公司plication:app:未指定
我不知道我错过了什么。

ffvjumwh

ffvjumwh1#

buildscript {
  **ext.kotlin_version = '1.1.1'**//Add this line
    repositories {
      **jcenter()**               //Add this line
        google()
    }
    dependencies {
//        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath 'com.android.tools.build:gradle:3.1.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
      **jcenter()**               //Add this line
        google()
        maven { url "https://jitpack.io" }
    }
}
92dk7w1h

92dk7w1h2#

如果(可传递的)依赖项仍然使用 jre kotlin库的变种,可以强制使用 jdk 借助解决策略的变体:

configurations.all {
    resolutionStrategy {
        eachDependency { DependencyResolveDetails details ->
            details.requested.with {
                if (group == "org.jetbrains.kotlin" && name.startsWith("kotlin-stdlib-jre")) {
                    details.useTarget(group: group, name: name.replace("jre", "jdk"), version: version)
                    details.because("Force use of 'kotlin-stdlib-jdk' in favor of deprecated 'kotlin-stdlib-jre'.")
                }
            }
        }
    }
}
bt1cpqcv

bt1cpqcv3#

请在下面的路径中检查您的kotlin的当前版本,
c:\program files\android\android studio\gradle\m2repository\org\jetbrains\kotlin\kotlin标准库\1.0.5
更改为该版本 (1.0.5) 在项目级渐变文件中。
您可以在上面的路径中看到没有提到任何java- jre version ,所以在应用程序级gradle文件中删除,如下所示,

compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
uqzxnwby

uqzxnwby4#

在修复build.gradle版本之后,它开始在4.0.0到3.5.0之间工作

nuypyhwy

nuypyhwy5#

我已经解决了这个问题,使用取消选择脱机工作选项中 Settings

rsaldnfx

rsaldnfx6#

一个新的解决方案如果你使用android studio 3.2,我通过在项目的build.gradle中添加mavencentral()来解决这个问题:

buildscript {
    ext.kotlin_version = '1.3.0'
    repositories {
        mavenCentral()
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

    }
}

allprojects {
    repositories {
        mavenCentral()
        google()
        jcenter()
    }
}

你应该把这一行作为这一顺序加上,这一行的贷方是这个答案

bxgwgixi

bxgwgixi7#

分裂 kotlin-stdlib 进入 kotlin-stdlib-jre7 以及 kotlin-stdlib-jre8 只是在kotlin1.1中引入的,这就是为什么依赖关系不能被解析,包版本根本不存在。
对项目文件的更新似乎在某个时候失败,并将kotlin版本设置为1.0.7。如果这是一个新项目,并且没有任何东西阻碍您使用1.1.1,我会切换到它。做完这件事你的问题就应该解决了。

kg7wmglp

kg7wmglp8#

代替

implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"

具有

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

由于jre的版本是绝对的,所以只需替换并同步项目
官方文件在此感谢链接@romanarmy
快乐编码:)

monwx1rj

monwx1rj9#

如果您使用的是android studio 3.2及更高版本,那么将通过在项目的build.gradle中添加google()&jcenter()来解决这个问题:

repositories {
        google()
        jcenter()
}
xhv8bpkk

xhv8bpkk10#

简单步骤:
单击“文件”>“项目结构”
单击dependencies>find,然后单击org.jetbrains。kotlin:kotlin-stdlib-jdk7:1.3.21(或任何当前版本)
在“详细信息”>“更新”部分下,单击[更新变量][更新依赖项]
单击“确定”
致以最诚挚的问候

6qftjkof

6qftjkof11#

从kotlin1.1.2开始,依赖项与组 org.jetbrains.kotlin 默认情况下,使用从应用插件获取的版本进行解析。您可以使用完全依赖关系表示法手动提供版本,如:

compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

如果您的目标是jdk7或jdk8,那么可以使用kotlin标准库的扩展版本,其中包含新jdk版本中添加的api的附加扩展函数。请使用以下依赖项之一,而不是kotlin stdlib:

compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7"
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
7cwmlq89

7cwmlq8912#

在“build.gradle”文件中,更改该行的当前kotlin版本,然后按synk:

ext.kotlin_version = '1.1.1'

///看起来像:
//顶级生成文件,您可以在其中添加所有子项目/模块通用的配置选项。

buildscript {
    ext.kotlin_version = '1.1.1'
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.0'
        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
    }
}
btqmn9zl

btqmn9zl13#

这就是我的工作:使用gradle4.8.1

buildscript {
    ext.kotlin_version = '1.1.1' 
repositories {
    jcenter()
    google()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.1.0'}
}
allprojects {
    repositories {
        mavenLocal()
        jcenter()
        google()
        maven {
            url "$rootDir/../node_modules/react-native/android"
        }
    maven {
            url 'https://dl.bintray.com/kotlin/kotlin-dev/'
    }
  }
}
ccrfmcuu

ccrfmcuu14#

在项目级别 build.gradle 仅使用此版本
ext.kotlin\u版本='1.3.31'
删除其他版本
这只适用于最新版本的androidstudio3.4
更新:尝试使用最新版本的kotlin和最新的androidstudio来避免错误。

bvuwiixz

bvuwiixz15#

build.gradle(项目)

buildScript {
    ...
    dependencies {
        ...
        classpath 'com.android.tools.build:gradle:4.0.0-rc01'
    }
}

gradle/wrapper/gradle-wrapper.properties属性

...
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip

有些库需要更新的gradle。例如:

androidTestImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines"

德国劳埃德船级社

相关问题