I've receiving this error in every project I make, new or otherwise.
I've attempted reinstalling Android Studio fresh without any luck and I've also scoured the Internet for the exact error and nothing seems to be coming up.
Does anyone have an idea of what's causing this error when I add a new layout to my project?
It's simply because you are trying to create new Activity / Layout file in a wrong package. To do so, You have to navigate to app >> java >> firstfolder.
@androiddeveloper - All alphanumeric characters, '. ' and '_' is allowed. However, a package name (or a "sub-package" name for that matter, like "reader" in com.
Package names are written in all lower case to avoid conflict with the names of classes or interfaces. Companies use their reversed Internet domain name to begin their package names—for example, com. example. mypackage for a package named mypackage created by a programmer at example.com.
Instead of adding the new activity by right clicking on the file labeled "layout", right click on the file labeled "res" to add a new activity and it should work fine.
As your screenshot shows,current package name is layout,but maybe you don't have a package named layout
,so such error existed.
If you want to add a layout file to your project,you should right click layout folder under res folder,and create a layout file.
Hope this helps
Option 1:
Option 2:
Hope it helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With