Search code examples
androidkotlinandroid-gradle-pluginparcelablekotlin-extension

ParcelCreator lint suppression not working


I'm trying to add Parcelize implementation but it doesn't seem to be working.

This is whaat my project's gradle looks like:

buildscript {
ext.kotlin_version = '1.2.30'

repositories {
    maven { url "https://jitpack.io" }
    google()
    jcenter()    }
dependencies {
    classpath 'com.android.tools.build:gradle:3.1.0'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"

    //Realm as ORM
    classpath "io.realm:realm-gradle-plugin:4.3.3"
}
}

allprojects {
repositories {
    maven { url "https://jitpack.io" }
    google()
    jcenter()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

App's build gradle:

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

apply plugin: 'realm-android'

android {
compileSdkVersion 27
defaultConfig {
    applicationId "com.----.----"
    minSdkVersion 21
    targetSdkVersion 27
    multiDexEnabled true
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

kapt {
generateStubs = true
}

dependencies {

def supportVersion = '27.1.0'

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:' + supportVersion
implementation 'com.android.support:preference-v14:' + supportVersion
implementation 'com.android.support:support-v4:' + supportVersion
implementation 'com.android.support:design:' + supportVersion
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
//noinspection GradleCompatible
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
// Dagger 2
implementation 'com.google.dagger:dagger:2.14.1'
kapt 'com.google.dagger:dagger-compiler:2.14.1'

// Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.4.0'
implementation 'com.squareup.retrofit2:converter-moshi:2.4.0'
implementation 'com.squareup.moshi:moshi-kotlin:1.5.0'

//Rx
implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
implementation 'io.reactivex.rxjava2:rxjava:2.1.9'
implementation 'io.reactivex.rxjava2:rxkotlin:2.2.0'

//Glide
implementation 'com.github.bumptech.glide:glide:4.6.1'
implementation 'jp.wasabeef:glide-transformations:3.1.1'
kapt 'com.github.bumptech.glide:compiler:4.6.1'

//Recycler view, Card view
implementation 'com.android.support:recyclerview-v7:27.1.0'
implementation 'com.android.support:cardview-v7:27.1.0'

//video player
implementation 'com.google.android.exoplayer:exoplayer:r2.5.1'

//circle image view
implementation 'de.hdodenhof:circleimageview:2.2.0'

//page indicator
implementation 'com.romandanylyk:pageindicatorview:1.0.0'

//spinner
implementation 'com.jaredrummler:material-spinner:1.2.4'

}
repositories {
mavenCentral()
}

And this is the model where I am trying to implement Parcelize:

@SuppressLint("ParcelCreator")
@Parcelize
data class StatusMessagesSender(@Json(name = "firstName")
                            val firstName: String?,
                            @Json(name = "lastName")
                            val lastName: String?,
                            @Json(name = "pushDeviceToken")
                            val pushDeviceToken: String?,
                            @Json(name = "address")
                            val address: String?,
                            @Json(name = "phoneNumber")
                            val phoneNumber: String?,
                            @Json(name = "name")
                            val name: String?,
                            @Json(name = "userId")
                            val userId: String?,
                            @Json(name = "age")
                            val age: Int?,
                            @Json(name = "email")
                            val email: String?): Parcelable

So even if I add this annotation @SuppressLint("ParcelCreator"), nothing changes.. It still gives me the same error without it:

"Class 'StatusMessagesSender' is not abstract and does not implement abstract member public abstract fun writeToParcel(dest: Parcel!, flags: Int): Unit defined in android.os.Parcelable"

Anyone can tell if I did something wrong here?


Solution

  • Put the next code inside android { } in the file build.gradle of your App.

    androidExtensions {
        experimental = true
    }