构建失败 Android Room 和 EventBus

Build failed Android Room & EventBus

我接手了一个Android项目,我需要修改数据库(至少添加实体和daos)。问题是代码中最细微的变化,项目不再 'compile',我得到以下错误。

***\app\src\main\java\fr\***\***\syxs\core\App.java:25: error: cannot find symbol
import fr.***.***.syxs.EventBusIndex;
                                ^
  symbol:   class EventBusIndex
  location: package fr.***.***.syxs

EventBusIndex class 未生成,因此我的应用无法编译。我想当我改变一些东西 在我的 AppDatabase class 中,什么都没有 invalidated/updated ?

一个例子: 此代码编译(默认代码)

@Database(entities = {
        MessageInbox.class,
        MessageOutbox.class,
        MessagePredefined.class},
        version = 12)
public abstract class AppDatabase extends RoomDatabase {

    public abstract MessageOutboxDao messageOutboxDao();

    public abstract MessageInboxDao messageInboxDao();

    public abstract MessagePredefinedDao messagePredefinedDao();

    ...

这个没有

@Database(entities = {
        MessageInbox.class,
        MessageOutbox.class,
        MessagePredefined.class},
        version = 12)
public abstract class AppDatabase extends RoomDatabase {

    public abstract MessageOutboxDao messageOutboxDao();

    public abstract MessageInboxDao messageInboxDao();

    public abstract MessagePredefinedDao messagePredefinedDao();

    public abstract OtherClassDao foo();

    ...

无论我多么努力地尝试更改数据库的版本,它都不会改变任何东西。我从我的项目中删除了所有的原理图,我试图在这里和那里清理。我还在 AndroidStudio 上尝试了著名的 'Invalidate cache & restart',当然没有结果。我在网上找遍了,但找不到任何结论。

build.gradle

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'org.sonarqube'

android {
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
    signingConfigs {
        release {
            storeFile file('C:\SIGNED\keystore.jks')
            storePassword '***'
            keyAlias '***'
            keyPassword '***'
        }
        debug {
            storeFile file('C:\SIGNED\keystore.jks')
            storePassword '***'
            keyPassword '***'
            keyAlias '***'
        }
    }
    compileSdkVersion 29
    defaultConfig {
        applicationId "fr.***.***"
        minSdkVersion 19
        targetSdkVersion 29
        multiDexEnabled true
        versionCode 37 
        versionName "2.5.8"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        javaCompileOptions {
            annotationProcessorOptions {
                arguments = ["room.schemaLocation": "$projectDir/schemas".toString(),
                             eventBusIndex : 'fr.***.***.syxs.EventBusIndex']
            }
        }
    }
    buildTypes {
        release {
            minifyEnabled false //true
            useProguard true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
            multiDexEnabled true
            debuggable true
        }
        debug {
            signingConfig signingConfigs.debug
            multiDexEnabled true
        }
    }
    buildToolsVersion '28.0.3'
    buildFeatures {
        viewBinding = true
    }
    lintOptions {
        checkReleaseBuilds false
        abortOnError false
    }
}

dependencies {
    // TODO check this
    implementation 'commons-net:commons-net:20030805.205232'

    // TODO delete all implementation of com.android.support.*
    def lifecycleVersion   = "1.1.1"
    def roomVersion        = "2.2.5"
    def multidexVersion    = "2.0.1"
    def eventbusVersion    = "3.2.0"
    
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation "androidx.multidex:multidex:$multidexVersion"
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.volley:volley:1.1.0'
    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
    implementation 'org.jetbrains:annotations-java5:20.1.0'

    // ViewModel and LiveData components
    implementation "android.arch.lifecycle:extensions:$lifecycleVersion"
    annotationProcessor "android.arch.lifecycle:compiler:$lifecycleVersion"

    // Room components
    implementation "androidx.room:room-runtime:$roomVersion"
    annotationProcessor "androidx.room:room-compiler:$roomVersion"

    // SocketIO
    implementation 'com.github.nkzawa:socket.io-client:0.6.0'

    // Gson
    implementation 'com.google.code.gson:gson:2.8.6'

    // Sygic
    implementation 'com.sygic.driving:driving-lib:1.2.1'
    implementation 'com.google.android.material:material:1.2.1'
    implementation project(path: ':SygicLib')

    // SFTP
    implementation 'com.jcraft:jsch:0.1.55'

    // EventBus
    implementation "org.greenrobot:eventbus:$eventbusVersion"
    annotationProcessor "org.greenrobot:eventbus-annotation-processor:$eventbusVersion"

    // Test
    testImplementation 'junit:junit:4.13.1'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

sonarqube {
    properties {
       ***
    }
}

repositories {
    mavenCentral()
}

configurations {
    cleanedAnnotations
    compile.exclude group: 'org.jetbrains' , module:'annotations'
}

我错过了什么?

编辑 12/04:

经过几次修改我的代码后,我发现问题是根据我的dao的内容出现的。当它为空时,一切都会编译,但即使我添加一种方法,编译也会失败。 最后,我觉得问题更多的是我entity/dao的层面,但我不知道问题出在哪里。

应用程序数据库:

...
public abstract FooDao fooDao();
...

FooDao :

import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.Update;
import androidx.room.Delete;
import androidx.room.Query;

@Dao
public interface FooDao {

    @Insert
    void insert(Foo foo);

    @Update
    void update(Foo foo);

    @Delete
    void delete(Foo foo);

    @Query("SELECT * FROM foo_table WHERE id=:id")
    Foo getFooById(int id);
}

富:

import androidx.room.Entity;
import androidx.room.PrimaryKey;

@Entity(tableName = "foo_table")
public class Foo {

    @PrimaryKey(autoGenerate = true)
    private long id;
    private boolean yes;

    public Foo() {}

    public Foo(long id, boolean no) {
        this.id = id;
        this.yes = no;
    }

    public Foo(boolean no) {
        this.yes = no;
    }

    public boolean getYes() {
        return yes;
    }

    public void setYes(boolean yes) {
        this.yes = yes;
    }
}

我找到了解决方案,我忘了在 AppDatabase 中声明我的实体 ... mb