Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Build a Simple Android App (2014) Creating the Screen Layout Adding a Button

Resource id cannot be an empty string (at 'id' with value '@+id/'). [Solved]

Solved. Thanks

Why would you just mark it as [solved] without sharing insight on what you did? tell us the solution that you implemented so that others can benefit from it.

4 Answers

Javier Alvarado
Javier Alvarado
16,060 Points

I also had this problem for the relative layout. I just added a name in the id section for the layout itself. I'm not sure why the error popped up in the first place though. I'm fairly certain there was no id section in the xml code before.

You are correct, This is nearly 5 months old now, I've gained a lot of the proper experience since then. You are surely correct with the issue. This will happen to many things. It is caused by the Android Studio forgetting to remove/add the elements id, and this will cause an error, you can simply solve this by going into the XML Text View and adjusting it manually (It is a lot faster then deleting the line and hitting build). and naming it for example, " RelativeLayout is at android:id="@+id/" Just add after / "relativeLayout1" or "relativeLayout2" etc etc.

Igor Demchenko
Igor Demchenko
1,433 Points

Same here: Error:(10, 17) Resource id cannot be an empty string (at 'id' with value '@+id/').

But, on the directory list mistake is shown in java directory, and if you follow the path and open it the three highlighted places are: (R.layout.activity_fun_fact); (R.menu.fun_fact, menu); (id == R.id.action_settings) with all three "R" highlighted in red.

Any ideas how to fix it?

I had the same error but it was under the relative layout (above the first TextView). I just deleted the entire line android:id="@+id/" then just click on build.

I had the same problem, I think it was because I accidentally added some id to my relative layout from property inspector, then deleted it, so it remained an empty string.

To get past this all I did was go to the text tab. Then for that button, I deleted the entire line android:id="@+id/" then just click on build.