I am trying to integrate Room in my kotlin project which also uses databinding.I have implemented all the required classes (I think so!) but when I try to build the project I get the below error message and can not find out what is causing this error or what am I missing
Here is the build log
e: [PATH_TO_PROJECT]\dataaccess\local\AppDatabase.java:7: error: android.arch.persistence.room.RoomProcessor was unable to process this class because not all of its dependencies could be resolved. Check for compilation errors or a circular dependency with generated code.
public abstract class AppDatabase extends android.arch.persistence.room.RoomDatabase {
^
e: [PATH_TO_PROJECT]\dataaccess\local\BusinessLocalDataSource.java:7: error: android.arch.persistence.room.RoomProcessor was unable to process this class because not all of its dependencies could be resolved. Check for compilation errors or a circular dependency with generated code.
public abstract class BusinessLocalDataSource implements [PACKAGE].dataaccess.local.BaseDao<[PACKAGE].dataaccess.local.model.Business>, [PACKAGE].dataaccess.BusinessDataSource {
^
e: [PATH_TO_PROJECT]\dataaccess\local\model\Business.java:7: error: android.arch.persistence.room.RoomProcessor was unable to process this class because not all of its dependencies could be resolved. Check for compilation errors or a circular dependency with generated code.
public final class Business {
^
:app:kaptAppDebugKotlin FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:kaptAppDebugKotlin'.
> Compilation error. See log for more details
* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:kaptAppDebugKotlin'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:103)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:73)
at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:59)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ResolveBuildCacheKeyExecuter.execute(ResolveBuildCacheKeyExecuter.java:66)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:59)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:101)
at org.gradle.api.internal.tasks.execution.FinalizeInputFilePropertiesTaskExecuter.execute(FinalizeInputFilePropertiesTaskExecuter.java:44)
at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:91)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:62)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:59)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:256)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:249)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:238)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:663)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:597)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
Caused by: org.gradle.api.GradleException: Compilation error. See log for more details
at org.jetbrains.kotlin.gradle.tasks.TasksUtilsKt.throwGradleExceptionIfError(tasksUtils.kt:16)
at org.jetbrains.kotlin.gradle.internal.KaptWithKotlincTask.compile(KaptWithKotlincTask.kt:79)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.doExecute(StandardTaskAction.java:46)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:788)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:755)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:124)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:113)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:95)
... 31 more
* Get more help at https://help.gradle.org
BUILD FAILED in 9s
This is my AppDatabase class
@Database(version = 1, entities = [(Business::class)])
abstract class AppDatabase : RoomDatabase() {
abstract fun businessDao(): BusinessLocalDataSource
companion object {
private var INSTANCE: AppDatabase? = null
fun getInstance(context: Context): AppDatabase {
if (INSTANCE == null) {
synchronized(AppDatabase::class) {
INSTANCE = Room.databaseBuilder(context,
AppDatabase::class.java,
"app.db")
.build()
}
}
return INSTANCE!!
}
fun destroyInstance() {
INSTANCE = null
}
}
}
My business entity
@Entity(tableName = "business")
data class Business(
@PrimaryKey
@ColumnInfo(name = "uuid")
var uuid: String = "",
@ColumnInfo(name = "title")
var title: String = "",
@ColumnInfo(name = "address")
var address: String = "",
@ColumnInfo(name = "votesCount")
var votesCount: Int = 0,
@ColumnInfo(name = "isSpecial")
var isSpecial: Boolean = false,
@ColumnInfo(name = "lat")
var lat: Double? = 0.0,
@ColumnInfo(name = "lon")
var lon: Double? = null,
@ColumnInfo(name = "imageUrl")
var imageUrl: String = "",
@ColumnInfo(name = "dateSeen")
var dateSeen: Long = 0
)
My BaseDao interface
interface BaseDao<T> {
@Delete
fun delete(t: List<T>): Int
@Delete
fun delete(t: T): Int
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insert(t: List<T>): List<Long>
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insert(t: T): Long
@Update
fun update(t: List<T>): Int
@Update
fun update(t: T): Int
}
And here is the BusinessLocalDataSource which implements BaseDao
@Dao
abstract class BusinessLocalDataSource : BaseDao<Business>, BusinessDataSource {
override fun getTitleSuggestions(request: TitleSuggesterRequest): Maybe<TitleSuggesterResponse> {
TODO("Currently local data source does not support getting title suggestions")
}
override fun getPreSearch(): Maybe<PreSearchResponse> {
TODO("Currently local data source does not support getting pre-search data")
}
@Query("SELECT * from business")
abstract override fun getLastSeen(): Flowable<List<Business>>
override fun saveLastSeen(business: Business) {
insert(business)
}
}
And here is my build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'io.fabric'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 26
buildToolsVersion '28.0.3'
// ...
configurations.all {
resolutionStrategy {
force 'com.android.support:appcompat-v7:26.1.0'
force 'com.android.support:design:26.1.0'
force 'com.android.support:support-v4:26.1.0'
force 'com.android.support:cardview-v7:26.1.0'
force 'com.android.support:palette-v7:26.1.0'
}
}
lintOptions {
disable 'MissingTranslation'
}
defaultConfig {
multiDexEnabled true
applicationId '[PACKAGE]'
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
packagingOptions {
exclude "lib/arm64-v8a/librealm-jni.so"
}
vectorDrawables.useSupportLibrary = true
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
dexOptions {
jumboMode true
javaMaxHeapSize "4g"
}
buildTypes {
debug {
versionNameSuffix '.DEBUG'
}
release {
minifyEnabled true
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/rxjava.properties'
exclude 'META-INF/rxkotlin.properties'
exclude 'META-INF/app_debug.kotlin_module'
exclude 'META-INF/proguard/androidx-annotations.pro'
}
dataBinding {
enabled = true
}
// ...
}
configurations {
implementation.exclude group: 'org.jetbrains', module: 'annotations'
implementation.exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jre7'
}
dependencies {
// ...
implementation "android.arch.persistence.room:runtime:1.1.1"
kapt "android.arch.persistence.room:compiler:1.1.1"
implementation "android.arch.persistence.room:rxjava2:1.1.1"
}
I really do not know what to check anymore. It would be great if someone help. Thanks in advance.
Maybe you forget to add apply plugin: "kotlin-kapt" in build.gradle[app].
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With