Room IllegalArgumentException: intcannot be converted to an Element

Error:Execution failed for task ':app:compileDebugJavaWithJavac'. java.lang.IllegalArgumentException: intcannot be converted to an Element

Basically, this problem arises not only by the @Delete query, but by all the Room's CRUD annotations (@Insert, @Delete, @Update) except @Query.

All of the parameters of these CRUD annotated methods must either be classes annotated with Entity or collections/array of it.

So we can't pass primitive or other than these.


remove

@Delete
public abstract void deleteNow(int id);

from your Dao it will work


@Delete annotation marks a method in a Dao annotated class as a delete method. The implementation of the method will delete its parameters from the database.
All of the parameters of the Delete method must either be classes annotated with Entity or collections/array of it.

Read here for extra information.

So in your case you pass a parameter with int type which violates the aforementioned rule. That is why you are getting that error.

In order to resolve this issue, you should either exclude deleteNow method or just pass any parameter that does not violates the rule that was mentioned above.