当我 运行 我的项目时,为什么会出现 cardview 错误?

Why do I get a cardview error when I run my project?

我在互联网上获得了一个源代码,我尝试 运行 它,但是我得到了这个错误。((错误:未能解决:cardview 受影响的模块:应用程序))我如何解决这个错误? 以下代码是我的 build.gradle(madule:app),我尝试其他版本的库并更新 android studio 即使我尝试删除我项目中的每个 cardview,但仍然有错误。

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion "30.0.1"
    defaultConfig {
        applicationId "com.example.ecommerce"
        minSdkVersion 23
        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 'com.google.firebase:firebase-core:17.4.4'
    implementation 'com.google.firebase:firebase-database:19.3.1'
    implementation 'com.google.firebase:firebase-storage:19.1.1'
    implementation 'com.firebaseui:firebase-ui-database:3.2.2'
    implementation 'com.squareup.picasso:picasso:2.71828'
    implementation 'com.github.rey5137:material:1.2.5'
    //implementation 'com.android.support:cardview-v7:29.1.1'
    //implementation 'com.android.support:recyclerview-v7:29.1.1'
    implementation "androidx.cardview:cardview:1.0.0"
    implementation 'androidx.recyclerview:recyclerview:1.1.0'
    implementation 'io.paperdb:paperdb:2.6'
    implementation 'com.android.support:design:29.1.1'
    implementation 'de.hdodenhof:circleimageview:2.2.0'
    implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.+'
    implementation 'com.cepheuen.elegant-number-button:lib:1.0.2'
    //implementation 'com.google.android.material:material:1.3.0-alpha01'
}

第一个:

您必须决定您的应用程序需要 Support LibraryAndroidX 的哪些依赖项。您已将支持库和 AndroidX 依赖项都添加到不正确的项目中。

无论如何,这是 Refactor 菜单中 Migrate to AndroidX 之后的右 build.gradle:

implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.firebase:firebase-core:17.4.4'
implementation 'com.google.firebase:firebase-database:19.3.1'
implementation 'com.google.firebase:firebase-storage:19.1.1'
implementation 'com.firebaseui:firebase-ui-database:3.2.2'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.github.rey5137:material:1.2.5'
implementation "androidx.cardview:cardview:1.0.0"
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'io.paperdb:paperdb:2.6'
implementation 'com.google.android.material:material:1.1.0'
implementation 'de.hdodenhof:circleimageview:3.1.0'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.0'
implementation 'com.cepheuen.elegant-number-button:lib:1.0.2'

第二个:

((ERROR: Failed to resolve: cardview Affected Modules: app)

这是因为它无法从 maven 或任何其他存储库下载所需的库,这主要是由您的 IP 限制引起的。