2017-09-05 68 views
1
符号间

我使用过Android Studio 3.0 Beta 2中有以下gradle这个设置客房持久性库:无法解析

我可以搜索RxRoom但目前没有房类。按照指令Add Components,我不能在我的Fragment中使用Room类。

该课程在单独模块中,应用程序模块不包含任何房间库依赖项。

错误在IDE中显示“无法解析符号空间”。

enter image description here

的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" 
} 

更新 我已经试过了房间图书馆第一降级到alpha8和客房类现在回来了。我不知道为什么这个类在alpha9中消失了,但至少它是解决方法。

回答

2

一周试用后,我发现我可以运行APK即使我有编译时错误。我试图通过以下方式解决该问题,以解决编译错误。

变化

annotationProcessor "android.arch.persistence.room:compiler:1.0.0-alpha9" 

implementation "android.arch.persistence.room:compiler:1.0.0-alpha9" 

,并添加以下Disable the error check from Migrate to Android Plugin for Gradle 3.0

javaCompileOptions { 
    annotationProcessorOptions { 
     includeCompileClasspath = true 
    } 
} 
0

请改变从implementation所有Room依赖到api中的build.gradle

+0

我改变了运行时间和rxjava2是 “API”,但没有运气 –

相关问题