Cannot find R.layout.activity_main

后端 未结 29 2167
轮回少年
轮回少年 2020-12-01 01:58

I was trying to work out with multiple layout using some online tutorials. The thing is my program was building and compiling correctly as long as there was only one XML fil

相关标签:
29条回答
  • 2020-12-01 02:23

    After cleaning the project and syncing with gradle(no result), i removed all my import statement, and brought them back in using alt+Enter.

    0 讨论(0)
  • 2020-12-01 02:24

    I had the same problem, fixed by replacing R with com.example.appname.R obviously put your package reference in there instead. Or just add this line to your file:

    import com.your.package.R
    

    Or even better, try removing this line from your code if exists:

    import android.support.compat.R
    
    0 讨论(0)
  • 2020-12-01 02:27

    or you can write

    import.R.layout // at the top

    It will work for sure

    0 讨论(0)
  • 2020-12-01 02:27

    First Doing This --> Select Build > Clean Project from the Android Studio toolbar, wait a few moments, and then build your project by selecting Build > Rebuild Project.

    if Problem Not solved then doing This --> File > Invalidate Caches / Restart > Invalidate and Restart from Android Studio’s toolbar.

    0 讨论(0)
  • 2020-12-01 02:29

    JUST REMOVE the import.android.R;

    Then the R.layout.(XML LAYOUTNAME) will turn to BLUE

    IT TOOK ME HOURS TO FIND THIS ONE ERROR

    0 讨论(0)
  • 2020-12-01 02:29

    Either your gradle or build need to know where resources are.

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