相关疑难解决方法(0)

将 Android kotlin 版本升级到 1.5.0 在构建时抛出错误消息

使用 kotlin 版本“1.4.32”运行我的 Android 项目运行和构建。尝试升级到 kotlin '1.5.0' 并且我的构建抛出:

Execution failed for task ':app:kaptDefaultsDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptWithoutKotlincTask$KaptExecutionWorkAction
   > java.lang.reflect.InvocationTargetException (no error message)
Run Code Online (Sandbox Code Playgroud)

我什至不知道从哪里开始寻找。还有其他人在升级到 kotlin 1.5.0 时遇到问题吗?

android kotlin

42
推荐指数
7
解决办法
8682
查看次数

在Kotlin中调用超类构造函数,Super不是表达式

我有两个班Entity,并Account

abstract class Entity(
    var id: String? = null,
    var created: Date? = Date()) {

    constructor(entity: Entity?) : this() {
        fromEntity(entity)
    }

    fun fromEntity(entity: Entity?): Entity {
        id = entity?.id
        created = entity?.created
        return this;
    }
}
Run Code Online (Sandbox Code Playgroud)

data class Account( 
    var name: String? = null,
    var accountFlags: Int? = null
) : Entity() {

    constructor(entity: Entity) : this() {
        super(entity)
    }
}
Run Code Online (Sandbox Code Playgroud)

这给了我错误

超级不是表达式,它只能用在点'左'的左侧.

为什么我不能这样做?

以下将传递编译错误,但我不确定它是否正确.

 constructor(entity: Entity) : this() {
    super.fromEntity(entity)
}
Run Code Online (Sandbox Code Playgroud)

kotlin

29
推荐指数
2
解决办法
3万
查看次数

标签 统计

kotlin ×2

android ×1