添加库Room Persistence时出错

时间:2017-07-26 18:19:09

标签: android

我开始使用房间持久性

我在gradle中添加了房间,出现了以下错误:

  

错误:无法解决:annotationProcessor
    href =" openFile:C:/.../ app / build.gradle">打开文件

同步gradle

时出现此错误

如何解决此问题?

这是gradle项目:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        maven { url 'https://maven.google.com' }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

app gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.0"
    dataBinding {
        enabled = true
    }
    defaultConfig {
        applicationId "com.app.bob.app"
        minSdkVersion 22
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.3.0'
    compile 'com.android.support:support-annotations:25.3.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.squareup.retrofit2:retrofit:2.3.0'
    compile 'com.google.code.gson:gson:2.8.0'
    compile 'com.squareup.retrofit2:converter-gson:2.3.0'
    compile 'com.android.support:support-v4:25.3.0'
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:recyclerview-v7:25.3.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.jakewharton:butterknife:8.7.0'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.7.0'
    compile 'com.android.support:cardview-v7:25.3.0'
    compile 'android.arch.persistence.room:runtime: 1.0.0-alpha5'
    annotationProcessor 'android.arch.persistence.room:compiler: 1.0.0-alpha5'
    compile 'android.arch.lifecycle:runtime:1.0.0-alpha5'
    compile 'android.arch.lifecycle:extensions:1.0.0-alpha5'
    annotationProcessor 'android.arch.lifecycle:compiler:1.0.0-alpha5'
    testCompile 'android.arch.persistence.room:testing:1.0.0-alpha5'
    compile 'android.arch.persistence.room:rxjava2:1.0.0-alpha5'
}

1 个答案:

答案 0 :(得分:0)

compile值中删除所有空格。 IOW,替换:

compile 'android.arch.persistence.room:runtime: 1.0.0-alpha5'
annotationProcessor 'android.arch.persistence.room:compiler: 1.0.0-alpha5'

使用:

compile 'android.arch.persistence.room:runtime:1.0.0-alpha5'
annotationProcessor 'android.arch.persistence.room:compiler:1.0.0-alpha5'