【问题标题】:How can I add cardview to my android studio project?如何将 cardview 添加到我的 android studio 项目中?
【发布时间】:2020-04-27 07:11:57
【问题描述】:

这个问题困扰我很久了。 错误:无法解决:cardview 受影响的模块:app

    apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"

    defaultConfig {
        applicationId "com.example.self"
        minSdkVersion 24
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

}

    dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation 'androidx.cardview:cardview:1.0.0'
}

【问题讨论】:

  • 您可以查看正确答案

标签: android android-studio


【解决方案1】:

implementation 'com.google.android.material:material:1.1.0' 添加到您的依赖项中

【讨论】:

    【解决方案2】:

    导航到布局设计部分,然后在搜索(页面左侧)中选择 design oy 搜索卡片视图。如果没有下载,您会在它旁边找到一个下载符号。单击它,这将添加以下依赖项 com.google.android.material:material:1.0.0 就完成了。

    【讨论】:

      【解决方案3】:

      您可以在 build.gradle (Module:app)

      中添加 implementation "androidx.cardview:cardview:1.0.0" 此依赖项

      在您的布局文件中:

      <androidx.cardview.widget.CardView 
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools">
      
      </androidx.cardview.widget.CardView>
      

      【讨论】:

        猜你喜欢
        • 2017-12-11
        • 2020-01-02
        • 2019-02-19
        • 2013-05-11
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多