android.support.v7.widget.CardView could not be found (Android Studio 1.1 Preview)

后端 未结 7 1688
既然无缘
既然无缘 2020-12-10 00:22

\"enter

I\'m trying to add CardView to my activity as the official sample. But it does

7条回答
  •  难免孤独
    2020-12-10 01:15

    Writing my answer to provide:

    1) updated version for compileSdkVersion 27.

    2) usage of implementation instead of compile - What's the difference between implementation and compile in Gradle?.

    3) a complete version number to heed the Avoid using + in version numbers; can lead to unpredictable and unrepeatable builds.., warning shown by Android Studio.

    4) a visual for location of build.gradle (Module:app).

    5) And because I was not able to write a comment below @Eun's answer.


    You need to paste implementation 'com.android.support:cardview-v7:27.1.1' in build.gradle [Module:app] located at, for example: MyFirstApplication -> app -> build.gradle

    Paste in following dependencies clause:

    dependencies {
       implementation fileTree(dir: 'libs', include: ['*.jar'])
       ...
       implementation 'com.android.support:appcompat-v7:27.1.1'
    
    
       implementation 'com.android.support:cardview-v7:27.1.1'
    
    
       ...
    }
    


    To open from Android studio itself: (From left side) 1:Project -> Select Android view -> Gradle Scripts -> build.gradle (Module: app)

    That is:
    (If the image below is not shown You can find the image here.



    Using Android Studio 3.1.4

    Edit: Updated version numbers.

提交回复
热议问题