你运行项目时为什么会出现卡片视图错误?

huangapple go评论102阅读模式
英文:

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

问题

I get a source code on the internet and I try to run it, but I get this error. ((错误: 无法解析: cardview 受影响的模块: app)) How can I solve this error?

以下是我的 build.gradle(module: 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'
}
英文:

i get a source code in internet and i try to run it, but i get this error.((ERROR: Failed to resolve: cardview Affected Modules: app))how i can solve this error?
the following code is my build.gradle(madule:app), i try other version of library and update android studio even i try to delete every cardview in my project, but still have error.

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'
}

答案1

得分: 0

First:

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

无论如何,在从“重构”菜单中“迁移到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'

Second:

> ((错误:无法解析:cardview 受影响的模块:应用程序)

这是因为它无法从Maven或任何其他仓库下载所需的库,这通常是由于您的IP限制引起的。

英文:

First:

You have to decide which dependencies of both Support Library or AndroidX you need in your application. You've added both Support Library and AndroidX dependencies to the project which is not correct.

Anyways, here is the right build.gradle after Migrate to AndroidX from Refactor menu:

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'

Second:

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

This is because it cannot download the needed libraries from maven or any other repositories which is mostly caused by your IP limitations.

huangapple
  • 本文由 发表于 2020年7月23日 01:10:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/63039657.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定