1

I am trying to import card view in java with android studio. I had tried several ways to fix this error but I couldn't fix this error if it's possible for you please help me. i add this code implementation 'com.android.support:cardview-v7:30.0.1' in dependencies in build.gradle(module:app).

but it gave me this error : Could not find cardview-1.0.0.jar (androidx.cardview:cardview:1.0.0). Searched in the following locations: https://dl.google.com/dl/android/maven2/androidx/cardview/cardview/1.0.0/cardview-1.0.0.jar

and when I remove this line from my code, it doesn't show me this error anymore.

i try yo replace that code with this code:

implementation 'androidx.cardview:cardview:1.0.0'

but I saw this error:

Failed to resolve: cardview-1.0.0 Affected Modules: app

and this is my build.gradle(Module: app)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 30
    buildToolsVersion '30.0.1'

    defaultConfig {
        applicationId "com.allamehelli3.second"
        minSdkVersion 21
        targetSdkVersion 30
        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.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
    implementation 'com.android.support:recyclerview-v7:30.0.1'
    implementation 'androidx.cardview:cardview:1.0.0'

    testImplementation 'junit:junit:4.13'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

    implementation 'com.google.code.gson:gson:2.8.6'

}'

P.S: i change this line 'implementation 'androidx.cardview:cardview:1.0.0'' to 'implementation 'com.android.support:cardview-v7:30.0.1'' but my problem didn't solve.

mohaka
  • 23
  • 6
  • 1
    can you please check if using `androidx.appcompat:appcompat:1.3.0-alpha02` instead of `androidx.appcompat:appcompat:1.2.0` solve the issue? also, make sure you use `androidx.cardview.widget.CardView` instead of `android.support.v7.widget.CardView` in the xml file. and I don't think using `com.android.support:cardview-v7:30.0.1` in gradle will help anymore. – ganjaam Sep 13 '20 at 04:45
  • although it might not answer your question directly, the answers to [this post](https://stackoverflow.com/q/53089633/8192914) might help you. – ganjaam Sep 13 '20 at 04:48
  • thanks for helping me but change my that line of code to 'androidx.appcompat:appcompat:1.3.0-alpha02' didn't help me. Is there any other solution for this problem? – mohaka Sep 13 '20 at 05:20
  • and also I haven't used this library in my XML files yet. – mohaka Sep 13 '20 at 05:22
  • remove dependency from gradle file and try to add cardview from direct xml like [this](https://drive.google.com/file/d/1PaJ8ee2SDuMWhkheF8zkTb8rgUnOzOIN/view?usp=sharing) right click on cardview or direct drag n drop it. – mr.volatile Sep 13 '20 at 06:34
  • thanks again for being very nice. I tried this solution but it gave me this error:Failed to resolve: cardview-1.0.0 Affected Modules: app – mohaka Sep 13 '20 at 07:52
  • i try to download it from there but it said to me that I should add it to my liabry and when I try to use it without adding the code (I mean drag and drop like you said)it shows me a dialog with this text : This operation requires the library androidx.cardview:cardview:+. Would you like to add this now? and when I press okay android studio automatically add the code to my dependencies and then it gave me the error which gave me last time – mohaka Sep 13 '20 at 07:56
  • In any case the support libraries v30 don't exist. – Gabriele Mariotti Sep 13 '20 at 08:05
  • thanks for helping me. but i change that line of my code to implementation 'androidx.cardview:cardview:1.0.0-alpha3' and my problem solve. – mohaka Sep 13 '20 at 08:56

0 Answers0