我的我的代码有错误
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'androidx.cardview:cardview:1.0.0'
和用于xml
<android.support.v7.widget.CardView
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="293dp"
app:cardBackgroundColor="@color/card"
app:cardCornerRadius="10dp"
app:cardElevation="5dp"
app:cardUseCompatPadding="true">
<TextView
android:id="@+id/textView4"
android:layout_width="432dp"
android:layout_height="510dp"
android:text="TextView" />
<WebView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:ignore="WebViewLayout" />
</android.support.v7.widget.CardView>
有了这行代码,应用程序停止了,我只尝试了依赖关系行,而我没有放置XML代码行,只有依赖关系实现cardview行和hid并没有停止,但是当我放行时应用程序停止的XML文件的代码集。
您的gradle文件中具有androidx
的CardView
版本:
implementation 'androidx.cardview:cardview:1.0.0'
但是您在布局文件中使用的是旧版本的CardView
:
<android.support.v7.widget.CardView ... />
您必须在两个版本中使用相同的版本。因此,用以下代码替换布局文件中的标记:
<androidx.cardview.widget.CardView ... />