Home>

Hello.

I have a question about the following error.

Widget has an unresolved type 'android.support.design.widget.CoordinatorLayout', and thus it was upcasted to 'android.view.View
Widget has an unresolved type 'android.support.design.widget.FloatingActionButton', and thus it was upcasted to 'android.view.View

I think something in the layout is bad, but I don't know. .

<? xml version = "1.0" encoding = "utf-8"?>

    
    
</android.support.design.widget.CoordinatorLayout>

I would appreciate your teaching.

  • Answer # 1

    Although it is an Android support library, the package name has changed recently, and it used to be android.support. ~, But now it is recommended to use androidx. ~.
    Also, the package name of FloatingActionButton seems to have changed.

    <? xml version = "1.0" encoding = "utf-8"?>
        <com.google.android.material.floatingactionbutton.FloatingActionButton
            ... />

    If this results in an error, add the following to app/build.gradle:
    Also, remove the implementation 'com.android.support ~' and use the corresponding androidx version.

    dependencies {
        implementation 'androidx.appcompat: appcompat: 1.1.0'
        implementation 'androidx.constraintlayout: constraintlayout: 1.1.3'
        implementation 'com.google.android.material: material: 1.1.0'
    }