有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java新材质依赖项不适用于CoordinatorLayout预览

因此,为了使用BottomAppBar,我添加了所有安卓 new material Dependency,但在我导入了所有内容并更改了文档显示的内容后,我甚至看不到预览,在编译时,我得到了一个错误,即test.runner不存在,这可能是我删除了support.test.runner,因为它说我们不需要将支持与材料混合

这就是我所做的

我的依赖

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    implementation 'com.google.安卓.gms:play-services-maps:16.0.0'
    implementation '安卓x.appcompat:appcompat:1.0.0'
    implementation '安卓x.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.安卓.material:material:1.0.0'
    implementation '安卓x.cardview:cardview:1.0.0'
    testImplementation 'junit:junit:4.12'
    implementation "安卓x.room:room-runtime:2.1.0-alpha01"
    annotationProcessor "安卓x.room:room-compiler:2.1.0-alpha01"

}

风格

<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">

我在我的AndroidManifest应用程序标记中添加了两行由编译器提供的建议

 tools:replace="安卓:appComponentFactory"
        安卓:appComponentFactory="settings"

我更改了所有类中的所有AppCompat,并用新的AndroidX AppCompat替换它们

错误

error: package 安卓.support.test does not exist

这可能是因为我删除了支持。从我的gradle测试,因为在医生说,我们不需要混合支持材料

试图预览coordinatorLayout时出现此错误

enter image description here

任何线索,它可能是什么,以及如何解决所有这些,因为我需要尽快与这种材料的设计工作

还有一件事,因为它有AppCompat,我可以在我的安卓 7上运行并看到这个设计

谢谢


共 (1) 个答案

  1. # 1 楼答案

    你有什么版本的Android studio? 根据这里:https://developer.android.com/jetpack/androidx/migrate Android studio必须为3.2或更高版本。 如果你的android studio现在是3.2或更高版本,在重构选项卡下有一个选项——“迁移到AndroidX”,等待它编译所有内容,并将现有项目迁移到AndroidX,这是你正在寻找的材料

    如果你可能会问,以下是我对androidx的依赖:

    implementation 'androidx.appcompat:appcompat:1.0.0-rc01'
    implementation 'com.google.android.material:material:1.0.0-rc01'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha2'
    implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'