Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/188.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android RoomProcessor编译或循环依赖_Android_Kotlin_Android Room - Fatal编程技术网

Android RoomProcessor编译或循环依赖

Android RoomProcessor编译或循环依赖,android,kotlin,android-room,Android,Kotlin,Android Room,我已经为Android Room组件的问题挣扎了好几天 我所做的只是将我的Android studio从3.3升级到3.4.1,同时对gradle等进行了修改。 我甚至试着回到3.3,但没有任何效果。 我已经使用运行了--info或--debug选项来尝试查看更多详细信息,但没有任何内容提供更多信息。请帮忙 e: /.../app/build/tmp/kapt3/stubs/debug/com/.../model/HotspotEntity.java:7: error: [RoomProcess

我已经为Android Room组件的问题挣扎了好几天

我所做的只是将我的Android studio从3.3升级到3.4.1,同时对gradle等进行了修改。 我甚至试着回到3.3,但没有任何效果。 我已经使用
运行了--info或--debug选项
来尝试查看更多详细信息,但没有任何内容提供更多信息。请帮忙

e: /.../app/build/tmp/kapt3/stubs/debug/com/.../model/HotspotEntity.java:7: error: [RoomProcessor:MiscError] androidx.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 HotspotEntity implements android.os.Parcelable {
             ^
e: /.../app/build/tmp/kapt3/stubs/debug/com/.../ConditionEntity.java:7: error: [RoomProcessor:MiscError] androidx.room.RoomProcessor "same as above".
public final class ConditionEntity implements android.os.Parcelable {
             ^
e: /.../app/build/tmp/kapt3/stubs/debug/com/.../model/AdLimits.java:6: error: [RoomProcessor:MiscError] androidx.room.RoomProcessor "same as above"
public final class AdLimits {
             ^
e: /.../app/build/tmp/kapt3/stubs/debug/com/.../model/AdTarget.java:6: error: [RoomProcessor:MiscError] androidx.room.RoomProcessor "same as above"
public final class AdTarget {
             ^
e: /.../app/build/tmp/kapt3/stubs/debug/com/.../model/AdUrl.java:6: error: [RoomProcessor:MiscError] androidx.room.RoomProcessor "same as above"
public final class AdUrl {
             ^

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:kaptDebugKotlin'.
> Compilation error. See log for more details
版本

Android Gradle:
3.4.1
Gradle version:
5.4.1
Android Room:
def room_version = "2.1.0-alpha06"
implementation 'androidx.room:room-runtime:' + room_version
kapt 'androidx.room:room-compiler:' + room_version
testImplementation 'androidx.room:room-testing:' + room_version
----更新----

使用room
2.1.0-rc01“
对以下问题进行了尝试,将其更改为相同的问题,但适用于不同的类别:

AppDatabase.java:8: error: [RoomProcessor:MiscError] androidx.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 androidx.room.RoomDatabase {
等级档案

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: "androidx.navigation.safeargs.kotlin"

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.cfl.surfstoked"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 19
        versionName "1.0.4"
        vectorDrawables.useSupportLibrary = true
    }
    buildTypes {
        debug {
            debuggable true
        }

        release {
            debuggable false
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    repositories {
        mavenCentral()
    }

    lintOptions {
        checkReleaseBuilds false
    }

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

dependencies {
    kapt 'com.google.dagger:dagger-android-processor:2.23.1'

    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.core:core-ktx:1.0.2'

    def lifecycleVersion = "2.1.0-alpha02"
    implementation 'androidx.lifecycle:lifecycle-extensions:' + lifecycleVersion
    implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:' + lifecycleVersion
    implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0-alpha01'
    implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.0.0'
    kapt 'androidx.lifecycle:lifecycle-compiler:' + lifecycleVersion

    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'

    //DI
    def koinVersion = "1.0.2"
    implementation 'org.koin:koin-android:' + koinVersion
    implementation 'org.koin:koin-androidx-scope:' + koinVersion
    implementation 'org.koin:koin-androidx-viewmodel:' + koinVersion

    //Navigation
//    def navigationVersion = "1.0.0-beta02"
//    implementation 'android.arch.navigation:navigation-fragment-ktx:' + navigationVersion
//    implementation 'android.arch.navigation:navigation-ui-ktx:' + navigationVersion

    def navigationVersion = "2.1.0-alpha01"
    implementation 'androidx.navigation:navigation-fragment-ktx:' + navigationVersion
    implementation 'androidx.navigation:navigation-ui-ktx:' + navigationVersion

    implementation 'org.greenrobot:eventbus:3.1.1'

    //Coroutines
    def corutinesVersion = "1.1.1"
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:' + corutinesVersion
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:' + corutinesVersion

    //Database
    def room_version = "2.1.0-rc01"
    implementation 'androidx.room:room-runtime:' + room_version
    kapt 'androidx.room:room-compiler:' + room_version
//    implementation 'androidx.room:room-coroutines:' + room_version
    testImplementation 'androidx.room:room-testing:' + room_version

}

apply plugin: 'com.google.gms.google-services'
应用程序依赖项

debugCompileClasspath - Compile classpath for compilation 'debug' (target  (androidJvm)).
+--- org.jetbrains.kotlin:kotlin-android-extensions-runtime:{strictly 1.3.30} -> 1.3.30 (c)
+--- org.jetbrains.kotlin:kotlin-stdlib:{strictly 1.3.30} -> 1.3.30 (c)
+--- org.jetbrains.kotlin:kotlin-stdlib-common:{strictly 1.3.30} -> 1.3.30 (c)
+--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:{strictly 1.3.30} -> 1.3.30 (c)
+--- androidx.core:core-ktx:{strictly 1.0.2} -> 1.0.2 (c)
+--- androidx.annotation:annotation:{strictly 1.1.0-rc01} -> 1.1.0-rc01 (c)
+--- androidx.core:core:{strictly 1.1.0-alpha05} -> 1.1.0-alpha05 (c)
+--- com.google.guava:listenablefuture:{strictly 9999.0-empty-to-avoid-conflict-with-guava} -> 9999.0-empty-to-avoid-conflict-with-guava (c)
+--- androidx.lifecycle:lifecycle-runtime:{strictly 2.2.0-alpha01} -> 2.2.0-alpha01 (c)
+--- androidx.lifecycle:lifecycle-common:{strictly 2.2.0-alpha01} -> 2.2.0-alpha01 (c)
+--- androidx.arch.core:core-common:{strictly 2.1.0-beta01} -> 2.1.0-beta01 (c)
+--- androidx.versionedparcelable:versionedparcelable:{strictly 1.1.0-alpha02} -> 1.1.0-alpha02 (c)
+--- androidx.collection:collection:{strictly 1.1.0-alpha03} -> 1.1.0-alpha03 (c)
+--- androidx.concurrent:concurrent-futures:{strictly 1.0.0-alpha02} -> 1.0.0-alpha02 (c)
+--- androidx.lifecycle:lifecycle-extensions:{strictly 2.2.0-alpha01} -> 2.2.0-alpha01 (c)
+--- androidx.arch.core:core-runtime:{strictly 2.1.0-beta01} -> 2.1.0-beta01 (c)
+--- androidx.fragment:fragment:{strictly 1.1.0-alpha05} -> 1.1.0-alpha05 (c)
+--- androidx.viewpager:viewpager:{strictly 1.0.0} -> 1.0.0 (c)
+--- androidx.customview:customview:{strictly 1.0.0} -> 1.0.0 (c)
+--- androidx.loader:loader:{strictly 1.0.0} -> 1.0.0 (c)
+--- androidx.lifecycle:lifecycle-livedata:{strictly 2.2.0-alpha01} -> 2.2.0-alpha01 (c)
+--- androidx.lifecycle:lifecycle-livedata-core:{strictly 2.2.0-alpha01} -> 2.2.0-alpha01 (c)
+--- androidx.lifecycle:lifecycle-viewmodel:{strictly 2.2.0-alpha01} -> 2.2.0-alpha01 (c)
+--- androidx.activity:activity:{strictly 1.0.0-alpha05} -> 1.0.0-alpha05 (c)
+--- androidx.savedstate:savedstate:{strictly 1.0.0-alpha02} -> 1.0.0-alpha02 (c)
+--- androidx.lifecycle:lifecycle-process:{strictly 2.2.0-alpha01} -> 2.2.0-alpha01 (c)
+--- androidx.lifecycle:lifecycle-service:{strictly 2.2.0-alpha01} -> 2.2.0-alpha01 (c)
+--- androidx.lifecycle:lifecycle-viewmodel-ktx:{strictly 2.1.0-alpha02} -> 2.1.0-alpha02 (c)
+--- org.jetbrains.kotlinx:kotlinx-coroutines-android:{strictly 1.1.1} -> 1.1.1 (c)
+--- org.jetbrains.kotlinx:kotlinx-coroutines-core:{strictly 1.1.1} -> 1.1.1 (c)
+--- org.jetbrains.kotlinx:kotlinx-coroutines-core-common:{strictly 1.1.1} -> 1.1.1 (c)
+--- androidx.appcompat:appcompat:{strictly 1.0.2} -> 1.0.2 (c)
+--- androidx.cursoradapter:cursoradapter:{strictly 1.0.0} -> 1.0.0 (c)
+--- androidx.legacy:legacy-support-core-utils:{strictly 1.0.0} -> 1.0.0 (c)
+--- androidx.documentfile:documentfile:{strictly 1.0.0} -> 1.0.0 (c)
+--- androidx.localbroadcastmanager:localbroadcastmanager:{strictly 1.0.0} -> 1.0.0 (c)
+--- androidx.print:print:{strictly 1.0.0} -> 1.0.0 (c)
...
+--- androidx.room:room-runtime:{strictly 2.1.0-rc01} -> 2.1.0-rc01 (c)
+--- androidx.room:room-common:{strictly 2.1.0-rc01} -> 2.1.0-rc01 (c)
+--- androidx.sqlite:sqlite-framework:{strictly 2.0.1} -> 2.0.1 (c)
+--- androidx.sqlite:sqlite:{strictly 2.0.1} -> 2.0.1 (c)
+--- com.jakewharton.timber:timber:{strictly 4.7.1} -> 4.7.1 (c)
+--- org.jetbrains.kotlin:kotlin-android-extensions-runtime:1.3.30
|    \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.30
|         \--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.30
+--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.30
...
+--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.1 (*)
+--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.1 (*)
+--- androidx.room:room-runtime:2.1.0-rc01
|    +--- androidx.room:room-common:2.1.0-rc01
|    |    \--- androidx.annotation:annotation:1.1.0-rc01
|    +--- androidx.sqlite:sqlite-framework:2.0.1
|    |    +--- androidx.annotation:annotation:1.0.2 -> 1.1.0-rc01
|    |    \--- androidx.sqlite:sqlite:2.0.1
|    |         \--- androidx.annotation:annotation:1.0.2 -> 1.1.0-rc01
|    +--- androidx.sqlite:sqlite:2.0.1 (*)
|    +--- androidx.arch.core:core-runtime:2.0.1 -> 2.1.0-beta01 (*)
|    +--- androidx.core:core:1.0.0 -> 1.1.0-alpha05 (*)
|    \--- androidx.collection:collection:1.0.0 -> 1.1.0-alpha03 (*)

尝试将文件室版本更新为“2.1.0-rc01”


从初始查找中,您的某些依赖项是旧的。请尝试我运行并测试的以下安装程序

Android Studio:3.4.1

build.gradle(项目)

build.gradle(应用程序)


您注释掉了
room coroutines
依赖项,但我假设您没有更改实际实现。此依赖项未被删除,而是重命名为
room ktx
。因此只需添加它即可启用room的Coroutine支持


我们试着尝试以下几点:

删除所有与文件室相关的依赖项,这些依赖项是最新的,根据:

第二件事是,您正在复制不同版本的依赖关系,当生成系统尝试执行依赖性解决方案并导致误导性错误时,可能会遇到问题,例如:

   implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0-alpha01'
   implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.0.0'
一个就足够了,最好是稳定的


如果您需要关于依赖项的信息,并且需要将一些依赖项迁移到androidx,因为这里无法编译这些依赖项,那么这是一个小小的(希望是暂时的)工作

如果您将gradle版本切换回
3.3.2
android studio应该编译一个普通版本,您可以保留所有其他依赖项,或者更新它们

该设置对我有效:

    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.0'
        classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.9.0"
        classpath 'io.fabric.tools:gradle:1.+'
    }

我遇到了同样的问题,比较OP的gradle文件和我的,我发现两者都包含

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

通过删除它,文件室的注释处理开始工作。

我也遇到了同样的问题,我可以通过更新数据库版本来修复它:

@Database(
    entities = [...],
    version = 4, exportSchema = true
)

问题是因为自动生成的架构,另一种解决方案可能是删除项目中
schemas
文件夹中的旧架构,但如果您的应用程序正在生产中,则可能会造成一些问题。

也有类似的问题,下面的注释排除在依赖项下(不知道为什么)

删除了它,它就工作了。也许这对你有帮助?

也有同样的问题。 在我从github获取项目后发生。
依赖项/版本更改没有影响。
我所做的是删除GitHub上除主分支以外的所有分支,并从其余分支创建新项目。

问题已开箱即用。

您必须包括库:

implementation org.jetbrains:annotations-java5:19.0.0
因为通过
kapt
插件从注释中生成的代码使用
org.jetbrains.annotations.NotNull
注释

如果您复制粘贴生成的java类是您的类路径,您将看到编译错误



干杯

谢谢你的建议,我尝试过更新它,似乎已经删除了上面的一些问题,但不是全部,“AppDatabase.java:8:error:'同上'“仍然存在。@cfl-更新后是否尝试在android studio中使缓存无效并重新启动?是的,谢谢。我真的在这个问题上浪费了很多时间,感谢你迄今为止的投入。如果你还有别的事,请告诉我suggestions@cfl-删除应用插件:'kotlin kapt'和clean and sync project。谢谢,我删除了它-但同样的问题正在发生。我做了所有的清洁等出于兴趣什么导致你建议删除?我认为有必要这样做,删除
build
.gradle
.idea
文件夹。“不要生成项目,请单击“使缓存无效”并重新启动。@谢谢,但这没有帮助,仍然是相同的问题。@cfl您能共享您的gradle文件吗?”?另外,您是否尝试运行:
/gradlew app:dependencies
以查看依赖关系树。你能分享一下这个问题的结果吗?@raxerz谢谢,我对这个问题做了修改。它超出了字符限制,所以不得不删除一些代码,试图只删除似乎不相关的代码。如果以上这些都不起作用,你会添加更多的内容。当你用AndroidStudio打开有问题的类时,你会看到任何错误吗。无论如何,它也可能与KAPT的全局缓存有关。它是否可以在某些CI上使用完全干净的构建?更改了导航渐变安全参数、生命周期视图模型和房间版本。其他的都一样。遗憾的是,仍然有相同的问题,我清洁等。谢谢。这个版本对你有用吗?这太糟糕了。不过我很感激。我将继续尝试围绕此设置进行其他更改。希望一切顺利。你能试着下载新的Android Studio并从头开始设置一切吗?同时删除您为该建议创建的.android&.gradle文件夹。我试过了,仍然有同样的问题。@cfl请帮我最后一个忙,请将项目上载到github,不要使用任何.xml和.java/.kt文件。我想在我的系统中运行完全相同的项目。谢谢@tynn我们没有使用它,但可能在将来。但知道我没能解决我的问题很有用。谢谢你,可惜我的问题没有解决。谢谢你。希望它能帮助其他人。我真的以为我已经删除了这个,但它是在另一个项目的窗口中。谢谢,这对我有帮助。我还删除了我所有的房间依赖项,一个接一个地添加它们,结果发现我不再需要其中的一半。提示:如果您需要
roomktx
进行协作,那么它将其他大部分内容作为可传递的依赖项。我的房间现在只有两行:
roomktx
   implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0-alpha01'
   implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.0.0'
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.0'
        classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.9.0"
        classpath 'io.fabric.tools:gradle:1.+'
    }
configurations {
    cleanedAnnotations
    compile.exclude group: 'org.jetbrains', module: 'annotations'
}
@Database(
    entities = [...],
    version = 4, exportSchema = true
)
configurations {
    compile.exclude group: 'org.jetbrains', module: 'annotations'
}
implementation org.jetbrains:annotations-java5:19.0.0