Cannot find R.layout.activity_main

后端 未结 29 2164
轮回少年
轮回少年 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:18

    You're importing invalid R class, import yourpackage.R class for example com.example.R

    what actully happends that u import android.R class not yourpackages.R

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

    I have a few suggestions:

    1. Make sure you don't have any other errors other than the R-related errors. Right-click your project folder in Eclipse, Android Tools -> Fix Project Properties.

      2.Check to make sure you have the correct R imported. Sometimes the default Android.R can be imported.

      3.Check for errors in your layout XML files.

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

    I removed import android.R and added import android.support.v7.appcompat.*;

    However this had to be done after importing appcompat by right click project and import

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

    If your XML's contain errors your generated file might not build try erasing most of their content and making sure id's and file names are not duplicated and no capitals and spaces are used. If it works you can start adding stuff.

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

    In Android Studio go to Tools -> Android -> Sync project with gradle files or File -> Sync project with gradle files in latest Android Studio version.

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

    I've got this when an inappropriate character (/-one slash) was added to the values/strings.xml, and, of course, renaming of problematic resource was helpful. And one more important thing - check the date and time on your device.

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