0

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

  • I think maybe somewhere use Material Card view. So that the problem can be occur. You can check [this answer](https://stackoverflow.com/a/57833454/6652743) Also check [this one](https://stackoverflow.com/a/53089654/6652743) for resolving this issue. – Nayan Sarder Jul 22 '20 at 17:27
  • tnx for your answer,i checked my xml layout, its correct but still have error,does it could have other solution? – Milad Javaheri Jul 22 '20 at 18:50
  • Post your layout and the full error. – Gabriele Mariotti Jul 22 '20 at 21:59
  • @ GabrieleMariotti ,i post my full project in Github,I would greatly appreciate it if you help me.this is link of my project.[link](https://github.com/miladjavaheri/eCommerce) – Milad Javaheri Jul 23 '20 at 23:03

1 Answers1

0

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.

ʍѳђઽ૯ท
  • 16,646
  • 7
  • 53
  • 108
  • tnx for your attention, i use VPN but it seemed the problem remain unsolved, and we should consider other possibilities? – Milad Javaheri Jul 23 '20 at 22:12
  • Have you tried updating your gradle to the latest version?: project level, build.gradle: `classpath 'com.android.tools.build:gradle:4.0.1'` Also make sure you didn't set the gradle to work in `offline mode`. – ʍѳђઽ૯ท Jul 24 '20 at 08:24
  • Thank you very much dear Mohsen, i update my gradle to 4.0.1 and its work. – Milad Javaheri Jul 24 '20 at 17:38