AndroidStudio Cannot Find Layout

瘦欲@ 提交于 2020-05-04 05:34:33

问题


Running AndroidStudio 3.6.2. A number of times I try to create a new fragment/activity, create a layout xml file, but when I try to use the layout AS shows an 'Unresolved reference' error. One option to 'fix' the problem is for AS to create the layout file for me. When I select this option the file is created, but AS still says it cannot resolve the reference to the file it just created. NOTE: It will find other layout files just fine, so it doesn't seem to be how I'm importing the resources.

Is this a known issue?

Here is the content of the layout file I created, just in case someone finds it helpful.

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <include
        layout="@layout/content_video"
        android:layout_width="4dp"
        android:layout_height="2dp" />

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|center_horizontal"
        android:layout_margin="16dp"
        android:orientation="horizontal">


        <ImageButton
            android:id="@+id/switchVideoCamera"
            android:layout_width="48dp"
            android:layout_height="48dp"
            android:layout_gravity="center"
            android:layout_margin="8dp"
            android:background="@android:color/transparent"
            app:srcCompat="@drawable/ic_switch_camera_white_24dp" />

        <ImageButton
            android:id="@+id/display_video"
            android:layout_width="48dp"
            android:layout_height="48dp"
            android:layout_gravity="center"
            android:layout_margin="8dp"
            android:background="@android:color/transparent"
            app:srcCompat="@drawable/ic_videocam_white_24dp" />

        <ImageButton
            android:id="@+id/mute_audio"
            android:layout_width="48dp"
            android:layout_height="48dp"
            android:layout_gravity="center"
            android:layout_margin="8dp"
            android:background="@android:color/transparent"
            app:srcCompat="@drawable/ic_mic_white_24dp" />

        <ImageButton
            android:id="@+id/connectActionFab"
            android:layout_width="48dp"
            android:layout_height="48dp"
            android:layout_gravity="center"
            android:layout_margin="8dp"
            android:background="@android:color/transparent"
            app:srcCompat="@android:drawable/stat_sys_phone_call" />

    </LinearLayout>

</androidx.coordinatorlayout.widget.CoordinatorLayout>

回答1:


I am facing the same problem. I just Restart Android studio with invalidate Cache and it's work for me.

But when I use the stable version for Android studio 3.6 it perfectly works for me.




回答2:


Go to File->Invalidate Caches/Restart



来源:https://stackoverflow.com/questions/61073064/androidstudio-cannot-find-layout

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!