当我将Room Library添加到我的项目中时,收到“无法解决:support-core-utils”

时间:2018-08-18 11:03:13

标签: java android android-room

我有一个使用SQLiteOpenHelper在数据库和应用程序之间进行通信的现有应用程序,但是我决定迁移到Room。我尝试了所有添加Room组件的方法,但是所有这些都使我返回相同的错误,即我创建了一个新项目并实现了Room库并正常工作!但是在这个有SQLiteOpenHelper的项目中,我给出了错误。当我添加Room Library Code时,我收到此错误:

Failed to resolve: support-core-utils

和我添加Room组件的build.gradle(module):

apply plugin: 'com.android.application'
android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.example.yasin.taksmssender"
        minSdkVersion 15
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        // used by Room, to test migrations
        javaCompileOptions {
            annotationProcessorOptions {
                arguments = ["room.schemaLocation":
                                     "$projectDir/schemas".toString()]
            }
        }
        sourceSets {
            androidTest.assets.srcDirs +=
                    files("$projectDir/schemas".toString())
        }
    }
    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'
    implementation 'com.android.support:support-v4:27.1.1'
    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'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.android.support:recyclerview-v7:27.1.1'
    implementation 'com.android.support:cardview-v7:27.1.1'
    implementation 'de.hdodenhof:circleimageview:2.2.0'
    implementation 'com.squareup.okhttp3:okhttp:3.7.0'
    implementation 'com.github.pchmn:MaterialChipsInput:1.0.8'
    implementation 'com.github.PhilJay:MPAndroidChart:v2.2.4'
    implementation 'pub.devrel:easypermissions:1.1.3'

// Room components
    implementation "android.arch.persistence.room:runtime:$rootProject.roomVersion"
    annotationProcessor "android.arch.persistence.room:compiler:$rootProject.roomVersion"
    androidTestImplementation "android.arch.persistence.room:testing:$rootProject.roomVersion"
}

和build.gradle(项目):

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

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.4'


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

ext {
    roomVersion = '1.1.1'
    archLifecycleVersion = '1.1.1'
}   
allprojects {
    repositories {
        google()
        jcenter()
        maven { url "https://jitpack.io" }
    }
}

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

2 个答案:

答案 0 :(得分:0)

原因可能是Room不支持support-core-utils 27.1.1,而是支持26.1.0。

https://mvnrepository.com/artifact/android.arch.persistence.room/runtime/1.1.1

答案 1 :(得分:-1)

通过更改解决了此问题

alter profile senior_claim_analyst limit
connect_time 180000
sessions_per_user 2
idle_time 30;