LoginSignup
1
0

More than 3 years have passed since last update.

kotlinx.android.parcel.Parcelizeのimportでエラーになる

Posted at
import kotlinx.android.parcel.Parcelize

これがparcelの時点でエラーになる

トップレベルのbuild.gradleで classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version" を dependenciesに追加する

build.gradle
buildscript {
    ext.kotlin_version = '1.3.70'
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.6.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        // ↓こいつを追加する
        classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
  // 以下略

そして肝心なのがモジュールのbuild.gradleでpluginの宣言の順

module/build.gradle
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

これが正しい順。 kotlin-android のあとに kotlin-android-extensions を書かないと表題の通りimportエラーになる。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0