Reputation: 1482
Im working on an Android App, currently using DSL and some libraries, suddenly the build gave me this error.
Task :app:kaptDebugKotlin FAILED ANTLR Tool version 4.7.1 used for code generation does not match the current runtime version 4.5.3ANTLR Runtime version 4.7.1 used for parser compilation does not match the current runtime version 4.5.3 FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:kaptDebugKotlin'. A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution java.lang.reflect.InvocationTargetException (no error message)
i've been searching but with no success...
If you wanna see the issue you can clone the project. Project GITHUB Im using Android Studio Canary 4.1.
Upvotes: 13
Views: 18519
Reputation: 1439
At lease for me, the root cause of this problem/error is because of the data binding not being handled properly. Currently, Android Studio does not have a mechanism to show error message for unreferenced variables in .xml file.
For example, In MyViewModel.kt, If I have a property name as,
var email
and you are mapping this property in xml as,
@={model.errEmail}
instead of @={model.email}
You get to see this error.
If you see this error, just go to layout xml file and check the binding names/mappings and correct it.
Upvotes: 0
Reputation: 1043
I got similar error. I have all files in Java and I changed few files to Kotlin. Then this issue showed up.
I have a function in a Java file accessing static function in a Kotlin file. That's the point where the app crashed.
Code in Kotlin file:
companion object{
@JvmStatic
fun myStaticFunction(){
// body of the static function
}
}
I added the annotation @JvmStatic
(see the above code) to the function and the error got resolved.
This is a very specific scenario in which this crash occurs and may not be applicable to all.
Upvotes: 0
Reputation: 57
The problem was fixed for me by changing this. from:
implementation "androidx.room:room-runtime:$depVersion"
implementation "androidx.room:room-compiler:$depVersion"
to:
implementation "androidx.room:room-runtime:$depVersion"
annotationProcessor "androidx.room:room-compiler:$depVersion"
Upvotes: 2
Reputation: 876
For anyone still experiencing this issue, just update your Room to the latest version:
androidx.room:room-runtime:2.3.0-alpha04
androidx.room:room-compiler:2.3.0-alpha04
It's due to this bug: https://issuetracker.google.com/issues/155215201
Upvotes: 2
Reputation: 9
Had a similar issue. I was trying to implement bindingAdapters to a TextView of a ViewHolder in my recyclerview
I failed to implement a bindingAdapter for a TextView after adding the adding a unique app attribute
app:tDate="@{transaction}
in the xml layout file for my recylerView item.
<TextView
android:id="@+id/trans_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/trans_category"
app:layout_constraintTop_toTopOf="parent"
app:tDate="@{transaction}"/>
Solved it by well.. implementing it.
@BindingAdapter("tDate")
fun TextView.setValue(item: Transactions){
text = item.date.toString()
}
Upvotes: -1
Reputation: 2821
Removing suspend keyword from queries in DAO interface, solved my problem
Upvotes: 1
Reputation: 8250
Inside the build.gradle(Module:app) copypaste this code
configurations.all() {
resolutionStrategy.force "org.antlr:antlr4-runtime:4.5.3"
resolutionStrategy.force "org.antlr:antlr4-tool:4.5.3"
}
Upvotes: 3
Reputation: 1482
So the solution was from the build.gradle
basically the import from ROOM was this
import(Room.compiler)
so i changed to this, and the issue was solved :)
kapt(Room.compiler)
Upvotes: 3