Search code examples
javaandroidr.java-file

Line of code in R.java representing a string that doesn't exist


public static final class string {
    public static final int Long Sword=0x7f050002;
    public static final int app_name=0x7f050000;
    public static final int desc=0x7f050001;
}

This is the code that appears in my R.Java. It produces a syntax error, as I suppose "Long Sword" is an invalid name for a string. However, there is no such field in my strings.XML file. If I create any new fields to try and amend the error, it just creates a new line of code in the R.java. Basically, as far as I know, I just need to get rid of this line of code, but don't know how to do it without R.java reverting the "manual changes".

Can anyone help?


Solution

  • It appears I solved my own problem after much pilfering! In my XML, I'd tried to create a string using android:string="@string/Long Sword", which was apparently a massive fail. Though I was just experimenting, for some reason R.java kept this invalid string after I'd deleted it, and errored. So what I had to do was create the invalid string again in my XML, then change it to a valid name! I then saved, and the error was gone :) I then deleted the line of code anyway, as I didn't need it.

    Hope this helps someone somewhere!