Android,Anko cardView不可用-未解决的参考:cardView

时间:2018-09-22 16:43:05

标签: android android-studio kotlin android-cardview anko

我是Android的新手,用Kotlin编写应用程序并用Anko生成视图。

我想使用cardView的anko版本,但是android studio将其突出显示为红色,并显示错误unresolved reference: cardView。如果按alt + Enter,则没有添加导入的选项。为什么我看不到任何想法?

下面是我的项目的build.gradle文件。

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'org.jetbrains.kotlin.android.extensions'

android {
    compileSdkVersion 28
    buildToolsVersion '27.0.3'
    defaultConfig {
        applicationId "uk.co.datakitchen.room7"
        minSdkVersion 15
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    androidExtensions {
        experimental = true
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    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:recyclerview-v7:28.0.0-rc02'
    implementation 'com.android.support:cardview-v7:23.0.+'

    implementation "org.jetbrains.anko:anko:$anko_version"
    // Anko Commons
    implementation "org.jetbrains.anko:anko-commons:$anko_version"

    // Anko Layouts
    implementation "org.jetbrains.anko:anko-sdk25:$anko_version" // sdk15, sdk19, sdk21, sdk23 are also available
    implementation "org.jetbrains.anko:anko-appcompat-v7:$anko_version"

    // Coroutine listeners for Anko Layouts
    implementation "org.jetbrains.anko:anko-sdk25-coroutines:$anko_version"
    implementation "org.jetbrains.anko:anko-appcompat-v7-coroutines:$anko_version"
}

1 个答案:

答案 0 :(得分:1)

删除此行: 实施'com.android.support:cardview-v7:23.0。+'

添加此行: 实现“ org.jetbrains.anko:anko-cardview-v7:$ anko_version”