Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 440 Vote(s) - 3.54 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution

#1
All of sudden I start getting this error, and I am not getting idea why if anyone just let me know where this error is, will be enough helpful. As much I am able to get is this because of new update of android studio.
Detailed summary of error I am getting.

Task :app:kaptDebugKotlin
ANTLR Tool version 4.5.3 used for code generation does not match the current runtime version 4.7.1ANTLR Runtime version 4.5.3 used for parser compilation does not match the current runtime version 4.7.1ANTLR Tool version 4.5.3 used for code generation does not match the current runtime version 4.7.1ANTLR Runtime version 4.5.3 used for parser compilation does not match the current runtime version 4.7.1C:\Users\shubh\Downloads\MarginCalculator\app\build\generated\source\kapt\debug\com\kotlin_developer\margincalculator\DataBinderMapperImpl.java:10: error: cannot find symbol
import com.kotlin_developer.margincalculator.databinding.FragmentCalculatorScreenBindingImpl;

symbol: class FragmentCalculatorScreenBindingImpl

Task :app:kaptDebugKotlin FAILED
location: package com.kotlin_developer.margincalculator.databinding
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)

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at

[To see links please register here]


BUILD FAILED in 17s
29 actionable tasks: 27 executed, 2 up-to-date
Reply

#2
If you have upgraded to classpath 'com.android.tools.build:gradle:4.0.0'
Replace it previous version

dependencies {
classpath 'com.android.tools.build:gradle:3.6.3'
}

And Change gradle-wrapper.properties

distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4- all.zip`

Reply

#3
I had the same error for a while then I started checking the other packages I came to know that I've made a typo mistake in my database code. So,
"Go through your database and other activity class files u may find some mistakes there."
Reply

#4
For me, a bunch of reference errors and an error in the XML expressions with `DataBinding` produced this error.

I have deleted a `<variable/>` in a `layout` file, because I thought, I don't need it anymore. I forgot that I had the variable referenced in the `layout` file.

After building the project, this produced an error, where it was not possible to import the `BindingImpl` class, because it does not exist and this error was only shown as a warning parallel to the above `KaptExecution` error.

After searching for a while, I found this error and resolved it. Then, a bunch of reference errors where shown, because I renamed something and it did not rename it in the `Fragment` files. After resolving these errors too, the build finished for me without errors or warnings.
Reply

#5
I had the same problem. Let me walk you through the example on how I ended up to the problem and the way I resolved it perhaps you can get a bigger picture.

Before resolving

@Entity(tableName = "modules")
data class Module
(
@PrimaryKey val id: Int,
val name: String
)

@Entity(tableName = "sessions")
data class Session
(
@PrimaryKey(autoGenerate = true) var id: Int,
@ColumnInfo(name = "module_id") val moduleId: Int,
@ColumnInfo(name = "start_time") val startTime: String,
@ColumnInfo(name = "end_time") val endTime: String
)

data class ModuleSession
(
@Embedded val module: Module,
@Relation(
parentColumn = "id",
entityColumn = "module_id"
)
val sessions: List<Session>,
@ColumnInfo(name = "is_updated") val isUpdated: Boolean = false // The problem
)

In the DAO

@Transaction
@Query("SELECT * FROM modules")
abstract suspend fun getModuleSession(): List<ModuleSession>

The error I got was

A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution

So I dug deeper and found the below message

The columns returned by the query does not have the fields [isUpdated] in com.gmanix.oncampusprototype.Persistence.ModuleSession even though they are annotated as non-null or primitive. Columns returned by the query: [id,name]
public abstract java.lang.Object getModuleSession(@org.jetbrains.annotations.NotNull()

I removed the field IsUpdated from the POJO ModuleSession and added it to the session table

After changes

@Entity(tableName = "sessions")
data class Session
(
@PrimaryKey(autoGenerate = true) var id: Int,
@ColumnInfo(name = "module_id") val moduleId: Int,
@ColumnInfo(name = "start_time") val startTime: String,
@ColumnInfo(name = "end_time") val endTime: String,
@ColumnInfo(name = "is_updated") val isUpdated: Boolean = false
)

data class ModuleSession
(
@Embedded val module: Module,
@Relation(
parentColumn = "id",
entityColumn = "module_id"
)
val sessions: List<Session>
)

On the other hand crosscheck if there is any field on the `SELECT` statement that is a suspect causing issues or you can annotate it with `@Ignore`

However you can post your code if you're still not comfortable.

I hope that might help
Reply

#6
Shout Out to @Rene Spies' answer above, I also got this error while working with databinding. It turns out the build engine doesn't like it when you put the `@Bindable` annotation on a field in the primary constructor of a `data class` in Kotlin.

So never do the following,

data class MyAwesomePojo(
@Bindable
var firstname: String,
var lastname: String
)

instead what you need to do is

data class MyCorrectAwesomePojo(
var lastname: String
):{
@get:Bindable
var firstname: String
set(value){
field = value
}
}

Bonus: remember to check for same values before setting value to field if you are trying to use two-way binding like me to prevent infinite looping of setting and getting.
Reply

#7
I got the same issue, so I tried to get more information, by doing

> gradle->app->Tasks->Build->assemble


After this I got exact error saying "Error while annotation processing".
I checked my recently tweaked DAO class and found that one of the method return type was not defined.

//Before
@Query("SELECT countryName FROM country_table WHERE countryCode= :code")
fun getCountryNameForCode(code: String)

//After
@Query("SELECT countryName FROM country_table WHERE countryCode= :code")
fun getCountryNameForCode(code: String): String
Reply

#8
Interestingly, I was getting this error because I added the description of the Retrofit. Be careful not to confuse the description of Room and Retrofit.



Reply

#9
In my case it was because I was not implementing Observable in my ViewModel. I added an EditText to the constraint layout with `android:text="@={addProductViewModel.inputProductName}"`

Once I implemented `Observable` in my ViewModel class the error was gone

ViewModel

class AddProductViewModel (
private val repository: ProductRepository,
private val context: Context
): ViewModel(), Observable {

@Bindable
val inputProductName = MutableLiveData<String>()


fun addProduct() {
//inputProductName.value
}

override fun removeOnPropertyChangedCallback(callback: Observable.OnPropertyChangedCallback?) {
TODO("Not yet implemented")
}

override fun addOnPropertyChangedCallback(callback: Observable.OnPropertyChangedCallback?) {
TODO("Not yet implemented")
}
}


Complete example for MVVM Databinding using Fragments

Layout - add_product.xml

<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android" >
<data class=".AddProductBinding">
<variable
name="addProductViewModel"
type="com.rao.iremind.AddProductViewModel" />
</data>

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">


<EditText
android:id="@+id/editTextTextProductName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Product name"
android:inputType="textPersonName"
android:text="@={addProductViewModel.inputProductName}"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />



</androidx.constraintlayout.widget.ConstraintLayout>
</layout>

AddProductFragment

class AddProductFragment: Fragment() {
private lateinit var binding: AddProductBinding
private lateinit var addProductViewModel: AddProductViewModel
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = DataBindingUtil.inflate(inflater, R.layout.add_product, container, false)
val dao = SubscriberDatabase.getInstance(requireActivity().applicationContext).productDAO
val repository = ProductRepository(dao)
val factory = AddProductViewModelFactory(repository, requireActivity().applicationContext)
addProductViewModel = ViewModelProvider(this, factory).get(AddProductViewModel::class.java)
binding.addProductViewModel = addProductViewModel
binding.lifecycleOwner = this
val view = binding.root

return view
}
}

AddProductViewModel

class AddProductViewModel (
private val repository: ProductRepository,
private val context: Context
): ViewModel(), Observable {

@Bindable
val inputProductName = MutableLiveData<String>()


fun addProduct() {
//inputProductName.value
}

override fun removeOnPropertyChangedCallback(callback: Observable.OnPropertyChangedCallback?) {
TODO("Not yet implemented")
}

override fun addOnPropertyChangedCallback(callback: Observable.OnPropertyChangedCallback?) {
TODO("Not yet implemented")
}
}

Hope this helps
R
Reply

#10
**In My Case:** Issue resolved

**Steps:**

1. Remove viewModel variable - **In XML**.
```xml
<variable
name="viewModel"
type="com.xx.AppViewModel" / >
```

2. Removed all viewModel binding references - **In XML**.

```
android:text="@{viewModel.simName}"
```

3. Removed viewModel instance reference to the binding mapping - **In Activity**

```
binding.viewModel = viewModel
```

4. **Clean project** and **recompile.**

5. Add viewModel variable - In XML & **Build project**.

```
< variable
name="viewModel"
type="com.xx.AppViewModel" / >
```

6. Add viewModel instance reference to the binding mapping - **In Activity & Build project**

```
binding.viewModel = viewModel
```

7. Add all viewModel binding references - **In XML & Build project.**.

```
android:text="@{viewModel.simName}"
```

8. It will work now.

-- I hope it will work for you also.

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through