1

In Eclipse, my code will not compile. There is a red X next to the project name and I get the warning to fix my app but I am not told what the problem is. Normally I see the error in the console and in red but occasionally no error message is shown. This is frustrating as it makes it very hard to find the error. How can I figure out where the problem is?

Johann
  • 27,536
  • 39
  • 165
  • 279
  • try to perform a clean on the project! – user944351 May 09 '12 at 06:32
  • Go to window called console.. there will be error logs... – ngesh May 09 '12 at 06:35
  • you created the project or imported from any other source?? – KMI May 09 '12 at 06:41
  • Now I am having your error exactly and I do not know what to do :( – Bob May 09 '12 at 06:41
  • After running a clean, the error was still there but this time the console indicates that R.java doesn't exist. It does exists. I've had that problem in the past and the solution was to delete the file and then modify my strings.xml to force it to regenerate the R.java file. The file will get regenerated but this error still remains. – Johann May 09 '12 at 06:42
  • Do you have this problem when compiling a specific solution? or all android solutions? If it really wont work you could always copy the code into a new android project. That might do the trick. – Wottah May 09 '12 at 06:42
  • clean did not solve my problem – Bob May 09 '12 at 06:43
  • @KMI: The project has been working fine for days and up till a few minutes ago. I added a line of code, compiled and then this is when it happened. I then uncommented the line I added but it didn't help. This is the first time I've seen it this bad. – Johann May 09 '12 at 06:47
  • @AndroidDev exactly for me. The project has been working fine for days and up till a few minutes ago. – Bob May 09 '12 at 06:47
  • @AndroidDev: this may occur sometimes just restart your eclipse and wait for the eclipse to build completely then check – KMI May 09 '12 at 06:52
  • I did it. I restarted my PC. Cleaned my project. No change :( – Bob May 09 '12 at 06:55
  • 1
    No change after restart. Deleted all bin and gen files, rebooted computer and same stuff. – Johann May 09 '12 at 06:57
  • try going to the `java build path` in the project properties, then remove all external jars and try cleaning and building – thepoosh May 09 '12 at 07:12
  • I solved the problem. check my answer [here](http://stackoverflow.com/a/10511279/779408) – Bob May 09 '12 at 07:14
  • @breceivemail: Your solution worked! Thanks a million. Delete the debug.keystore file. it is located under Android-SDK/AVDs/.android. Ridiculous the amount of time you have to spend tracking down these hidden errors. – Johann May 09 '12 at 07:34

4 Answers4

0

Expand the project by double-clicking and navigates to each files. See all the individual files which have a red cross sign. You can see red marks corresponding to line which have errors. Better look at the source files as well as .xml files

If the project is showing a red exclamation mark instead of cross, better look the default properties of the project. Probably, the target api level is invalid.

user1030768
  • 265
  • 2
  • 5
  • 13
0

In these cases that you get this message exception:Your project contains error(s), please fix it before running it do the following steps:

1) Restart eclipse and clean your project. If problem is not solved yet go to step 2

2) This can also be caused by an out of date "Debug Certificate" fixed as follows:

Delete your debug certificate under ~/.android/debug.keystore (on Linux and Mac OS X); the directory is something like %USERPROFILE%\.android on Windows.

The Eclipse plugin should then generate a new certificate when you next try to build a debug package. You may need to clean and then build to generate the certificate.

3) before rebuilding your project uninstall you app from device or emulator

Enjoy!

my reference

Community
  • 1
  • 1
Bob
  • 22,810
  • 38
  • 143
  • 225
0

Sometimes I faced this problem too. My way is to create a new project, then copy and paste all things to new project. These kinds of undefined bugs from Eclipse IDE, so you can't do anything else.

Good luck.

toantran
  • 1,789
  • 17
  • 25
0

Delete the debug.keystore file. it is located under Android-SDK/AVDs/.android.

Johann
  • 27,536
  • 39
  • 165
  • 279