R.java gives an error - java

My R.java gives an error
public static final int 1405308882_more = 0x7f020000
Don't know or understand why its giving this error, i regenerate the R.java file and it still gives me the following above. and when i hover my mouse over it, it says
underscore have to be located within digits
I tried editing it but when it compiles it still regenerate the same name variable.
Please before anyone starts rating this question as usless take your time to understand it
I don't have error in any of my java files either in the src folder or layout folder every thing else is fine its just the R.java that generates that constant so please understand before you jump to conclusions. Thank you.

There might be some thing error in your res folder once check each and every file and clean your project once and refresh it again..
Sounds like the R.java file has not updated, try some of these general pointers to begin with:
Do not manually edit any of the files in the gen folder, as these are automatically built for you.
If you find it is out of sync then try refreshing the project.
If that did not work try a clean (project -> clean)
If that did not work delete the gen folder, from within Eclipse, (do not panic) it will then be rebuilt by Eclipse - however if there is a coding error of some sort it may not do this straight away.
Hope this helps..

It wasn't the XML file that was the issue. It was an image in the resource folder with a name that didn't follow the standard naming rules and thus made the R.java to generate that error.

The reason it regenerates same is because it regenerates from your code you should check the .xml files of this project the problem is probably at 1 of them try clearing xmls you have created then regenerate it.

Related

How can I clean up my eclipse project after deleting a .java whose .class file still seems to be somewhere?

So, I deleted a couple of .java files from within eclipse because I didn't need them anymore. However for some reason another class still uses them and compiles without a problem. When I go to the declaration of the constructor of one of the deleted classes a .class file opens of that class even though I thought they got deleted by eclipse when I deleted their .java files.
I have tried to clean the project and I tried to find the .class file using the system file explorer in the folders that are listed in
project > properties > resource > linked resources. However I couldn't find them.
Now, since I deleted those files/classes there should be a compile time error wherever they are used but everything compiles without an error, even using the code that should've gotten deleted. A colleague that recently joined the project does receive compile time errors, since he doesn't have those class files. And I want to get them too, so I can fix the code where the classes were used. Of course he could show me the lines of code that are affected but if this happens again he would probably be affected as well as he would have the class files by then.
Try doing the following
Go to project > properties > Java Build path >Source
under that you can find Default Output Folder section, simply delete the classes folder under that location with in your project.
Try cleaning the project.
Or
Simply close the eclipse and reopen it again, sometime this would work for me.
Hope it resolves your problem
If you just deleted the sources, they binaries would still be there. So open the Navigator View and go to the project in question. Look for the bin directory and delete the appropriate class files. Otherwise, delete the project itself.
You should also ensure that no other programs depend on those class files.
I found the problem. Someone built a .jar file I didn't know of which contained a lot of old code.
I found it by right clicking the constructor and selecting
references>project

Accidentally Deleted R.java

I was doing some work on my app when I accidentally deleted the file R.java in the gen folder. Is there any way to get it back? I need it because it is giving ever activity errors. I tried copying my data into another application and that didn't work. I also checked my recycle bin and there was no file and cleaned. Please help?
Several ways to get out:
Simply modify(add a white space or so) in one of your resource files and save it, if the eclipse is enabled 'build automatically', the R.java will be re-generated again.
Go to project - clean project, clean your project and it will be re-generated when you run the project again
It is automatically generated file
Just clean and rebuild you project If there is no error{there must not any xml error which neither shown error nor let R.java build} then it will create your R.java file
again
Every Successful build just re-create new R.java file
R.java is auto generated when you delete it, make sure the xml file has no error . If this is also not solving your problem the start doing your project from scratch no copy paste.

Can't get R.java back in eclipse

I have a massive problem, and I can't find a single thread out there that specifies this problem.
I'd been watching Google IO, and the Android Studio was mentioned, I downloaded it, installed it, and opened my project into there, as I wanted to try out some of the new features, Fine and dandy, (on a separate note, I love Android Studio)
It was working before in Eclipse, and I literally changed nothing about my project, I was only looking around at the device preview features and stuff, didn't touch any piece of code what so ever, just having a look at some of the features..
Went back to eclipse, and my generated folder only showed R in, no tree structure of R or anything, just R.java, and R inside it, and everything in my classes were underlined, but it wasn't the R that was, it was the value after it (ie. Cannot find R.layout.main) which I thought was really weird, so I cleaned my project, and it disappeared, I now have a project without a generated R.java file.
To note; I changed nothing about my project, all my XML files were absolutely fine, i've tried every trick I can find on StackOverFlow and other websites (removing some of the XML's, painstakingly going over my 15 layout files character by character for an hour, removing imports, build paths, etc) and nothing works, and i've been trying to do this for almost 3 hours now.. Does anyone have any experience doing this, or any solution?
in the Gen section of your project, try to delete the R.java
It should re-generate, I had some issues like that in the past..
Give it go.
The R file may not be generated due to errors in the project.
Check your xml files in res folder. Also read Error log of the eclipse.
(Windows -> Show View -> Problems)
The best way is copy R.java from another project and Past it in gen
And then Delete R.java file then the system will recreate R.java back for you..........

R.java file gets deleted suddenly on cleaning project

on cleaning a project to update a image My R.java file in gen folder got deleted with no clue how , as a result giving errors how to recover it
Delete gen and bin folder. And perform build.
If R.java file is not generated, probably you have some errors with resources.
Check your Android manifest file. I bet you have a typo there. If manifest is clear, R.java will be automatically re-genrated.
Also remove all reference to the R.java file in your source that u might have imported mistakenly.
Check your resource files. Remember that your file names must contain only [a-z0-9_.] No "-".
The best way to know where the problem is coming from is to check the "problems" view in eclipse.

Eclipse run old version of program

I have a problem while runing my application in eclipse. I make some edits like this:
String res = "newvalue";
System.out.println(res);
But when I run the application I still receive "oldvalue" in output. After this I tried to delete main() function - and I run application and I see "oldvalue" in output again.
Maybe it's some cache in JVM, or smth. else?
UPD:
It's 15:35 on my clock now. But in /bin folder I see .class files with 14:33 timestamp. I change source files (.java), press ctrl+f11 in eclipse and files in /bin folder are still 14:33 ...
UPD2:
After cleaning the project I receive the following problem:
The project was not built due to "Could not write file: D:\projects\NelderMead\bin\ru.". Fix the problem, then try refreshing this project and building it since it may be inconsistent
SOLUTION
The problem was that eclipse can't write file to the folder with spaces and UTF chars in it's name. So, I copy project to the new clean workspace and it runs without problems! Thx all for help detecting the problem!
You're executing an older class files, the reason could be
a compile error somewhere else (see problems view)
or your changed accidentally the source path so that the new source no longer gets compiled.
Try to clean the project and make sure the new classes are compiled to your output folder.
The JVM doesn't have a cache for class files.
First, make sure the file is saved (there is no asterisk next to the file name in the tab). Usually files are saved automatically, but you could choose not to save files and never ask by mistake, the first time Eclipse pops up this dialog.
Then see what's going on in the Problems view. You might see something like project cannot be built due to the following reason. It may be because of compilation errors in the dependent projects.

Categories