ste*_*ood 5 java android android-room
我正在开发一个Android库,并希望在其中使用新的Android Room持久性库.但是,在启动时我收到了这个错误:
Caused by: java.lang.RuntimeException: cannot find implementation for MyLibraryName.Database.QSDatabase. QSDatabase_Impl does not exist
at android.arch.persistence.room.Room.getGeneratedImplementation(Room.java:90)
这意味着annotationProcessor在编译期间不会生成额外的代码.
顺便说一句,当我将@Database代码放在app模块中时,一切正常.
我的gradle文件(库模块):
apply plugin: 'com.android.library'
apply plugin: 'groovyx.android'
buildscript {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'
classpath 'org.codehaus.groovy:groovy-android-gradle-plugin:1.1.0'
}
}
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
if (!requested.name.startsWith("multidex")) {
details.useVersion '25.3.0'
}
}
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets { main { java.srcDirs = ['src/main/java', 'src/main/groovy'] } }
}
dependencies {
// google Room persistence library
compile "android.arch.persistence.room:runtime:1.0.0-alpha1"
annotationProcessor "android.arch.persistence.room:compiler:1.0.0-alpha1"
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2',
{
exclude group: 'com.android.support', module: 'support-annotations'
})
// google location service
compile 'com.google.android.gms:play-services-location:10.2.4'
androidTestCompile 'junit:junit:4.12'
// Http
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.8.0'
compile 'com.squareup.retrofit2:converter-scalars:2.1.0'
// groovy
compile group: 'org.codehaus.groovy', name: 'groovy-all', version: '2.4.4'
}
Run Code Online (Sandbox Code Playgroud)
Abh*_*nav -1
@stevenwood 看来你对 groovy/ 的看法是对的
我有相同的项目结构。但就我而言,我在 groovy/ 中没有真正的 Groovy 代码。只有普通的旧 Java 代码。因此,通过进行以下更改,也许对我来说更容易让项目再次运行
删除/注释掉classpath 'org.codehaus.groovy:gradle-groovy-android-plugin:0.3.8' from the project's build.gradle
删除/注释掉apply plugin: 'groovyx.grooid.groovy-android' from the module's build.gradle
git mv groovy/ java/
至少从那以后,我就不再收到missing Database_ImplRoom 发来的消息了。
| 归档时间: |
|
| 查看次数: |
1438 次 |
| 最近记录: |