Lon*_*ger 3 android android-studio-3.0 android-room
我将Android Studio 3.0 Beta 2与以下gradle设置一起使用
我可以搜索RxRoom,但没有找到Room类。按照“ 添加组件”的说明进行操作后,我无法在Fragment中使用Room类。
此类位于单独的模块中,app模块不包含任何房间库依赖项。
该错误在IDE中显示为“无法解析符号房间”。
build.gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
javaCompileOptions {
annotationProcessorOptions {
arguments = ["room.schemaLocation":
"$projectDir/schemas".toString()]
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.0.2'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:26.0.2'
implementation 'com.android.support:support-v4:26.0.2'
implementation 'com.android.support:recyclerview-v7:26.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.1', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation "android.arch.persistence.room:runtime:1.0.0-alpha9"
annotationProcessor "android.arch.persistence.room:compiler:1.0.0-alpha9"
testImplementation "android.arch.persistence.room:testing:1.0.0-alpha9"
implementation "android.arch.persistence.room:rxjava2:1.0.0-alpha9"
}
Run Code Online (Sandbox Code Playgroud)
更新后, 我尝试先将会议室库降级为alpha8,然后再次返回Room类。我不知道为什么该类在alpha9中消失了,但至少是解决方法。
经过一周的试用,我发现即使出现编译时错误也可以运行apk。我试图通过以下方式解决该问题,以解决编译错误。
更改
annotationProcessor "android.arch.persistence.room:compiler:1.0.0-alpha9"
Run Code Online (Sandbox Code Playgroud)
至
implementation "android.arch.persistence.room:compiler:1.0.0-alpha9"
Run Code Online (Sandbox Code Playgroud)
并添加以下禁用从Gradle 3.0迁移到Android插件的错误检查
javaCompileOptions {
annotationProcessorOptions {
includeCompileClasspath = true
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5258 次 |
| 最近记录: |