I am following this tutorial for Android app : https://www.youtube.com/watch?v=wW-AAXOy4u4
I added a list that may contain some items; For each item, I want it to be a Card. Created the card, imported dependencies in build.gradle:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.core:core-ktx:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.squareup:android-times-square:1.6.5@aar'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation 'com.google.android.material:material:1.2.0-alpha01'
implementation 'androidx.cardview:cardview:1.0.0'
}
as suggested here: android.support.v7.widget.CardView could not be found (Android Studio 1.1 Preview)
Nevertheless, I still get the "android.support.v7.widget.CardView could not be found" error.
The error that I get:
The following classes could not be found:
- android.support.v7.widget.CardView (Fix Build Path, Edit XML, Create
Class)
Tip: Try to build the project. Tip: Try to refresh the layout.
Here is my main_activity_single_item code:
<android.support.v7.widget.CardView
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:background="@color/colorAccent"
android:elevation="4dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_width="80dp"
android:layout_height="105dp"
android:id="@+id/ivMain"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tvMain"
android:textStyle="bold"
android:layout_toRightOf="@+id/ivMain"
android:layout_marginLeft="6dp"
android:layout_toEndOf="@+id/ivMain"
android:text="Timetable"
android:textSize="24sp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tvDescription"
android:layout_below="@+id/tvMain"
android:layout_toRightOf="@+id/ivMain"
android:layout_marginLeft="6dp"
android:text="Description"
android:textSize="16dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tvClick"
android:textSize="12dp"
android:text="click here"
android:layout_below="@+id/tvDescription"
android:layout_alignBottom="@+id/ivMain"/>
</RelativeLayout>
</android.support.v7.widget.CardView>
What I already tried:
changed in
res->value->styles
from <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
to <style name="AppTheme" parent="Base.Theme.AppCompat.Light.NoActionBar">
(error)
File .. Invalidate caches / restart
Build project
I work on Android Studio, my API version is 22
Can you please, share your insights on this issue ?
Please let me know if you need some extra information. Thank you very much.