android.support.v7.widget.CardView(修复构建路径,编辑 XML,创建 Class)使用 Android Studio 3.4
android.support.v7.widget.CardView (Fix Build Path, Edit XML, Create Class) Using Android Studio 3.4
我一直在构建一个应用程序,在我更新到最新的 Android Studio 之前它一直运行良好。我一直收到错误
“ android.support.v7.widget.CardView(修复构建路径,编辑 XML,创建 Class)”
我的 cardview 不显示图像。
该应用程序编译良好并安装到我的 phone 但在启动时崩溃。昨天它工作正常。我有最新的依赖项,但我不知道为什么我的 cardviewer 不工作。任何解决方案?我需要降级 sdk 版本吗?我到处查看并进行了很多修复,现在我真的很努力地试图修复这个错误。更改当前依赖项以匹配 buildToolsVersion 似乎也不起作用。
A picture of my error
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);
}
});
}
}
我的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'
}
你可以尝试使用
implementation 'androidx.cardview:cardview:1.0.0'
而是
androidx.cardview.widget.CardView
在XML?
我一直在构建一个应用程序,在我更新到最新的 Android Studio 之前它一直运行良好。我一直收到错误 “ android.support.v7.widget.CardView(修复构建路径,编辑 XML,创建 Class)” 我的 cardview 不显示图像。 该应用程序编译良好并安装到我的 phone 但在启动时崩溃。昨天它工作正常。我有最新的依赖项,但我不知道为什么我的 cardviewer 不工作。任何解决方案?我需要降级 sdk 版本吗?我到处查看并进行了很多修复,现在我真的很努力地试图修复这个错误。更改当前依赖项以匹配 buildToolsVersion 似乎也不起作用。
A picture of my error
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);
}
});
}
}
我的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'
}
你可以尝试使用
implementation 'androidx.cardview:cardview:1.0.0'
而是
androidx.cardview.widget.CardView
在XML?