2017-09-05 121 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」,但沒有運氣 –

相關問題