187

I am developing a simple Android application. But when I run Eclipse, it shows the following error:

Your project contains error(s), please fix it before running it.

I can't find any error in my project or there is no error in my application. There is a red cross under the application name but it is not under another file name.

Does anyone else have this issue?

Jonathan Soifer
  • 2,715
  • 6
  • 27
  • 50
JackeyChan
  • 1,871
  • 2
  • 13
  • 6

26 Answers26

220

That usually comes from errors in the build path.

If you're using eclipse, there is a view you can add that lists all the errors called "Problems":

enter image description here

Otherwise, you can try to clean the project, and that usually solves a few problems.

Finally, if you add or alter resources from outside your IDE, you'll want to reload the resources and clean.

EDIT (Comment by anonymous user)

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

IF ALL FAILS THEN THIS GOTTA BE THE SOLUTION:

Delete your debug certificate under ~/.android/debug.keystore (on Linux and Mac OS X); the directory is something like %USERPROFILE%/.androidon 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.

This is also another fix for the "setContentView(R.layout.main);" error that says it cannot find R.layout.main when it is actually generated. (R cannot be resolved to a variable).

This is also another fix for the error "Your project has errors..." and you cannot find any. Clean and rebuild are still necessary after generating a new debug certificate.

sashoalm
  • 75,001
  • 122
  • 434
  • 781
Jason Rogers
  • 19,194
  • 27
  • 79
  • 112
  • 5
    It is important to understand that problems will not always be reported against a source code file at a line number. Issues with project as a whole, like build path problems, will be attached at project level. You will not be able to see the problem text anywhere other than the Problems view. – Konstantin Komissarchik Feb 10 '11 at 20:46
  • 6
    the expired debug key usually does me in. every year. i really should put a reminder in my calendar or something. – Harlo Holmes Mar 15 '12 at 16:43
  • For me, there were no errors visible in the "Problems" view, yet Eclipse complained about errors! deleting `~/.android/debug.keystore` did indeed fix it !! I installed the android SDK on this Mac only 4 months ago so it shouldn't have expired. (using Eclipse Juno) – Someone Somewhere Aug 06 '13 at 18:25
  • my keys were in ~/.ssh/android-keystore, deleting it fixed my problem. – kritzikratzi Sep 10 '14 at 11:10
35

First go to Window -> Show View -> Error Logs in menu. It will display error logs if you have any. Then try to clean the project and build it again.

Sam R.
  • 16,027
  • 12
  • 69
  • 122
chikka.anddev
  • 9,569
  • 7
  • 38
  • 46
  • 3
    The Error Log view shows malfunction in Eclipse plugins. It is helpful for reporting issues, but the entries aren't going to point to problem in user application code. For that you want the Problems view. – Konstantin Komissarchik Feb 10 '11 at 20:38
  • 1
    I've similar issue (but with NDK/C++). My NDK+android projects compiles successfully, but Eclipse doesn't allow to run/debug it. I have an error on #include (I haven't added STL path to resources, and don't want to do it). How could this be possible, is there an option to turn it off? I want to see that not-so-real 'errors', but I want to run application (which does **NOT** contain any compile/link errors). – Krystian Bigaj Nov 17 '11 at 19:44
  • for me the problem was the debug certificate. And the suggestion to open up the "problems" windows was also helpful. I was looking under the "errors" window which was not showing anything. – user590849 Jun 01 '12 at 07:11
  • I got this error in Error Log: Error generating final archive: Unable to get debug signature key. – Pratik Butani Apr 23 '13 at 04:39
13

Well, in my case some libraries were addressed twice in the:

Project >> Properties >> Java Build Path >> Libraries

I just had to remove the duplicate and it worked fine without any cleanings or refreshing.

Mahorad
  • 1,258
  • 1
  • 15
  • 22
  • Uncheck jar files from Project >> Properties >> Java Build Path >> Order and Export tab – Ajay Takur Jan 02 '15 at 19:31
  • In case CAUTION Symbol error ! show in project. I solved the following steps project>>properties>>Java Build Path in left panel and select libraries in right panel(3 column) jar file is error. Just add JAR file in the same project libs folder in the popup. delete errored lib file. It works for me. – gnganapath Mar 10 '15 at 14:54
10

I saw this with an existing project. I had made a few edits, but hadn't imported anything new. Restarting Eclipse didn't help.

Project->Clean did solve the problem.

Nikhil
  • 16,194
  • 20
  • 64
  • 81
Mighty
  • 325
  • 2
  • 9
6

I come across this error often when I import a new project in my workspace.

Reason: Some necessary files (Like R.Java) is not generated in its respective packages.

Cure: Clean and build projects, All the files that needs to be auto generated will be there on place after building the project.

Best Luck.

Prasham
  • 6,646
  • 8
  • 38
  • 55
5

This is happened to me. After format of my system,
When i import project it shows same error

remove first debug.keystore file then goto -

Project -> Project properties -> select library -> remove -> add again libraries.

It's working for me......

user3209435
  • 111
  • 2
  • 2
4

Go to projects menu, click on clean menu item.

After that close the eclipse and reopen and try compiling..

It is software glitch you find some times.

Vinay
  • 2,395
  • 3
  • 30
  • 35
4

it can also happen if you move required files. Simply check Problems View (menu window -> show view -> Problems) as told here

Nikhil
  • 16,194
  • 20
  • 64
  • 81
Filippo Mazza
  • 4,339
  • 4
  • 22
  • 25
3

Is there a way to ignore existing errors in project. Something similar what eclipse allows in case of java projects.

In my case the errors exist in jni directory. The errors are shown even though ndk-buid succeeds. So all i want to do is to ignore the errors reported by eclipse.

If the errors are indeed errors then i should get unresolved symbols during ndk-build.

I have ensured standard android includes are there in include path.

Also my project is of type android/c/c++.

I have two builders associated with the project 1. statndard android builder 2. custom ndk builder that ive explicitly created.

sharadendu sinha
  • 827
  • 4
  • 10
  • (http://www.eclipse.org/forums/index.php/t/274600/) Go to Window->Preferences->C/C++->Code analysis and uncheck false warnings. – bartolo-otrit Sep 05 '14 at 10:00
3

I had this exact same problem. One solution that would work would be to create a brand new project, but I don't think there's any need for that. For me the problem was that the debug certificate that gets auto-generated had expired. Deleting this file allowed Eclipse to rebuild that file, which solved the problem. You can't run an app with an invalid certificate, whether it be a debug or release certificate. Note that cleaning my project did not work. For more information, see: "Debug certificate expired" error in Eclipse Android plugins

Community
  • 1
  • 1
Michael
  • 648
  • 11
  • 23
  • You are not alone, see also: http://stackoverflow.com/questions/8467835/cannot-run-android-project-in-eclipse-despite-no-errors – Asmo Soinio Jan 12 '12 at 11:49
3

Recently I came across this error. I was really in a corner with no help, then I figured it out. This error can occur for the following reasons:

  • An error in the project code
  • Improper linking of external library files to the project
  • Most important: if your debug.keystore file is expired.

The first 2 cases are easily identifiable but the third one is like searching a black box in a dark room.

So in addition to Project -> Clean, remove your debug.keystore file also.

I am using Mac + Eclipse so to remove, I wrote the command rm ~/.android/.debug.keystore in a terminal.

ChrisWue
  • 18,612
  • 4
  • 58
  • 83
Nikesh K
  • 621
  • 6
  • 10
2

Simulate your self some error in class. Then save it and it would show more errors than you simulated. For me it was incorrect import and this helped.

Streetboy
  • 4,351
  • 12
  • 56
  • 101
2

I have had a similar problem.

Under "problems" tab I have found an error saying "Error generating final archive: Debug Certificate expired on 2/22/12 1:49 PM"

So my advice is to look in the problems tab to get some more info.

Bye

Nikhil
  • 16,194
  • 20
  • 64
  • 81
1

I had this exact problem when trying to run the Doodlz app, from the book Android for Programmers, on Mac OS X with Eclipse Juno.

After downloading and unzipping the demos from the book, I forgot to change the permission of the files. They were read-only on my system so this was the first issue.

The second issue was solved by selecting a build target on Eclipse. This was fixed by going to: Project > Properties , and clicking the Android field on the left panel to be able to select one option as the Project Build Target, which in my case was:

  Target Name     Vendor         Platform    API Level
> Google APIs     Google Inc.    4.0.3       15

Then cleaning and rebuilding the project showed no errors.

Finally, to run the app right-click the package (at the Package Explorer tab) and then select: Run As > Android Application

karlphillip
  • 92,053
  • 36
  • 243
  • 426
1

Simply Deleted my debug certificate under ~/.android/debug.keystore and Project->Clean did solve the problem.

Shailendra Madda
  • 20,649
  • 15
  • 100
  • 138
1

If none of the above solution work, you should check the READ ONLY property of the Project folder, if it is Read-Only, the compiler will not be able to overwrite the resources, R.java and other dex APK etc files and hence this will occur.. This happened to me and I fixed after a long struggle.. Happy Programming.

Pervez Alam
  • 1,246
  • 10
  • 20
1

For some reason eclipse only showed a ! error on root and didn't specified what error it was. Go in Windows -> Show Views -> Problems. You might find all previous errors there, delete them, do a clean build and build again. You'll see the exact errors.

Eclipse shows an error on android project but can find the error

animuson
  • 53,861
  • 28
  • 137
  • 147
Hemanshu
  • 76
  • 6
0

I had the same error, when I copied a project to another computer.

I then checked all properties of the project on both machines, and the only thing that was different was the order of items in Java Build Path - tab Order and Export.

I moved the items Android X.X.X and Android Dependencies above the other 2 in the list (in my case, src and gen folders) and voila, it worked again!

I'm not really sure if the different order was actually the problem, but at least changing it (and saving the properties again) seemed to help...

Dylan
  • 9,129
  • 20
  • 96
  • 153
0

This happened to me when I was experimenting with Maven.

Right click project -> Maven -> disable maven nature corrected the problem for me.

Vasudev
  • 1,936
  • 19
  • 17
0

Yes, this is a rather cryptic message. If you've got a faulty project (say one you've been working on in the past) then you'll get this message (and no messages in your current project's Problems / Error Log panes).

You may just want to run your current project. This may be perfectly fine. Just click on the down arrow to the right of the Run button to select your project.

Snowcrash
  • 80,579
  • 89
  • 266
  • 376
0

Try changing your workspace. I am not sure this is the exact solution . I did face the same issue for sometime untill i changed my workspace.

SajidKhan
  • 59
  • 2
  • 14
0

In my case, it happens with ADT 22.

I choose not to create Activity.

After I remove the "appcompat_v7" as library project. I works.

Yeung
  • 2,202
  • 2
  • 27
  • 50
0

I had similar problem where I couldn't run my project yet didn't see any problems in the code. In Error Log panel it said something like "Cannot add P/ to the list of segments P/ in as a parent". Restarting Eclipse solved the problem.

0

Delete the .android folder from your Documents&settings\User\ on XP and \User\ on Win7. Recreate the AVD again and create a new project.

2ndlife
  • 1,378
  • 3
  • 14
  • 20
0

I had the exact same problem after updating the SDK and ADT. My issue was resolved by deleting the .android folder (hidden) under C:\Users\USERNAME\

Nikhil
  • 16,194
  • 20
  • 64
  • 81
Freddroid
  • 2,449
  • 22
  • 23
0

What caused this problem for me was none of the above, but simply that I'd left the "debuggable" attribute to false in the manifest.xml file after doing a release. D'oh!

Of course neither the LogCat, Error log, Console, or Problems window alerted me to this..

Ben Clayton
  • 80,996
  • 26
  • 120
  • 129