我不断地发现以下错误:
\AppDatabase_Impl.java:66: error: onCreate(SupportSQLiteDatabase) in <anonymous com.mgr.data.AppDatabase_Impl$1> cannot override onCreate(SupportSQLiteDatabase) in Delegate
protected void onCreate(SupportSQLiteDatabase _db) {
^
attempting to assign weaker access privileges; was public
和,
error: onValidateSchema(SupportSQLiteDatabase) in <anonymous com.mgr.data.AppDatabase_Impl$1> cannot override onValidateSchema(SupportSQLiteDatabase) in Delegate
protected RoomOpenHelper.ValidationResult onValidateSchema(SupportSQLiteDatabase _db) {
^
attempting to assign weaker access privileges; was public
我不知道为什么这一切都会突然发生。我可以分享我的build.gradle (app)
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'kotlin-android'
id 'kotlin-kapt'
id 'dagger.hilt.android.plugin'
id 'org.jetbrains.kotlin.plugin.serialization'
}
android {
compileSdk 32
defaultConfig {
applicationId ""
minSdk 24
targetSdk 32
versionCode 1
versionName "0.8.3"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary true
}
javaCompileOptions {
annotationProcessorOptions {
arguments += [
"room.schemaLocation":"$projectDir/schemas".toString(),
"room.incremental":"true",
"room.expandProjection":"true"
]
}
}
}
buildTypes {
release {
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
freeCompilerArgs += [
"-opt-in=kotlin.RequiresOptIn"]
jvmTarget = '1.8'
}
buildFeatures {
compose true
viewBinding true
}
composeOptions {
kotlinCompilerExtensionVersion "1.2.0"
}
packagingOptions {
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
excludes += 'META-INF/gradle/incremental.annotation.processors'
}
}
kapt {
useBuildCache = true
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.5.0'
implementation "com.github.ireward:compose-html:1.0.2"
implementation 'com.google.dagger:hilt-android:2.43.2'
implementation "androidx.hilt:hilt-navigation-compose:1.0.0"
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation "androidx.compose.material:material:$compose_version"
implementation 'org.chromium.net:cronet-embedded:76.3809.111'
implementation 'com.google.dagger:hilt-compiler:2.43.2'
annotationProcessor 'com.google.dagger:hilt-compiler:2.43.2'
implementation "androidx.datastore:datastore-preferences:$datastore"
implementation "androidx.datastore:datastore-preferences-core:$datastore"
implementation "androidx.datastore:datastore:1.0.0"
implementation "org.jetbrains.kotlinx:kotlinx-collections-immutable:0.3.5"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.2"
// Coroutines
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines"
// Work
implementation "androidx.work:work-runtime-ktx:$work"
implementation "androidx.work:work-gcm:$work" // optional - GCMNetworkManager support
androidTestImplementation "androidx.work:work-testing:$work" // optional - Test helpers
implementation "androidx.work:work-multiprocess:$work" // optional - Multiprocessor support
// Navigation
implementation "androidx.navigation:navigation-fragment-ktx:$navigation"
implementation "androidx.navigation:navigation-ui-ktx:$navigation"
implementation "androidx.navigation:navigation-dynamic-features-fragment:$navigation"
// Testing Navigation
androidTestImplementation "androidx.navigation:navigation-testing:$navigation"
// Jetpack Compose Integration
implementation "androidx.navigation:navigation-compose:$navigation"
// status bar customization
implementation "com.google.accompanist:accompanist-systemuicontroller:0.23.1"
// Accompanist
implementation "com.google.accompanist:accompanist-pager:$accompanist" // Pager
implementation "com.google.accompanist:accompanist-pager-indicators:$accompanist" // Pager Indicators
implementation "com.google.accompanist:accompanist-flowlayout:$accompanist"
implementation "com.google.accompanist:accompanist-navigation-animation:$accompanist"
implementation "com.google.accompanist:accompanist-swiperefresh:$accompanist"
implementation "androidx.recyclerview:recyclerview:$rcview"
// For control over item selection of both touch and mouse driven selection
implementation "androidx.recyclerview:recyclerview-selection:$rcview_select"
// Card view
implementation "androidx.cardview:cardview:1.0.0"
// Extensions = ViewModel + LiveData
implementation "android.arch.lifecycle:extensions:1.1.1"
kapt "android.arch.lifecycle:compiler:1.1.1"
//Room
implementation "androidx.room:room-runtime:$room"
kapt "androidx.room:room-compiler:$room"
implementation "androidx.room:room-ktx:$room"
implementation "android.arch.persistence.room:runtime:1.1.1"
kapt "android.arch.persistence.room:compiler:1.1.1"
// optional - Kotlin Extensions and Coroutines support for Room
implementation("androidx.room:room-ktx:$room")
// optional - RxJava2 support for Room
implementation("androidx.room:room-rxjava2:$room")
// optional - RxJava3 support for Room
implementation("androidx.room:room-rxjava3:$room")
// optional - Guava support for Room, including Optional and ListenableFuture
implementation("androidx.room:room-guava:$room")
// optional - Test helpers
testImplementation("androidx.room:room-testing:$room")
//implementation "androidx.paging:paging-runtime:3.1.1"
implementation 'androidx.paging:paging-compose:1.0.0-alpha15'
// optional - Paging 3 Integration
implementation "androidx.room:room-paging:2.5.0-alpha02"
// Google Sign In Integration
implementation "com.google.android.gms:play-services-auth:20.2.0"
implementation 'androidx.core:core-ktx:1.8.0'
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.animation:animation-graphics:$compose_version"
implementation "androidx.compose.material3:material3:$material3"
implementation "androidx.compose.material3:material3-window-size-class:$material3"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle"
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$lifecycle"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle"
implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:$lifecycle"
kapt "androidx.lifecycle:lifecycle-compiler:$lifecycle"
// optional - helpers for implementing LifecycleOwner in a Service
implementation "androidx.lifecycle:lifecycle-service:$lifecycle"
// optional - ProcessLifecycleOwner provides a lifecycle for the whole application process
implementation "androidx.lifecycle:lifecycle-process:$lifecycle"
// optional - ReactiveStreams support for LiveData
implementation "androidx.lifecycle:lifecycle-reactivestreams-ktx:$lifecycle"
// optional - Test helpers for LiveData
testImplementation "androidx.arch.core:core-testing:2.1.0"
// optional - Test helpers for Lifecycle runtime
testImplementation "androidx.lifecycle:lifecycle-runtime-testing:$lifecycle"
implementation "androidx.fragment:fragment-ktx:1.5.1"
implementation "androidx.activity:activity-ktx:1.5.1"
// https://github.com/Bryanx/themed-toggle-button-group
implementation "nl.bryanderidder:themed-toggle-button-group:1.4.1"
implementation 'androidx.activity:activity-compose:1.5.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"
implementation "io.github.vanpra.compose-material-dialogs:datetime:0.7.2"
}
遗憾的是,我不知道是什么导致了这一切。这是潜在的许可问题吗?我需要编辑应用程序清单文件吗?我真的被困在这里了。我试图在我的应用程序中使用Room数据库,我使用Kotlin和Jetpack Compose。到目前为止,我读了多条线索,但没有帮到我。
发布于 2022-08-27 22:21:42
在更新依赖项/添加撰写时,我只是遇到了同样的问题。这种依赖似乎是一个问题:
implementation "androidx.room:room-paging:2.5.0-alpha02"
尝试更改为最新的稳定版本:
implementation "androidx.room:room-paging:2.4.3"
我已经发现,对于Kotlin + Room + Hilt 1.6.10来说,我目前可以在我的项目中使用Kotlin版本。
因此,在项目级别的build.gradle:
buildscript { ext.kotlin_version = "1.6.10" }
和
dependencies { classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10 }'
还在应用程序build.gradle中添加"android“块(这与Kotlin 1.6.10兼容):
composeOptions { kotlinCompilerExtensionVersion '1.1.0' }
https://stackoverflow.com/questions/73496496
复制相似问题