-1

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.

5
  • whats the name of string variable ? Commented Mar 5, 2018 at 16:07
  • 1
    Variable names cannot have spaces. public static final int font size = is not valid. Commented Mar 5, 2018 at 16:08
  • 1
    ctrl + shift + f > search for font size. Is there anywhere in your code or XML files where you've declared it with the space? It won't be in this file since R.java is automatically generated. Commented Mar 5, 2018 at 16:13
  • ctrl + shift + f helped me to search in the entire project the place in my xml file where by mistake I had named the id incorrectly. Thanks @MichaelDodd Commented Mar 5, 2018 at 23:59
  • @pamo Good to see it's worked. I've expanded on my comment in an answer so we can mark this question as closed. Commented Mar 6, 2018 at 0:13

2 Answers 2

1

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 e.g. 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.

Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.