无法解决房间依赖性

时间:2018-06-21 05:57:11

标签: java android gradle android-gradle

我想在我的项目中添加以下依赖项:

1.compile "android.arch.persistence.room:runtime:1.0.0"
2.annotationProcessor "android.arch.persistence.room:compiler:1.0.0"

但是我的项目无法解析':app @ debug / compileClasspath'的依赖关系:无法解析android.arch.persistence.room:runtime:1.0.0。 以下文字显示了我的build.gradle

apply plugin: 'com.android.application'

android {
 compileSdkVersion 27
 defaultConfig {
     applicationId "com.smm.room"
     minSdkVersion 17
     targetSdkVersion 27
     versionCode 1
     versionName "1.0"
     testInstrumentationRunner 
 "android.support.test.runner.AndroidJUnitRunner"
 }
 buildTypes {
     release {
         minifyEnabled false
         proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
     }
 }
}

dependencies {
 implementation fileTree(dir: 'libs', include: ['*.jar'])
 implementation 'com.android.support:appcompat-v7:27.1.1'
 implementation 'com.android.support.constraint:constraint-layout:1.1.2'
 testImplementation 'junit:junit:4.12'
 androidTestImplementation 'com.android.support.test:runner:1.0.2'
 androidTestImplementation 'com.android.support.test.espresso:espresso- 
core:3.0.2'

 compile "android.arch.persistence.room:runtime:1.0.0"
 annotationProcessor "android.arch.persistence.room:compiler:1.0.0"
}

2 个答案:

答案 0 :(得分:1)

将两者均更新为 1.1.1版本,例如:

outputFilePath

尝试以下代码:

Factory Method

您的项目爷爷应该像这样:

Audit auditLogger = LoggingFactory.createAuditLogger(outputfilepath);

答案 1 :(得分:1)

我遇到了同样的问题,并通过以下方法解决了

1.-取消选中设置中的离线工作

2.-添加allprojects->repositories-> maven { url 'https://dl.google.com/dl/android/maven2/'}。

3.- repositories-> mavenCentral()

4.-依赖关系如下:

def room_version = "1.1.1"

implementation "android.arch.persistence.room:runtime:$room_version"
annotationProcessor "android.arch.persistence.room:compiler:$room_version"

// optional - RxJava support for Room
implementation "android.arch.persistence.room:rxjava2:$room_version"

// optional - Guava support for Room, including Optional and ListenableFuture
implementation "android.arch.persistence.room:guava:$room_version"

// Test helpers
testImplementation "android.arch.persistence.room:testing:$room_version"