Eclipse error : Your project contains error(s),please fix them - android

I am using Eclipse Classic 3.7.2 working only on Android. I use Ubuntu as my OS. When I run any basic Android application on Eclipse say "Hello World", it results an error called Your Project contains error(s), please fix them before running your application.
Now I have googled and checked here and may others but I did not get the solution.
I also tried Project > clean... but it isn't working.
Windows->Show Views->Problems shows 2 errors:
Error generating final archive: java.io.FileNotFoundException:/home/android/Desktop/helloworld/bin/resources.ap_does not exist.
Unable to parse aapt...

It may be be because of Eclipse's debug certificate expiration.
Please look at to my this answer.

Close and restart Eclipse. It works everytime !
Its bug with deleting android projects I think.

I have faced exactly same type of issue. Just update your eclipse ADT plugin to latest version.
After update clean build the project.

Go to your .android folder and delete your debug certificate. In my computer it is in this path
E:\Users\(ur profyle)\.android
Inside that there is a file name 'debug.keystore'. Delete that,clean and try to build the project again. Sometimes this error is caused when the certificate expires.

You need to update your Eclipse to the latest available version(Indigo) and then need to update the ADT(level 16 I think), as the latest ADT updates works on Indigo only. After the updates close and reopen the Eclipse, it should work now.

Go to Project Properties -> Java Build Path
Select Libraries and remove Android Dependencies
After this my problem solved.
The error was because of updating

Set your Android sdk path once again and restart Eclipse. It fixes the issue (window-preferences-android-sdklocation).
Or, just update your Android tools and restart Eclipse works.

Check your libs folder ..
some libraries cause this ,
it happened to me once and i was use Apache POI .. i tried to delete the jars from libs folder and it's worked ..

I had this problem in Eclipse after executing Project => Clean... That option deletes all the compiled stuff from your project and, therefore, the java classes start looking like if they all have errros.
To fix that problem I had to:
1. open my java clases and XML layout files(for android dev)
2. do a small change, something like a adding a space
3. Hitting Crt+S to ask eclipse to save and compile the class once again.
This solution may or may not work for you. I recommend looking at your specific problems using the Problems tab of Eclipse (Found at Windows=>Show View=>Problems) since it tells you about the exact errors and other very useful information.

If you're using android support library make sure you have not added jar files ( android-support-v4.jar and android-support-v7-appcompat.jar ) in your libs folder.
you only need to add android-support-v7-appcompat as library on your project.
It worked for me the time I had the same issue

My project had no errors in it but I noticed another open (unrelated) project which did have errors. I closed that project and my other project worked fine again.
Now the "unrelated" project used to be related but I'd removed the dependency ages ago. Closing it solved my problem so I have to assume there is some Eclipse bug in there somewhere which is still linking to it in some way. I'd say if I created a new project and copied everything in it might have achieved the same result.
As a test for yourself.. maybe close all other projects except the one you are working on.

Related

APK path is not specified for module "Example-Example"

I am newbie in the world of android app development. I was creating a project Example on Android Studio. I have my LunchList.java file in src/main/java/apt.tutorial.lunchlist .Till yesterday Everything was working fine. But when I open android Studio today I got an error saying
"The modules below have been removed from Gradle structure. Check
those to be removed from the project too:"
☑ LunchList
☑ LunchList-LunchList
And there is OK and Cancel Button. I don't want to remove them. So I click cancel and proceed.
Then when I tried to run the application in emulator the emulator runs but nothing happens. And I got this error
Waiting for device.
Target device: emulator-5554 (Android)
ERROR: APK path is not specified for module "LunchList-LunchList"
I don't know what went wrong. Please help me.
[Edit: I tried unchecking both of them and click OK. But after that I'm not getting the first error but still getting the second error ]
Exit Android studio. Launch it with Administrator Privilege.
This solved the problem with Android Studio v0.1 in Windows 7.
I had the same issue, I unselected the 2 files and then received the error
"ERROR: APK path is not specified for module"
I just restarted Android Studio and reopened the project and then it worked normal again.
It is indeed a bug but there's a simple work around.
Here's what worked for me: delete .idea/ and *.iml files, then open a project again (as gradle project) - all the idea files will be recreated - and everything works fine
I had the same error with IntelliJ CE.
I fixed it by choosing "Inherit project compile output path" in the strong text imodule settings (Paths tab > Compiler output)
In my case, I imported the same project over again. Android Studio overrode the old settings. Then this error went away!
this happened when i update to 2.0. i had to change the dependencies in the build.gradle file under src dir not gradle dir. change from
dependencies {
classpath 'com.android.tools.build:gradle:0.4.0'
}
to
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
Not sure how much help this will be, but I saw that same error this morning after updating to Android Studio 0.2.0. First, I needed to modifying my build.gradle file to indicate that the correct gradle plugin to use with my project was version 0.5.0 (rather than 0.4). After modifying build.gradle, I saw the "APK path is not specified for module .." error when attempting to build. I solved this by simply quitting and restarting Android Studio.
I had the same issue and found the solution.
Stackoverflow Question
this is the same way to fix the error
Also lower down in there is "SDKs" i also had to make them match.
Name and Build Target.
Hope it helps it did me. apparently the IntelliJ is what Android Studio is.
I've found that the issue is usually if you've changed or moved the folder to a different location.
If you open up the .idea folder in AndroidStudio, have a search for any reference to the old location. If you find some, just replace with the new location. It would seem some of the lines are hardcoded.
There is a manual "how to move project" here
I moved progect, got your problem, followed this manual, got window like you and choose "OK".
And now it works very well.
It helped me to set the right SDK...
I used the one in Program Files, what did not work!
Then i found out to use the following SDK (set in local.properties):
sdk.dir=C:/Program Files (x86)/Android/android-studio/sdk
Hope this helps...
I find this:
http://www.chrisdew.com/blog/2013/07/17/android-studio-nosuchmethoderror-lazystringarraylist/
it is realy help for me.
Thus, in my case, the problem was to have two libraries:
protobuf-2.4.1.jar
and new protobuf-2.5.0.jar
it resulted error:
APK path is not specified for module “Example-Example”
To correct this, rename file protobuf-2.4.1.jar to protobuf-2.4.1.jar.disabled
mv protobuf-2.4.1.jar protobuf-2.4.1.jar.disabled
Finally! Updated solution found here:
Android APK path is not specified for module
Open Project structure
Click on Modules tab
Expand your project and click on Android
On right side click on Compiler tab
Looking for "APK path" field
Enter your project root folder, i.e. /Users/bla/project/my.apk
Click Apply and Ok

Cannot build library dependent project after update to ADT 14

In order to implement different versions of our UI we broke our program up into UI specific code and a common library project that has everything else. Up until yesterday when I updated to ADT 14 everything was working fine. Now I can't build. I keep getting the error "The container 'Library Projects' references non existing library 'path to the bin folder of my common project and the name of the project.jar'
I've been all over the web and tried everything I can think of to fix this to no avail. Can someone help me out? I'm basically stuck at this point.
Maybe you have the same issues I had when switching to the new ADT:
In my previous setup I had some resources split between the library and the main project. The library project would not compile error free on its own but only in combination with the main project which added the missing resources.
It doesn't work like this any more.
The library project must compile completely error free now. When it does the build process will create a <lib_project_name>.jar in the bin folder of the library project.
If the jar file is not created ( thus the build process of the library project failed for some reason - eg. because the changes in the R.java file (see http://tools.android.com/recent/buildchangesinrevision14 )) you will get the error message you described.
Also, I had to manually remove the <lib_project>_src from the project.
I've had a problem with a few different projects where I did the fixes suggested in the other answer, but they were only fixed temporarily.
Every time I reopened Eclipse or did a Clean on a project, the "Library Projects" directory would disappear, and I would have to open the project properties, remove the library, and add it again.
I solved this the hard way by creating a new project and copying everything into it.
Then I found an easy way to solve it. Right click the project, Refactor-->Rename. You can rename it back afterwards. This fixed it.
Check out the article "Changes to Library Projects in Android SDK Tools, r14" ( http://android-developers.blogspot.com/2011/10/changes-to-library-projects-in-android.html ) on the Android Developers blog.
E.g. #P.Melch: "I had to manually remove the _src from the project" should be done as follows:
To fix the project, you must remove the extraneous source folders with the following steps:
Right click source folder and choose Build Path > Remove from Build
path.
A dialog will pop up. In it, make sure to check “Also unlink the folder from the project” to completely remove the folder.
You have to update the Android SDK in Android SDK Manager
Android SDK Tools Intalled
Android SDK Plataforms Installed
Android SDK Builds Installed

All my android projects have r.java related errors

For some reason my eclipse/android development environment has stopped creating the r.java files and wont read them in any of my projects. Should I just uninstall eclipse and all traces of it and the android sdk Ive been using and start fresh?
Ive been looking for the past couple hours for a fix but I cant find one at all that seems to work so any suggestions on the matter would help.
Every time I update my source I always do this:
Refresh project
Clean project
Refresh project
Works every time (unless I have a build path issue, then Right Clicking and Doing Android Tools->Fix project properties usually works)
Having build errors can keep the R file from being generated, make sure you don't have any syntax errors.
Try touching (making non-changing edit) one of your .java files and seeing if it forces the R files to rebuild. This appears to be a bug with Android SDK / Eclipse integration.
This happens to me a lot. Two things to try.
1) Try to clean the project
If that doesn't work. This usually works for me.
1) In eclipse delete the project (BE SURE NOT TO DELETE THE SOURCE)
2) Close eclipse
3) Open eclipse
4) Add the project back via New Project from existing source
You can try this:
Make sure that "Build automatically" option is on (under Projects menu)
Clean your project
Refresh your project
I fixed this by removing parentheses from a string title that I had created.
I am a complete n00b so I did not think that adding () to a title would cause problems.

R cannot be resolved to a variable

other answers relating to this did not help me out. Hence, I am posting a new question. I am trying to test a sample app of android that comes with their SDK. I get the error "R cannot be resolved to a variable". Looks like my R.java is not being generated. I don't know if I checked in the right place. I checked in the 'gen' folder of where I had downloaded my SDK and could not find the R.java file in the app which I am trying to test.
Could you please provide me with some ideas?
Thank you so much.
It happens when resources are not compiled. If you don't use automatic builds then just build your project. Otherwise it may happen because of some errors in resources.
I had the same problem(there was nothing under gen folder) and tried other solutions such as "cleaning project, checking if not android.R package is imported instead of mypackage.R, moving gen folder over src in java build path => order export tab and checking permissions of SDK executables" but none of them solved it.
Finally when I was checking one of the layout xml files in the res=>layout whether it has a problem or not Eclipse warned me with "The project target (Android 2.3.3) was not properly loaded" text. So I wanted to double check Android SDK Manager from Eclipse and found out that related SDK had an update. I did not see it before because it has a confusing structure with new or installed check boxes in my opinion.
When the 2.3.3 SDK updated all the problems gone...
Just clean the project and build again.
This is the most common problem I've found while developing for android.
Also try this Link for a detailed description about this issue.
Try to remove the read only in the properties of the sample sdk folder. That fix my problem i guest. Then remove the project in the eclipse. Restart eclipse. Then import it again.

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

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?
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":
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.
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.
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.
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.
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.
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......
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.
it can also happen if you move required files. Simply check Problems View (menu window -> show view -> Problems) as told here
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
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.
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.
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.
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
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.
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
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
Simply Deleted my debug certificate under ~/.android/debug.keystore and Project->Clean did solve the problem.
Delete the .android folder from your Documents&settings\User\ on XP and \User\ on Win7. Recreate the AVD again and create a new project.
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..
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...
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\
This happened to me when I was experimenting with Maven.
Right click project -> Maven -> disable maven nature
corrected the problem for me.
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.
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.
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.
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.

Categories

Resources