I've been building an app and it's been working well until I updated to the latest Android Studio. I've been getting the error " android.support.v7.widget.CardView (Fix Build Path, Edit XML, Create Class)" My cardview doesn't show the image. The app compiles well and installs to my phone but crashes on start up. And it was working fine yesterday. I have the lastest dependencies and I don't know why my cardviewer isn't working. Any solution? Do I need to downgrade the sdkversion? I've looked everywhere and followed a lot of fixes and now I'm literally pulling my hair off trying to get this one error to be fixed. Changing the currently dependencies to match the buildToolsVersion doesn't seem to work either.
XML
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Suicune">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg"
android:orientation="vertical"
android:weightSum="12">
<GridLayout
android:id="@+id/mainGrid"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="6"
android:alignmentMode="alignMargins"
android:columnCount="1"
android:columnOrderPreserved="false"
android:padding="14dp"
android:rowCount="3">
<!-- Row 1 -->
<!-- Column 1 -->
<android.support.v7.widget.CardView
android:layout_width="1dp"
android:layout_height="1dp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_marginLeft="90dp"
android:layout_marginRight="90dp"
android:layout_marginBottom="16dp"
app:cardCornerRadius="5dp"
app:cardElevation="8dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_vertical"
android:layout_margin="0dp"
android:orientation="vertical">
<ImageView
android:id="@+id/suicuneframedata_button"
android:layout_width="wrap_content"
android:scaleType="fitXY"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="@drawable/framedata_button" />
</LinearLayout>
</android.support.v7.widget.CardView>
<!-- Column 2 -->
<android.support.v7.widget.CardView
android:layout_width="1dp"
android:layout_height="1dp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_marginLeft="90dp"
android:layout_marginRight="90dp"
android:layout_marginBottom="16dp"
app:cardCornerRadius="5dp"
app:cardElevation="8dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_vertical"
android:layout_margin="0dp"
android:orientation="vertical">
<ImageView
android:id="@+id/suicunecombosheets_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:layout_gravity="center_horizontal"
android:src="@drawable/combosheets_button" />
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="1dp"
android:layout_height="1dp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_marginLeft="90dp"
android:layout_marginRight="90dp"
android:layout_marginBottom="16dp"
app:cardCornerRadius="5dp"
app:cardElevation="8dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_vertical"
android:layout_margin="0dp"
android:orientation="vertical">
<ImageView
android:id="@+id/suicunenotableplayers_button"
android:layout_width="wrap_content"
android:scaleType="fitXY"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="@drawable/notableplayers_button" />
</LinearLayout>
</android.support.v7.widget.CardView>
</GridLayout>
</LinearLayout>
Java Class
package com.example.sayafkadam.ptdxassault;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import androidx.appcompat.app.AppCompatActivity;
public class Suicune extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_suicune);
getSupportActionBar().setTitle("Suicune Database");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
ImageView FrameData;
ImageView ComboSheets;
ImageView NotablePlayers;
FrameData = (ImageView) findViewById(R.id.suicuneframedata_button);
FrameData.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intentLoadSuicuneInfo = new Intent(Suicune.this,
SuicuneFD.class);
startActivity(intentLoadSuicuneInfo);
}
});
NotablePlayers = (ImageView) findViewById(R.id.suicunenotableplayers_button);
NotablePlayers.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intentLoadNotablePlayers = new Intent(Suicune.this,
SuicuneNP.class);
startActivity(intentLoadNotablePlayers);
}
});
}
}
My Gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.sayafkadam.ptdxassault"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
buildToolsVersion = '28.0.3'
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:gridlayout-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.github.chrisbanes:PhotoView:2.2.0'
implementation 'com.github.barteksc:android-pdf-viewer:3.1.0-beta.1'
implementation 'gr.pantrif:easy-android-splash-screen:0.0.1'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
}
Can you try using
implementation 'androidx.cardview:cardview:1.0.0'
Instead and
androidx.cardview.widget.CardView
In XML?