207

I know this question has been asked before and I have seen a plethora of solutions out there, yet none seem to work for me. I was able to build my apk without issues until this error started cropping up. I have tried cleaning my project, removing it from the workspace and reimporting it, removing "Java Builder" from my Builders for the project, building the project manually, reordering my java build path. I have no visible compiler issues and no problems exist in my workspace.

I did experience this issue before and solved it once by removing the project form my workspace and re-importing it and another time I solved it by removing "Java Builder" from my java build path. None seem to work this time. I currently have most of the settings set back to default (i.e. java build is checked again).

I am running windows 7 (64 bit) and using jdk1.6.0_21 via Eclipse 3.6.

Any suggestions would be greatly appreciated as I have lost loads of development time troubleshooting this already.

[Update] My locale is English & I have tried removing the debug.keystore, United States as related to issue 834

David Gill
  • 8,411
  • 5
  • 19
  • 21
  • Create a new project, copy your files to this new one, and then rebuild, perhaps. – James Black Jan 24 '11 at 02:48
  • I have the same problem but I can't get it resolved. Where do you have the JavaSE-1.5 option? I'm using IBM RAD though, and I have different JDK/JRE for Android SDK than for Java dev. could that be the problem to?(Android SDK couldn't find original JDK/JRE so I had to do additional install) – Brent Jan 25 '11 at 20:33
  • 3
    Also worth noting I think this is an overloaded error message by the android debugger. I've seen a plethora of solutions to this problem out there. – David Gill Feb 05 '11 at 05:16
  • In my case, I had used a special character in my project name - é. That was the reason behind the error. I changed it to 'e' and the problem went away. – Bilbo Baggins Aug 05 '13 at 13:45
  • I'd recommend running `android update project --path .` from your project's root, then trying to run `ant debug`. This resulted in specific build errors that led to my solution; for whatever reason, Eclipse wasn't being verbose about what was going wrong. – namuol Aug 11 '13 at 00:31

24 Answers24

603

Please follow these steps; this might help you out:

  1. Right-click your app project and go to Properties

  2. Select Android from left-hand side list

  3. Uncheck the "Is Library" checkbox

If your app project relies on library projects which are in your workspace, those of course need to have the "Is Library" box checked.

user149408
  • 5,385
  • 4
  • 33
  • 69
Hikmat Khan
  • 6,434
  • 2
  • 25
  • 22
  • 16
    Bingo! +1 dude I'd ++++ more but can't. I have no idea how "is library" got selected in the first place. –  Aug 05 '11 at 07:44
  • 2
    This solved it for me too, though the shared library it failed to import IS a library. So when this pops up again in the future i will just uncheck, install, then re-check this option. – joveha Nov 08 '11 at 18:55
  • This will indeed solve the problem most of the time. Worth noting that b/c its an overloaded message it is not always the solution – David Gill Apr 11 '12 at 17:42
  • 5
    This did not work for me, I used the solution below (deleting R.java in /gen/ then relaunching eclipse) – Ryan R Jun 09 '12 at 22:59
  • 4
    "is library" should be unchecked for the library project, not your implementing project. Perhaps the message is produced since the library tries to find and reference it's own .apk as a library to itself?! – Almer Nov 13 '12 at 11:32
  • 1
    @HikmatKhan: I have an that is ALSO a library. So I do need the apk to install it. Do I have to keep unselecting/selecting the `Is Library` checkbox each time I make changes to it?? – Luis A. Florit Dec 23 '12 at 03:35
  • 2
    Note that this is the correct answer for MAIN projects, but not for actual library projects. See http://stackoverflow.com/questions/5580575/could-not-find-the-xxx-apk-message-in-console-while-starting-application-with – Robin Davies Dec 08 '13 at 20:15
  • 1
    In my case "Library" got checked because I was trying to get GridView to import. A search on the error brought me right here! Yes, that fixed it. – gbarry Jan 12 '14 at 07:12
  • I forgot it checked from previous tests. Did it. – Niki Romagnoli Feb 14 '15 at 18:33
  • It would really help if there is some kind of visual clues indicating that this is being built/run/mode as library. I mean, really, there should be some kind of feedback there. – Neon Warge Sep 26 '15 at 11:25
  • The comment by @RobinDavies pointing to https://stackoverflow.com/a/6118122/2597758 is the correct one in my case: That annoying "could not find .apk" message (in red) only occurred for one my libs, not for the others (and certainly not for the app itself). – WebViewer Dec 05 '22 at 04:53
24

deleting the R.Java file in /Gen folder did the trick for me

gavtaylor
  • 653
  • 8
  • 21
16

I tried all the above solutions. but it didn't work.

The solution was to restart eclipse !!!!!!!

hope this will help someone :)

Elshaer
  • 431
  • 4
  • 13
12

In my case this problem started after eclipse updated the plugin with the v4.0 API release. I fixed it by going to the main preferences for Eclipse and under Android->Build uncheck 'Skip packaging and dexing until export or launch'

Note: if you eclipse gives you the Unknown Command 'crunch' error then follow this post

Community
  • 1
  • 1
FearlessHyena
  • 3,527
  • 33
  • 39
8

I've tried to gather the best of other peoples answers into a step by step list of things to try in order:

  • Check the project is not set as a library:
    1. Go to Project->Properties
    2. Select Android from left-hand side list
    3. Uncheck the "Is Library" checkbox
  • Clean and rebuild the project - this should delete and recreate the entire gen folder, including the R.java file mentioned in some peoples answers
  • Check eclipse and all the Android plugins are up to date
  • Close the project, exit Eclipse, reopen eclipse, reopen the project.
  • Go to Java Build Path > Projects and check for any incorrect project dependencies
  • Go to the main preferences for Eclipse and under Android->Build uncheck 'Skip packaging and dexing until export or launch'
  • Check JAVA_HOME is set correctly. Follow the steps in this article

If you complete the above list, and still haven't solved the issue, please leave a comment, or if you find something else that works, feel free to edit the answer and add your thing in.

rjmunro
  • 27,203
  • 20
  • 110
  • 132
  • 1. Clean and rebuild the project 2. Close the project, exit Eclipse, reopen eclipse, reopen the project. Above 2 steps fix my problem, thanks – wenbo qiu Jul 09 '13 at 09:33
  • "Close the project, exit Eclipse, reopen eclipse, reopen the project" worked for me!! This reminds of the wonderful windows recipe - "Please restart your computer and see if the problem has gone away." – Chandranshu Oct 12 '14 at 12:56
5

Delete the project from your workspace & import again.
This worked for me.

Can't believe similar issue has been there since 2008.
http://code.google.com/p/android/issues/detail?id=834.

  • FYI- this worked for me a different time I had this issue. Anyone experiencing this issue should probably try this solution first. I saw that also, but my language was set to English. This really leads me to believe it's an overloaded and vague error message. – David Gill Mar 06 '11 at 15:49
2

I was having the same issue as the OP except that all these suggestions did not work. I found a solution for me.

Make sure that "Skip packaging and dexing until export or launch." is selected.

Go to Window -> Preferences -> Android -> Build. Just make sure that option is selected and apply.

I know this does not make a lot of sense, but having it unselected was giving me this error and with it selected it goes away and the apk is installed.


I am using the auto generated ant build script from android and ONLY using it as my build process in eclipse. I am not using any other build methods.

prolink007
  • 33,872
  • 24
  • 117
  • 185
2

i'm no expert, but eclipse on Windows, doing android apps, refuses to create the default.properties file (in the app root directory). I've just copied one from another app and it works fine. Simple contents, for Android 2.2 project it just says (ignoring comments):

target=android-8

fwiw

jim
  • 21
  • 1
1

Run Eclipse as "Administrator" and then import the project.

ag0702
  • 381
  • 1
  • 6
  • 18
1

None of these things worked for me. I'm trying to access native code through the jni, first with NDK samples. What I found was the build won't run if jarlist.cache is not present in the project bin directory. If I copy one from another project to that location (may need to refresh to see the folder in Eclipse), build works every time.

Dale
  • 11
  • 1
1

Clean the project and it will do. Sometimes it happens unknowingly but keep trying to solve using diff methods.

eckes
  • 64,417
  • 29
  • 168
  • 201
nagesh
  • 21
  • 2
1

I had somehow done a Run configuration as a Java application instead of a Android.

1

I figured it out. I was referencing JavaSE-1.5 and using JDK 1.6. I changed it to use 1.6 and that appears to fix it.

Seems like through my research that is an overloaded error message that covers a lot of error cases.

David Gill
  • 8,411
  • 5
  • 19
  • 21
  • Your Android project shouldn't be referencing Java directly. Your build path should include an Android version but not a Java version. – Kenny Wyland Aug 01 '11 at 21:44
  • Some how mine must have gotten mixed up. I think this happened flipping an earlier version of [maven-android-plugin](http://code.google.com/p/maven-android-plugin/) with m2eclipse on. I'd still highly recommend maven for your android builds though. – David Gill Aug 08 '11 at 03:50
1

I just fixed this by reselecting a default JRE for the execution environment (JRE6 for JavaSE-1.6 in my case). It got unchecked for some reason.

1

This fixed my problem. I kept getting the console error in eclipse "Could not find com_android_vending_licensing.apk" and even though it didnt seem to effect the way my app ran, it was annoying. So going into the com_android_vending_licensing project properties and unchecking the "is library" option, building the project to produce the needed apk and then going back into the com_android_vending_licensing project properties and re checking the "is library" check box fixed the problem.

Peter O.
  • 32,158
  • 14
  • 82
  • 96
Daniel
  • 11
  • 1
0

SHA1's answer did it for me: after updating to the latest sdk/adt, my project refused to build an apk; unchecking the option resolved the issue.

I don't know if the update checked this, or if it was checked before but the new adt screwed things up, but things work again now :)

MacD
  • 783
  • 7
  • 23
0

In my case this worked :

Delete R.Java file in /Gen folder

+

Delete all "R.Android" imports that Eclipse added to some of my java classes !!!

and rebuild the project.

Hubert
  • 16,012
  • 18
  • 45
  • 51
0

remove -- R.java -- Clean the project and run again.. this worked for me ..

Srinath Reddy
  • 289
  • 1
  • 3
  • 4
0

Find the project's folder in your system, enter it's Properties via context menu and deselect "Read only" option. Worked in my case.

This seems to be the source of the problem in many cases, moreover some solutions up there base on copying/rewriting the files in the project what makes them non-read-only.

Mathew
  • 31
  • 3
0

This is caused by JAVA_HOME not being set correctly. It can be easily resolved by following the steps in this article.

Joseph Mansfield
  • 108,238
  • 20
  • 242
  • 324
Rory
  • 11
0

Mine was caused by this problem (incompatibility between ADT and SDK), and was fixed thus:

  • Eclipse > Help
  • Install New Software
  • Add 'https://dl-ssl.google.com/android/eclipse/' to 'Work With' section and press enter
  • After developer tools appears on the list, check it and click Next
  • Restart eclipse once download is finished
Community
  • 1
  • 1
ED-209
  • 4,706
  • 2
  • 21
  • 26
0

I my case, I had to switch from API 21 to API 19, clean and build and everything was fine again. I am using a Mac and apparently API 21 is not fully supported on Yosemite.

Paranoid Android
  • 4,672
  • 11
  • 54
  • 73
0

the problem for me was I was trying to use IBM RAD which appears to not work properly for this, I installed Eclipse and now have a different error but I should be able to get past it

Brent
  • 1,378
  • 2
  • 16
  • 30
0

On my machine (Windows7, 64bit) I could fix this by setting my execution environment to a 32bit variant of the jdk (I used 1.6.0_23). And I tried a lot of things before...

rebouny
  • 71
  • 4