Status Update
Comments
ag...@google.com <ag...@google.com>
x3...@gmail.com <x3...@gmail.com> #3
st...@google.com <st...@google.com> #4
You need to use version 1.5.30 of the Kotlin Gradle plugin or later, which should be compatible with all recent versions of the Android Gradle Plugin. The only other thing to keep in mind is that the fix is only implemented on the IR backend, which is the default since Kotlin 1.5. If you explicitly pass -Xuse-old-backend
to the compiler you will not see the fix.
ar...@gmail.com <ar...@gmail.com> #5
I am facing this error right now. I am using kotlin version 1.5.31 and gradle version 7.0.3. The error says:
error: unexpected type
public static final android.os.Parcelable.Creator<long> CREATOR = null;
^
And this is the class I am trying to parcelize:
@Parcelize
@JvmInline
value class Amount(
val value: Long = 0
) : Parcelable
st...@google.com <st...@google.com> #6
You are using the old compiler backend. Since we're using the IR backend by default since Kotlin 1.5 you just have to remove the -Xuse-old-backend
option and the bug will be fixed.
ar...@gmail.com <ar...@gmail.com> #7
But I don't have that flag in my build.gradle. I even tried setting useIR = true
in kotlinOptions
but that too didn't work.
mi...@anz.com <mi...@anz.com> #8
I've tried on AGP 7.0.3 with Kotlin 1.5.31 and 1.6.10, using IR backend, and I'm getting this compile error
org.jetbrains.kotlin.backend.common.BackendException: Backend Internal error: Exception during IR lowering
File being compiled: /Users/myuser/Documents/Source/GitHub/abc/efg/src/main/java/com/abc/efg/MyClass.kt
The root cause java.lang.NullPointerException was thrown at: org.jetbrains.kotlin.ir.util.IrUtilsKt.getTypeSubstitutionMap(IrUtils.kt:533)
here is the class
@JvmInline
@Parcelize
value class MyClass<T>(val value: String) : Parcelable
mi...@gmail.com <mi...@gmail.com> #9
For me what seems to be causing the issue is :
apply plugin: 'kotlin-kapt'
I'm playing around with DataBinding and only after adding it and "kapt" has the error appeared. Before that it was completely fine.
st...@google.com <st...@google.com> #10
Thanks a lot for the reports and especially to
Fortunately, the kapt implementation with the new backend is already being worked on, and you can track the progress in
Meanwhile you should be able to disable the parcelize plugin when generating kapt stubs. I'll try to figure out if there's an easy way to do this in gradle.
sa...@gmail.com <sa...@gmail.com> #11
ag...@google.com <ag...@google.com> #12
Update from
December 2022
We’ve added support for kapt in the new JVM IR backend in Kotlin 1.7.20, available via a flag. See the documentation for more information on how to enable it.
Plans
We plan to enable this behavior by default in v1.8.20 (KT-53135).
The flag to enable the JVM_IR backend for kapt in 1.7.20 is kapt.use.jvm.ir=true
in gradle.properties
.
Description
Example:
If you try write
SomeDataClass
to a parcel it will fail in runtime saying: