gpt4 book ai didi

java - 我在布局预览中遇到 Missing CLASSES 的问题

转载 作者:行者123 更新时间:2023-11-29 22:51:51 24 4
gpt4 key购买 nike

我遇到了缺课的问题。“找不到以下类(class):”让我恶心的消息。

我已经尝试了 stackoverflow 答案中的大多数答案,但它根本没有帮助。我使用导航栏项目创建文件,然后将我的文件应用到 Firebase。

我尝试更改依赖项和样式文件。 这是我的依赖项:

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'androidx.constraintlayout:constraintlayout: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.google.firebase:firebase-analytics:17.2.0'
implementation 'com.firebaseui:firebase-ui-auth:4.3.1'
implementation 'com.google.firebase:firebase-messaging:20.0.0'
implementation 'com.google.firebase:firebase-auth:19.0.0'
implementation 'com.google.android.gms:play-services-auth:17.0.0'

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'androidx.constraintlayout:constraintlayout: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.google.firebase:firebase-analytics:17.2.0'
implementation 'com.firebaseui:firebase-ui-auth:4.3.1'
implementation 'com.google.firebase:firebase-messaging:20.0.0'
implementation 'com.google.firebase:firebase-auth:19.0.0'
implementation 'com.google.android.gms:play-services-auth:17.0.0'

这是我的样式代码

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>

<style name="AppTheme.AppBarOverlay"
parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

我已经将 Apptheme 部分 Theme.App 更改为 Base.Theme.App

并且还尝试将文件无效的缓存/重启方法

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'androidx.constraintlayout:constraintlayout: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.google.firebase:firebase-analytics:17.2.0'
implementation 'com.firebaseui:firebase-ui-auth:4.3.1'
implementation 'com.google.firebase:firebase-messaging:20.0.0'
implementation 'com.google.firebase:firebase-auth:19.0.0'
implementation 'com.google.android.gms:play-services-auth:17.0.0'

这是xml文件

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
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:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">

<include
layout="@layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />

<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer" />

</android.support.v4.widget.DrawerLayout>

这些是我的错误信息。它在预览错误中给出。

找不到以下类:- android.support.constraint.ConstraintLayout( 向项目添加约束布局库依赖项,修复构建路径,编辑 XML,创建类)- android.support.design.widget.AppBarLayout(修复构建路径、编辑 XML、创建类)- android.support.design.widget.CoordinatorLayout(修复构建路径、编辑 XML、创建类)- android.support.design.widget.FloatingActionButton(修复构建路径、编辑 XML、创建类)- android.support.design.widget.NavigationView(修复构建路径、编辑 XML、创建类)- android.support.v4.widget.DrawerLayout(修复构建路径、编辑 XML、创建类)- android.support.v7.widget.Toolbar(修复构建路径、编辑 XML、创建类)

我可以尝试解决这个问题吗?还是我必须重置所有内容?

最佳答案

implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

然后阅读 AndroidX .

您的 XML 将 -->

 <androidx.constraintlayout.widget.ConstraintLayout
<com.google.android.material.navigation.NavigationView
<androidx.cardview.widget.CardView
<androidx.appcompat.widget.Toolbar
<com.google.android.material.appbar.AppBarLayout
<androidx.coordinatorlayout.widget.CoordinatorLayout

The following classes could not be found: - android.support.constraint.ConstraintLayout

然后使用

 implementation 'com.android.support.constraint:constraint-layout:1.1.2'

关于java - 我在布局预览中遇到 Missing CLASSES 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57823345/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com