简体   繁体   中英

R.java error in Android

When I run my project I get the following error

Error:(3433, 37) error: ';' expected

Error:(3433, 42) error: identifier expected

Error:Execution failed for task ':app:compileDebugJavaWithJavac'.

Compilation failed; see the compiler error output for details.

Ther error is in R.java file from the following line of code, in third line

public static final int fill_vertical=0x7f0e0033;
    public static final int fixed=0x7f0e004a;
    public static final int font size=0x7f0e00d6;
    public static final int greyStar=0x7f0e00ca;

The error is coming on the 3rd line where there is a gap between font and size. I am not able to understand why and how that gap is coming.

I was actually creating String variables in string.xml file and setting those values on the textview in a layout file when suddenly this error crept in.

I've tried cleaning the project and rebuilding it, but nothing has helped.

Can anyone help.

As discussed in the comments, R.java is generating an invalid constant due to an invalidly-named XML identifier. In your case, you have an XML identifier that contains a space eg android:id="@+id/font size" . This may be in a layout file, strings.xml file or any other XML resource under res .

You'll need to hunt down this invalid identifier and replace the space with an underscore or any other valid character. The easiest way to do this is to bring up the Find In Path search ( ctrl + shift + F or Edit > Find > Find in path... ) and search for font size . This will bring up any instances of this string through your project.

You need to correct this variable name font size in project. you need to either remove this blank space or use _ instead of blank space.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM