Class example is not abstract and does not implement fun writeToParcel() defined in android.os.Parcelable
bqytallhsirlkm
Posted on June 21, 2020
In my Android project, I want to add a Bundle including a Place object described below to my Intent. Since serializable was slow and not recommended, I preferred Parcelable.
Although I use Kotlin 1.3.72, I have problems paralyzing some data classes. Example:-
import kotlinx.android.parcel.IgnoredOnParcel
import android.os.Parcelable
import kotlinx.android.parcel.Parcelize
@Parcelize
data class QariItem(
val id: Int,
val name: String,
val url: String,
val path: String,
val db: String? = null
) : Parcelable {
@IgnoredOnParcel
val databaseName = if (db.isNullOrEmpty()) null else db
val isGapless: Boolean
get() = databaseName != null
}
bulid.gradle.kt
import org.jetbrains.kotlin.config.KotlinCompilerVersion
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("com.android.application")
kotlin("android")
kotlin("kapt")
}
// https://stackoverflow.com/a/52441962
fun String.runCommand(
workingDir: File = File("."),
timeoutAmount: Long = 60,
timeoutUnit: TimeUnit = TimeUnit.SECONDS
): String? = try {
ProcessBuilder("\s".toRegex().split(this))
.directory(workingDir)
.redirectOutput(ProcessBuilder.Redirect.PIPE)
.redirectError(ProcessBuilder.Redirect.PIPE)
.start().apply { waitFor(timeoutAmount, timeoutUnit) }
.inputStream.bufferedReader().readText()
} catch (e: java.io.IOException) {
e.printStackTrace()
null
}
android {
compileSdkVersion(29)
buildToolsVersion("29.0.3")
buildFeatures {
viewBinding = true
}
val gitVersion = listOf(
"git rev-parse --abbrev-ref HEAD",
"git rev-list HEAD --count",
"git rev-parse --short HEAD"
).joinToString("-") { it.runCommand()?.trim() ?: "" } +
(if (("git status -s".runCommand() ?: "").isBlank()) "" else "-dirty")
defaultConfig {
applicationId = "ye.ansarallah.Almumin"
minSdkVersion(15)
targetSdkVersion(29)
versionCode = 623
versionName = "3.1.3"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
resConfigs("en", "fa", "ckb", "ar", "ur", "ps", "glk", "azb", "ja")
// setProperty("archivesBaseName", "PersianCalendar-$versionName-$gitVersion")
multiDexEnabled = false
}
signingConfigs {
create("nightly") {
storeFile = rootProject.file("nightly.keystore")
storePassword = "android"
keyAlias = "androiddebugkey"
keyPassword = "android"
}
}
buildTypes {
create("nightly") {
signingConfig = signingConfigs.getByName("nightly")
// versionNameSuffix = "-${defaultConfig.versionName}-$gitVersion-nightly"
applicationIdSuffix = ".nightly"
isMinifyEnabled = true
isShrinkResources = true
}
getByName("debug") {
// versionNameSuffix = "-${defaultConfig.versionName}-$gitVersion"
applicationIdSuffix = ".debug"
}
getByName("release") {
isMinifyEnabled = true
isShrinkResources = true
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}
tasks.withType {
kotlinOptions.jvmTarget = "1.8"
}
dependencies {
implementation("org.jetbrains.kotlin:kotlin-android-extensions-runtime:1.3.72")
implementation("com.github.persian-calendar:equinox:1.0.0")
implementation("com.github.persian-calendar:calendar:1.0.0")
implementation("com.github.persian-calendar:praytimes:1.0.0")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${KotlinCompilerVersion.VERSION}")
implementation("androidx.appcompat:appcompat:1.1.0")
implementation("androidx.preference:preference-ktx:1.1.1")
implementation("androidx.recyclerview:recyclerview:1.1.0")
implementation("androidx.cardview:cardview:1.0.0")
implementation("androidx.constraintlayout:constraintlayout:1.1.3")
implementation("androidx.viewpager2:viewpager2:1.0.0")
implementation("com.google.android.material:material:1.1.0")
implementation("com.google.android:flexbox:1.1.0")
implementation("com.google.android.apps.dashclock:dashclock-api:2.0.0")
implementation("com.google.android.gms:play-services-maps:17.0.0")
val navVersion = "2.2.2"
implementation("androidx.navigation:navigation-fragment-ktx:$navVersion")
implementation("androidx.navigation:navigation-ui-ktx:$navVersion")
implementation("androidx.core:core-ktx:1.3.0")
implementation("androidx.fragment:fragment-ktx:1.2.5")
implementation("androidx.activity:activity-ktx:1.1.0")
implementation("androidx.browser:browser:1.0.0")
implementation("androidx.work:work-runtime-ktx:2.3.4")
//weather implamentation
implementation("androidx.legacy:legacy-support-v4:1.0.0")
implementation("com.google.android.apps.dashclock:dashclock-api:2.0.0")
implementation("com.diogobernardino:williamchart:2.2")
implementation("androidx.lifecycle:lifecycle-extensions:2.2.0")
annotationProcessor("androidx.lifecycle:lifecycle-compiler:2.2.0")
// debugImplementation("com.squareup.leakcanary:leakcanary-android:2.0-alpha-2")
// debugImplementation("com.github.pedrovgs:lynx:1.1.0")
testImplementation("junit:junit:4.13")
androidTestImplementation("androidx.test:runner:1.2.0")
androidTestImplementation("androidx.test:rules:1.2.0")
androidTestImplementation("androidx.test.espresso:espresso-contrib:3.2.0")
androidTestImplementation("androidx.test.espresso:espresso-core:3.2.0")
implementation("com.github.clans:fab:1.6.4")
//Quran_Quarn
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.6")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.6")
implementation("com.squareup.retrofit2:retrofit:2.7.2")
implementation("com.squareup.retrofit2:converter-moshi:2.7.2")
implementation("androidx.media:media:1.1.0")
implementation("androidx.localbroadcastmanager:localbroadcastmanager:1.0.0")
implementation("androidx.preference:preference:1.1.1")
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0")
implementation("androidx.multidex:multidex:2.0.1")
// rx
implementation("io.reactivex.rxjava2:rxjava:2.2.19")
implementation("io.reactivex.rxjava2:rxandroid:2.1.1")
// dagger
api("com.google.dagger:dagger:2.27")
kapt("com.google.dagger:dagger-compiler:2.27")
kapt("com.google.dagger:dagger-android-processor:2.26")
// workmanager
implementation("androidx.work:work-runtime-ktx:2.3.4")
implementation("com.squareup.okio:okio:2.6.0")
implementation("com.squareup.okhttp3:okhttp:3.12.+")
implementation("com.squareup.moshi:moshi:1.9.2")
kapt("com.squareup.moshi:moshi-kotlin-codegen:1.9.2")
implementation("com.jakewharton.timber:timber:4.7.1")
debugImplementation("com.squareup.leakcanary:leakcanary-android:2.3")
testImplementation("com.google.truth:truth:1.0.1")
testImplementation("org.mockito:mockito-core:3.3.3")
testImplementation("com.squareup.okhttp3:mockwebserver:3.12.+")
testImplementation("com.squareup.okhttp3:okhttp-dnsoverhttps:3.12.+")
androidTestImplementation("androidx.test.espresso:espresso-core:3.2.0")
androidTestImplementation("androidx.test.espresso:espresso-intents:3.2.0")
implementation("com.crashlytics.sdk.android:crashlytics:2.10.1")
implementation ("dnsjava:dnsjava:2.1.9")
implementation ("com.squareup.okhttp3:okhttp-dnsoverhttps:3.12.+")
}
I really appreciate your help.
Posted on June 21, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
November 29, 2024