“未解决的参考:将其打包".更新到Kotlin 1.3.30之后 [英] "Unresolved reference: Parcelize" after updating to Kotlin 1.3.30

查看:290
本文介绍了“未解决的参考:将其打包".更新到Kotlin 1.3.30之后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很长时间以来一直在实验模式下将Kotlin 1.3.21与kotlin-android-extensions插件一起使用.今天,我通过修改版本就切换到Kotlin 1.3.30,现在无论在哪里使用@Parcelize注释,我都看到错误: Unresolved reference: Parcelize.

I was using Kotlin 1.3.21 for a long time together with kotlin-android-extensions plugin in experimental mode for a long time. Today I swtiched to Kotlin 1.3.30 just by bumping the version and now wherever I used @Parcelize annotation I see the error: Unresolved reference: Parcelize.

这是我启用android扩展的方法:

Here's how I enable android extensions:

apply plugin: 'kotlin-android-extensions'

androidExtensions {
    experimental = true
    features = ["parcelize"]
}

注意,我尝试时未明确声明必需的功能,但效果也不佳.

Notice, that I tried without explicitly declaring required features and it didn't work as well.

还要注意,我使用的是Grrovy Gradle DSL.

Also notice that I use Grrovy Gradle DSL.

如何使用Kotlin 1.3.30启用Parcelize back?

How can I enable Parcelizeback with Kotlin 1.3.30?

编辑,这是我的应用级别build.gradle

EDIT Here's my app level build.gradle

apply plugin: 'com.android.application'
apply plugin: "de.mannodermaus.android-junit5"
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'

apply from: "../versions.gradle"

android {

    compileSdkVersion 28

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
        applicationId "com.myapp.dtt"
        minSdkVersion 18
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"

        vectorDrawables.useSupportLibrary = true
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
        test.java.srcDirs += 'src/test/kotlin'
        androidTest.java.srcDirs += 'src/androidTest/kotlin'
    }

    testOptions {
        junitPlatform {
            filters {
                engines {
                    include 'spek2'
                }
            }
        }
    }
}

detekt {
    input = files("src/main/kotlin")
    baseline = file("detekt-baseline.xml")
}

androidExtensions {
    experimental = true
    features = ["parcelize"]
}

dependencies {
    kapt "com.google.dagger:dagger-compiler:$dagger_version"
    kapt "com.google.dagger:dagger-android-processor:$dagger_version"
    kapt "com.github.bumptech.glide:compiler:$glide_version"

    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
    implementation "com.google.android.material:material:$material_version"
    implementation "androidx.lifecycle:lifecycle-runtime:$lifecycle_version"
    implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"
    implementation "androidx.appcompat:appcompat:$appcompat_version"
    implementation "androidx.recyclerview:recyclerview:$recyclerview_version"
    implementation "androidx.constraintlayout:constraintlayout:$constraint_layout_version"
    implementation "com.google.dagger:dagger:$dagger_version"
    implementation "com.google.dagger:dagger-android:$dagger_version"
    implementation "com.google.dagger:dagger-android-support:$dagger_version"
    implementation "io.reactivex.rxjava2:rxjava:$rx_java_version"
    implementation "io.reactivex.rxjava2:rxandroid:$rx_android_version"
    implementation "io.reactivex.rxjava2:rxkotlin:$rx_kotlin_version"
    implementation "com.github.bumptech.glide:glide:$glide_version"

    debugImplementation "com.squareup.leakcanary:leakcanary-android:$leak_canary_version"
    releaseImplementation "com.squareup.leakcanary:leakcanary-android-no-op:$leak_canary_version"

    testImplementation "org.spekframework.spek2:spek-dsl-jvm:$spek_version"
    testImplementation "org.spekframework.spek2:spek-runner-junit5:$spek_version"
    testImplementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
    testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_jupiter_version"
    testImplementation "io.mockk:mockk:$mockk_version"
    testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit_jupiter_version"
}

推荐答案

我发现错误

Kotlin plugin should be enabled before 'kotlin-android-extensions'

因此将顺序更改为

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

它工作正常(:з''∠).

祝你好运.

这篇关于“未解决的参考:将其打包".更新到Kotlin 1.3.30之后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆