gpt4 book ai didi

android - Android Studio找不到Kotlin依赖项

转载 作者:行者123 更新时间:2023-12-02 13:31:42 29 4
gpt4 key购买 nike

我试图为我的Android Studio项目升级一些依赖项,现在每当我尝试构建项目时,我都会遇到以下错误消息:

Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':app:debugAnnotationProcessorClasspath'.
> Could not find org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.60-eap-25.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.3.60-eap-25/kotlin-stdlib-jdk8-1.3.60-eap-25.pom
- https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.3.60-eap-25/kotlin-stdlib-jdk8-1.3.60-eap-25.pom
Required by:
project :app > androidx.databinding:databinding-compiler:4.0.0-alpha04
project :app > androidx.databinding:databinding-compiler:4.0.0-alpha04 > androidx.databinding:databinding-compiler-common:4.0.0-alpha04

这是我的项目gradle文件:
buildscript {
// Define versions in a single place
ext {
// Sdk and tools
compileSdkVersion = 28
minSdkVersion = 21
targetSdkVersion = 28

// App dependencies
appCompatVersion = '1.1.0'
fragmentVersion = '1.2.3'
gradleVersion = '4.0.0-alpha04'
kotlinVersion = '1.3.60-eap-25'
ktlintVersion = '0.33.0'
ktxVersion = '1.2.0'
mapVersion = '17.0.0'
}

repositories {
google()
jcenter()
mavenCentral()
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap'}
}

dependencies {
classpath "com.android.tools.build:gradle:${gradleVersion}"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$navigationVersion"
}
}

plugins {
id "com.diffplug.gradle.spotless" version "3.24.0"
}

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

spotless {
kotlin {
target "**/*.kt"
ktlint(ktlintVersion).userData(['max_line_length' : '100'])
}
}

以及相关的应用gradle依赖项:
kaptTest "androidx.databinding:databinding-compiler:$gradleVersion"
implementation "androidx.core:core-ktx:$rootProject.ktxVersion"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$rootProject.kotlinVersion"

我曾经尝试过使用其他Kotlin版本,但是这样做时甚至无法同步gradle文件。

最佳答案

试试这个:

build.gradle(:app)

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.example.mytestapplication"
minSdkVersion 21
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.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.1.0'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'androidx.core:core:1.3.0-alpha02'
implementation 'androidx.mediarouter:mediarouter:1.1.0'
}

build.gradle(:projectname)
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.3.61'
repositories {
google()
jcenter()

}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.1'
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
}
}

allprojects {
repositories {
google()
jcenter()

}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

关于android - Android Studio找不到Kotlin依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61025926/

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