Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/413.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/239.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何修复Android Studio中的“缺少类”错误?_Java_Android_Xml - Fatal编程技术网

Java 如何修复Android Studio中的“缺少类”错误?

Java 如何修复Android Studio中的“缺少类”错误?,java,android,xml,Java,Android,Xml,当我尝试在Android Studio中进行新活动时 这些错误都会发生,在此错误之前,我创建了一些活动,通常没有任何错误: The following classes could not be found: - android.support.constraint.ConstraintLayout (    Add constraint-layout library dependency to the project, Fix Build Path, Edit XML, Create Class

当我尝试在Android Studio中进行新活动时 这些错误都会发生,在此错误之前,我创建了一些活动,通常没有任何错误:

The following classes could not be found:
- android.support.constraint.ConstraintLayout (    Add constraint-layout library dependency to the project, Fix Build Path, Edit XML, Create Class)
- android.support.design.widget.CoordinatorLayout (Fix Build Path, Edit XML, Create Class)
- android.support.v7.widget.Toolbar (Fix Build Path, Edit XML, Create Class)
依赖项库:


dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.android.support:support-v4:29.+'
    implementation 'com.android.support:design:29.+'
    implementation 'com.android.support:appcompat-v7:29.+'
    implementation 'com.android.support.constraint:constraint-layout: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 'com.google.android.material:material:1.0.0'
    implementation 'com.squareup.retrofit2:retrofit:2.0.2'
    implementation 'com.squareup.retrofit2:converter-gson:2.0.2'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'de.hdodenhof:circleimageview:3.0.0'
    implementation 'com.mikhaellopez:circularimageview:3.2.0'
    implementation 'com.google.android.gms:play-services-base:11.0.1'
    implementation 'com.google.android.gms:play-services-basement:11.0.1'
    implementation 'com.google.android.gms:play-services-safetynet:11.0.1'
    implementation 'com.google.android.gms:play-services-tasks:11.0.1'
}

看起来您正在尝试在同一项目中使用AndroidX库和支持库。从菜单迁移到AndroidX,它将替换包名和依赖项

您的项目正在添加来自支持库的小部件,而不是导致此问题的AndroidX

如果仍然出现错误,请替换列表中的旧包名称:

您将AndroidX依赖项与AppCompat混为一谈。要么从重构->迁移到AndroidX将其迁移到AndroidX,要么使用AppCompat

正如在代码中一样,您已经对约束布局使用了这两个依赖项。解决您的问题的最简单方法是删除该行

implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

在这里发布您的依赖项库代码。编辑第一篇文章您有AndroidX项目,并且您说您创建的活动没有任何错误,所以请检查这些活动:android.support.constraint.ConstraintLayout,android.support.design.widget.CoordinatorLayout,android.support.v7.widget.Toolbar…并将其转换为androidx dependency。@Niklaus转到laylut文件,将约束布局的包名替换为androidx.widget.constraintLayout