Android Studio 2.1 Cannot resolve symbol 'R'

前端 未结 9 1188
鱼传尺愫
鱼传尺愫 2021-02-10 17:10

Android Studio 2.1, Java V8 Update 91, Gradle 2.1.0 .

I know that this questions has been asked many times here, but none of the recommendation solutions works out.

相关标签:
9条回答
  • 2021-02-10 17:59

    Sometimes the R.java class is not created when there is some error into an xml file (like activity_main.xml). For example, if you change some attribute name that has a reserved word that cannot be changed. Like this: if you changed the attribute called: id to another name like
    id_A_Word_With_Error_Here in this code that can be part of the activity_main.xml, your error (R class not created) can occur.

    <android.support.v7.widget.RecyclerView
                android:id="@+id/messageRecyclerView"
    

    and there is an error like:

      <android.support.v7.widget.RecyclerView
                android:id_A_Word_With_Error_Here="@+id/messageRecyclerView"
    

    If clean, rebuild did not work and there is no error with import like import com.something... , my suggestion is to search an error into xml files.

    0 讨论(0)
  • 2021-02-10 18:05

    Try syncing the project, go to Tools > Android > Sync Project with Gradle Files

    UPDATE

    If you're using Android Studio 3.3, use the Sync Project with Gradle Files icon

    0 讨论(0)
  • 2021-02-10 18:06

    Have you tried Rebuild Project go to Build> Rebuild Project and perform it without doing the Clean project I had the same problem & it worked for me

    0 讨论(0)
提交回复
热议问题