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..........
Related
II updated AS to the latest stable build and all of my projects melted down. Only Java files in the main directory (com.company.app) can find R.java as intended. ALL of my subdirs can't find it. I did not have to import R.java before the update. I rebuilt my projects from scratch, restored backups, copy-paste to new projects from the backups, reinstalled AS, restarted PC, invalidated caches and restart, cleaned, literally every go to insta-fix-it solution that the internet always recommends and still I can't get this to work.
Can someone tell me how my subdirectories cant find R.java but other files in my main directory can? Is this a feature change in AS or something? Are we now supposed to import R.java? There are no XML errors. My project built before I moved any subdirectory files back to my main package. The package name exactly matches the one in my manifest.
Edit 1: I can rebuild my project and make R.java. The main package files still see it without the import, but the subdirs can't find it.
Edit 2: I can move a file from my main package to a subdir and it still finds R.java. This appears to be a compiler glitch.
Edit 3: Importing R.java makes the errors go away so I guess that is a solution. I am leaving the question open because this makes no logical sense.
You need to understand how App resources work.
When you build your android project, all of your resources in /res folder will be mapped automatically in generated your.package.names.R class.
Now you want to access the resources through the class. It's only make sense when you need to import the file when you use it in different package.
I had this issue, even though the error wasn't being underlined in red there was an error in my strings.xml. Go to Values->strings.xml and check if you duplicated any strings.
I am just starting off in Java and trying to follow buckythenewboston on you tube. I have java and eclipse neon both downloaded correctly. However, when I create a new project like he showed in the video, I click finish and nothing shows up, in the video it showed on the side there should be a like java symbol with the name of the project I created. Well nothing happens it is blank on my screen. I tried opening a file from the work space in my C drive and that doesn't work either as nothing shows up so I can create a class. I know there is a couple of forum questions with similar title but that is different I think as they can at least get code in where I can't. Any explanation as what is going on would be helpful. I also tried to go to file-import-existing project... but the existing project part isn't an option.
Thanks in advance.
go into your workspace directory and delete .metadata folder, then restart eclipse
Close all perspectives and open a new one, the one you like.
Yesterday, i've Closed Eclipse & then Turned Off The Computer, Now it's appear that a Crash has occured, when i started Eclipse again, Project List was empty So i've imported the Projects Again,
Problem : a Java Files is now corrupted, the file size seem correct, i can Open the File but the File is filed with "NUL" when i open it with a Text Editor & is empty when i open it in Eclipse,
I've tried to use the History Features of eclipse but there is No Any Backup in the .History Folder, only empty folders,
Is there any way to recover this Damaged .Java File ?
Thanks
if you use SVN, or other version controls, or ever back up your PC, you could look at restoring it from there. However, by your description, this doesnt seem likely.
Noting from your comments you have tried a system restore.. System restore points and backing up your PC are two different things.
Right click on your file -> Properties.
The click "Previous Versions" along the top.
It may say "There are no previous versions available", or may offer a restore choice.
Perhaps if you had previously deployed the project you can get at the class file and de-compile the class back to code but that may still result in some loss. Also just try doing a search on your machine for that file name perhaps it was backed up by you at an earlier time that you forgot about.
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.
I am working on Java project (A terraria like sandbox game) and I have come across something that I just don't understand. I have been exporting the project as .jar's as I go along to upload and share with my friends, but the last time I did this, the .jar won't run, but when I run it in eclipse, it runs fine. When I try to run the jar all it does is lose focus on the explorer window for a split second, then goes back. I have tried many things, like changing the main class, changing the META, and moving the files to specific packages, but nothing is working.
The project is 9 classes, so I won't paste all the code for it here, but the latest, non-working source code can be found here (http://www.mediafire.com/?fiw6wq73j7cff4t), the non-working jar here (http://www.mediafire.com/?bhjo162oh3hi2j9), and the working jar here (http://www.mediafire.com/?h918s8xpyxw4psr). If someone with more experience in java could please take a look at this it would be much appreciated.
One of the things I tried was not adding the JPanel (the game), and just leaving the splash screen, and the jar worked. This shows that it must be a problem in the coding somewhere.
Thanks for the time,
I.D.
Couldn't find message comes from your ReadMap class. So check which circumstance leads to this error. Most likely you did not add all classes or other files to your JAR, so file is not found. Check that all needed files are added to exported JAR in Eclipse export dialog. It's also a good idea to provide more debugging info (stacktrace is ok), especially when you are studying. BTW, cool game :)