I'm hoping someone has come across the issues that i'm seeing while building my java/Kotlin project. The project is interop with java and kotlin, with the following versions:

  • Jdk 1.7
  • Kotlin 0.9.66
  • Gradle(包装器)2.0

在我做了一些更改之前,Kotlin已经编译得很好了,即将一些java类转换为等效的Kotlin版本.

以下是我看到的错误:

  c:\projects\myproject>gradlew  :java:workspace:models:compileKotlin  --stacktrace     :java:workspace:models:compileKotlin

w: Annotations path entry points to a non-existent location:
C:\projects\myproject\java\workspace\models\annotations

e: C:\projects\CustomerProfileEmail.kt: (15, 32): Unresolved reference: toLowerCase
e: C:\projects\CustomerProfilePhone.kt: (34, 22): Unresolved reference: equalsIgnoreCase
e: C:\projects\Account.kt: (17, 21): Unresolved reference: javaClass
e: C:\projects\Account.kt: (18, 21): Unresolved reference: javaClass
e: C:\projects\Account.kt: (31, 15): Unresolved reference: indexOf
e: C:\projects\Account.kt: (35, 15): Expression 'length' of type 'kotlin.Int' cannot be invoked as a function. The function invoke() is not found
e: C:\projects\Account.kt: (39, 15): Expression 'length' of type 'kotlin.Int' cannot be invoked as a function. The function invoke() is not found
e: C:\projects\Balance.kt: (10, 21): Unresolved reference: javaClass
e: C:\projects\Balances.kt: (12, 21): Unresolved reference: firstOrNull
e: C:\projects\Balances.kt: (12, 35): Cannot infer a type for this parameter. To specify it explicitly use the {(p : Type) -> ...} notation
e: C:\projects\Debit.kt: (7, 12):Unresolved reference: javaClass
e: C:\projects\ProgramR.kt: (12, 21): Unresolved reference: javaClass
e: C:\projects\ProgramR.kt: (13, 21): Unresolved reference: javaClass
e: C:\projects\Transaction.kt: (7, 12): Unresolved reference: javaClass
e: C:\projects\Transaction.kt: (7, 40): Unresolved reference: javaClass
e: C:\projects\Adjustment.kt: (13,21): Unresolved reference: javaClass
e: C:\projects\Reward.kt: (12, 24): Unresolved reference: javaClass
:java:workspace:models:compileKotlin FAILED

FAILURE: Build failed with an exception.

Here is an example of the source code:

import javax.xml.bind.annotation.*

XmlAccessorType(XmlAccessType.FIELD)
XmlType
XmlSeeAlso(javaClass<LoyaltyCredit>(), javaClass<Debit>())
public open class Transaction: TransactionParent(){
    public var account: Account? = null
    public var balances: Balances? = null
    public var rewards: Rewards? = null
}

Gradle脚本

repositories {
    mavenCentral()
}

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.connorgarvey.gradle:gradle-grails-wrapper:1.0'
        classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:0.9.66'
        classpath 'org.jetbrains.kotlin:kotlin-stdlib:0.9.66'
    }
}

apply from: 'build/includes.gradle'

我已经看到了这一点:https://devnet.jetbrains.net/message/5478050没有帮助.

任何帮助都将不胜感激!

推荐答案

请将您的 playbook 与关于Gradle的Kotlin reference进行比较.

Kotlin Stdlib dependency should be in another scope, not buildscript. Also Kotlin plugin should be applied using apply plugin.

Kotlin相关问答推荐

创建具有共同父类型的两种不同类型对象的列表的最有效方法是什么?

来自SnapshotFlow的单元测试StateFlow仅发出initialValue

如何在Jetpack Compose中从领域查询中读取数据?

无法访问类kotlin.coroutines.CoroutineContext';.判断模块类路径中是否存在丢失或冲突的依赖项

在调用父构造函数之前重写类属性

多模块Kotlin项目中的FreeFair

创建包含 3 个相同项目的列表/使用返回类型重复

为什么 Kotlin main 函数需要 @JVMStatic 注解?

如何在 kotlin @Parcelize 中使用 null

在 SplashActivity 中显示的 Firebase 应用内消息.如何在 MainActivity 中显示它?

下拉通知面板时是否可以暂停Android中的任何视频(媒体播放器)应用程序?

Kotlin 解构超过五个组件

无法创建类 ViewModel kotlin 的实例

取消信号上的kotlin流量采集

如何暂停kotlin coroutine直到收到通知

编译错误:-Xcoroutines has no effect: coroutines are enabled anyway in 1.3 and beyond

Kotlin数据类打包

在 kotlin 中,如何将主构造函数中的属性设置器设为私有?

尾随 lambda 语法(Kotlin)的目的是什么?

在 IntelliJ Idea 中未为 Kotlin @ConfigurationProperties 类生成 spring-configuration-metadata.json 文件