Reputation: 11
So I'm working on the Android tutorial provided by android.com. However, when I get to the Adding Action Buttons portion, I try to use the code that supports Android 2.1 with support libraries and that seems to cause an error in the .xml file. I have the same .xml name, "main_activity_actions.xml" with the same exact code. I notcied that my R.java however, was able to generate whenever I took out
<item android:id="@+id/action_search"
android:icon="@drawable/ic_action_search"
android:title="@string/action_search"
app:showAsAction="ifRoom" />
So, I'm not really sure what's wrong with this. My code is virtually the same throughout the tutorial up through this point.
Link for tutorial: http://developer.android.com/training/basics/actionbar/adding-buttons.html
Entire Code:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" >
<!-- Search, should appear as action button -->
<item android:id="@+id/action_search"
android:icon="@drawable/ic_action_search"
android:title="@string/action_search"
app:showAsAction="ifRoom" />
<!-- Settings, should always be in the overflow -->
<item android:id="@+id/action_settings"
android:title="@string/action_settings"
app:showAsAction="never" />
</menu>
Upvotes: 0
Views: 336
Reputation: 11
Okay, I found the answer to my question which was pretty stupid. The wrong part about the .xml is that the resources did not exist such as the string action_search and the drawable ic_action_search, thus R.java could not be generated and I had no idea as to why. Thanks for all the help guys!
Upvotes: 0
Reputation: 39992
Are the support libraries added to the project? Right-click the project, Android Tools --> Add Support Libraries.
If that isn't the issue, you need to post more information. Post the build errors, there should be information in there related to why the R file could not be generated.
Upvotes: 1