I have problem with updating Kotlin version in existing project.

当前成绩:

com.android.tools.build:gradle:7.0.1

现任Kotlin :

org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.30

当我将Kotlin版本更改为

org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.20

我收到错误消息:

> Unable to find method ''java.io.File
> org.jetbrains.kotlin.gradle.tasks.KotlinCompile.getDestinationDir()''
> 'java.io.File
> org.jetbrains.kotlin.gradle.tasks.KotlinCompile.getDestinationDir()'
> 
> Gradle's dependency cache may be corrupt (this sometimes occurs after
> a network connection timeout.)
> 
> Re-download dependencies and sync project (requires network) The state
> of a Gradle build process (daemon) may be corrupt. Stopping all Gradle
> daemons may solve this problem.
> 
> Stop Gradle build processes (requires restart) Your project may be
> using a third-party plugin which is not compatible with the other
> plugins in the project or the version of Gradle requested by the
> project.
> 
> In the case of corrupt Gradle processes, you can also try closing the
> IDE and then killing all Java processes.

我在试着:

  • 重新同步Gradle
  • 重新下载依赖项
  • 清除缓存

Update 1.

已更新所有依赖项,但仍无法更改Kotlin版本.

How I can solve this problem ?

推荐答案

好的.我会写一些对我有帮助的东西,也许将来也会对某个人有帮助.

在这种情况下,gradle个库中kotlin个兼容版本存在问题.

使用--stacktrace运行构建

./gradlew assembleDebug --stacktrace

如果没有--stacktrace.,错误是不可见的

Caused by: java.lang.NoSuchMethodError: org/jetbrains/kotlin/gradle/tasks/KotlinCompile.getDestinationDir()Ljava/io/File; (loaded from file:/C:/Users/user/.gradle/caches/jars-9/d2eb7478e0f9b31ee9b2ffc619a8e9b4/kotlin-gradle-plugin-1
.7.20-gradle71.jar by VisitableURLClassLoader(ClassLoaderScopeIdentifier.Id{coreAndPlugins:settings[:]:buildSrc[:]:root-project[:](export)})) called from class de.mannodermaus.gradle.plugins.junit5.providers.KotlinDirectoryProvider 
(loaded from file:/C:/Users/user/.gradle/caches/jars-9/4ae406a23e7d8b323fd6eec4907799d4/android-junit5-1.7.0.0.jar by VisitableURLClassLoader(ClassLoaderScopeIdentifier.Id{coreAndPlugins:settings[:]:buildSrc[:]:root-project[:](export)})).

在更新这个库之后,我能够升级到Kotlin版本.

Android相关问答推荐

房间数据库迁移未正确处理:原因:java.lang. IllegalState异常:

安卓Gradle看不到dagger 柄

这款应用与最新版本的Android不兼容.在Android 14中

在一列中垂直对齐两个框

如何在Android中打印到命令行

如何修复Google Play市场中有关已删除广告库的错误消息?

我无法在底部导航栏中正确导航-Android底部导航视图

触发PurchasesUpdatedListener回调时,billingClient.launchBillingFlow之前设置的成员变量丢失

找不到com.android.tools.build:gradle:8.0

更改活动(上下文)对接收到的uri的访问权限的影响?

从不可组合回调打开可组合屏幕

如何迭代 SqlDelight Select 结果而不将所有内容加载到内存中?

如何在jetpack compose中使可组合的屏幕zoom 到不同的手机(屏幕)尺寸?

错误:无法安装应用程序:INSTALL_PARSE_FAILED_MANIFEST_MALFORMED (React-Native-Android-Studio)

当 Firebase Firestore 发生变化时,Kotlin ViewModel 不会更新

如何像 XML 一样在 Compose Android Studio 中折叠/展开小部件代码区域/区域

JCenter 是否永久关闭(10 月 31 日)?

更改 Android SDK 版本 33 后建议在 xml 布局文件中不起作用

如何使用 Kotlin 在 Android Wear(Galaxy watch 4)中继续在后台运行应用程序

如果我在网络请求中指定它们是否与判断网络功能相关