Ok! If you are new to Android development, then you must checkout our Android Studio tutorials. Meanwhile, if you are getting an error ‘R Cannot be resolved’ or ‘Cannot resolve activity_main’, then here’s the fix. While creating a project, you might have set a package name, by default it will be com.example.applicationname. For instance, if your application name is “StartApp”, then the package name will be automatically set to ‘com.example.StartApp’. In case, if you change the package name, then remember to write import for ‘R’ class as below,
import yourpackagename.R; //Right way to import
and NOT as,
import com.android.R; //Not a right way if you change the default settings.
This should solve your problem.