46

Compile Error: Error generating final archive: java.io.FileNotFoundException: ..\bin\resources.ap_ does not exist.

Compile other simple sample works. Same source file and project works on my college's machine.

Any tips ? Why resources.ap_ doesn't get generated ?

jim.huang
  • 1,052
  • 2
  • 9
  • 14
  • For me it was a asset file name, which contained the german letter 'ß'. I changed it to 'ss' and then everything worked. – nomnom Nov 19 '15 at 16:42

28 Answers28

38

Did you do a Project > Clean? If that doesn't work, try forcing Eclipse to build the project again. Restart Eclipse if that still doesn't work.

Zarah
  • 5,179
  • 2
  • 29
  • 29
  • 7
    Tried clean several times. – jim.huang Dec 15 '10 at 02:47
  • Tried several times but doesn't work. Even tried below stuff still not work. 1)re-install android sdk 2)change my local to English and restart machine 3)re-create the project. but same projects works on other machines and other sample projects works on my machine. – jim.huang Dec 15 '10 at 02:48
  • Tried all of the above, numerous times. Clean, delete gen folder, Build All, restart Eclipse. Nothing helps. I've also confirmed that my build targets match up between manifest & project properties, which one other commenter suggested. One interesting note is that, when I delete my gen folder, Eclipse puts it back on the next build - but never puts anything in it. – Sterling Feb 17 '11 at 17:47
  • I tried all suggestions, and still have these errors on every project (even on projects that are newly created empty android projects..) – Peterdk Oct 27 '11 at 17:54
  • If Clean doesn't work, do a "git clean -df". You may have bad resource files in the res or assets directory. – Danke Xie Jan 19 '16 at 02:05
14

I created an empty text file under C:\Users\me\workspace\project\bin\resources.ap_

Then Cleaned/Rebuild... that seemed to fix it.

user614518
  • 141
  • 1
  • 2
7

In my case was a 9 patch drawable that was modified with GIMP, then adb cannot "parse" it, recreated with the draw9patch then worked fine

eveliotc
  • 12,863
  • 4
  • 38
  • 34
  • In my case it was just a simple png image that was somehow corrupted: The console said: `libpng error: Not a PNG file [2011-09-28 12:52:56 - ] ERROR: Failure processing PNG image.` Removing the file fixed the problem – Jens Sep 28 '11 at 10:54
5

I was getting both the error in this thread and the one in this post: Android Unknown Command 'crunch'.

Updating the Android SDK inside Eclipse fixed both errors for me.

Community
  • 1
  • 1
Greg Haygood
  • 958
  • 8
  • 11
4

If you delete the whole "gen" folder, then go to Project>Build All it seems to regenerate the folder and the R.java file

ElCoe
  • 41
  • 1
3

Finally i found the reason. The update aapt tool treat the format string without order as build error. e.g. "%s %d" should be "%1$s %2$d".

jim.huang
  • 1,052
  • 2
  • 9
  • 14
  • 1
    Can you please give some more details? I am having the same problem. – deeJ Dec 21 '10 at 16:15
  • 1
    This was my problem as well. Basically anywhere in your strings.xml where you have any combination of %s or %d in the same string, replace them with %1$s or %2$d where the number between the % and $ is the order in which they are placed in the string. For exmaple: "Blah %d something %s" should now be "Blah %1$d something %2$s" – Kleptine Dec 26 '10 at 20:12
  • Oh, you did not mention that you upgraded to SDK v8 when you encountered the problem. Yes, the SDK is more strict now when it comes to ordering format strings. :) – Zarah Jan 09 '11 at 18:06
  • It can't be, we can find this problem in android sdk examples, SearchableDictionary has this problem ._. – rubdottocom Feb 22 '11 at 16:48
3

For me, it was turning off Instant Run.

Preferences -> Build, Execution, Deployment -> Instant Run -> uncheck "Enable Instant Run to hot..."

Also, I heared killing a goat and draw a pentagram on the office floor with its warm blood helps prevent these kind of problems.

最白目
  • 3,505
  • 6
  • 59
  • 114
3

Delete bin and gen directories from system. Then F5 in eclipse.
This helped me. Nothing else worked for me.

Kjuly
  • 34,476
  • 22
  • 104
  • 118
3

I got this along with an error when the "aapt.exe" update tool was run.

There's apparently a bug in this program when the console build output is set to "Verbose". Changing it to "Normal" fixed it for me.

See this link:

aapt.exe is throwing unhandled exception while building *.apk file for Android project in Eclipse

Community
  • 1
  • 1
Grant K.
  • 31
  • 1
3

Try going to Window->Android SDK manager and update Tools and Android 4.0. This solved my issues.

If that doesnt work, try updating everything.

That totally worked for me!

Reference: Error generating final archive: java.io.FileNotFoundException: xxx\bin\resources.ap_ does not exist

Community
  • 1
  • 1
Sagar Hatekar
  • 8,700
  • 14
  • 56
  • 72
  • Thanks this saved me days of deleting .android dir or the keystore. which none of it worked. Turns out just needed to let the updates fix whatever was wrong. – JPM Jan 17 '12 at 15:56
1

i tried the Notepad Tutorial Exercise 2 and got the same error. i used the wrong API-Level (3). i just switched to level 8 and now it's working fine.

kiddo
  • 11
  • 1
  • this worked for me too, the only thing extra is that you should do a clean after changing the api-level – Kennethvr Dec 23 '10 at 10:06
1

This problem occurred for me after eclipse did some updates. I just went to a backup of my project and took the file that and placed it in the appropriate place in my current project and all worked.

David C
  • 11
  • 1
0

You might need to remove extra files from your assets or res directory. One case I had was having both "A.jpg" and "A.JPG" files in the assets directory. It prevented the resources.ap_ file from being generated.

Danke Xie
  • 1,757
  • 17
  • 13
0

For Android studio, if you are using gradle 2.2.2 just disable shrinkResources into build.gradle file:

 shrinkResources false
0

Goto file->Properties and change the target to the correct version of android. For me it was 1.5 (from the tutorial on hack-a-day)

Anony
  • 1
0

AndroidManifest.xml displayed within Eclipse was out of sync with what was on disk/being read by Android. shutdown restart eclipse and edit AndroidManifest.xml to be correct and clean and build.

Happens due to having two AndroidManifest.xml files and renaming them. Two useful if two apps from same code base. Linking projects with Android is problematic.

maxweber
  • 576
  • 1
  • 5
  • 12
0

first try

clean,build automatically from eclipse

and if not resolved then try uder solution

i found solution why R.class not made by eclipse after making again-2 clean,build etc.

problem is here in strings.xml:

Hello World, HelloAutoComplete!

HelloAutoComplete these are by default created by the eclipse when you create an projects

definitly you are changing the strings.xml for your own requirment sometimes you cleare the string.xmls these two lines from your codes.

it is making problem in AndroidManifest.xml file

so it cant communicating strings.xml

dont delete these two lines from strings.xml

android:icon="@drawable/icon" android:label="@string/app_name"

android:name=".HelloAutoComplete"

android:label="@string/app_name"

regards aarifmohammadkhan@gmail.com

if any one have nay problem in android

welcome for asking questions

Regards aarifmkhan

Padma Kumar
  • 19,893
  • 17
  • 73
  • 130
aarifmkhan
  • 17
  • 2
0

I had both values and values-en folders and it was picking the string from the values-en folder. I deleted the en folder and it was back to normal.

I tried

  1. Clean
  2. Delete gen
  3. restart eclipse
dhaval
  • 2,368
  • 9
  • 35
  • 60
0

Here are a few of the things I did that made this finally work for me.

1) I was using Admob ads, and I didn't have an attrs.xml file in my res/values folder

2) I deleted a line that says "import andriod.R" from my main activity, and all my resources connected again and this ultimately made the error go away.

3) The last thing I had wrong is I had a "lib" folder instead of a "libs" folder that held my Admob jar file.

Lastly, I cleaned the project after these changes.

So, hopefully this helps someone else having this same error if none of the above fix the problem.

Ben Mc
  • 2,038
  • 6
  • 30
  • 37
0

I had the same problem and after digging around the different output Eclipse provides discovered that the issue had to do with a malformed 9-patch image.

I discovered the issue in the Problems output (Alt-Shift-Q then X).

Salsero69
  • 2,160
  • 3
  • 23
  • 27
0

I had the same error message and it was caused by having a backslash character in one of my string resource values (in the file: res/values/strings.xml).

I had to remove the offending character and clean the project before it would build.

ninjaPixel
  • 6,122
  • 3
  • 36
  • 47
0

1 - Try Project > Clean and rebuild project

2 - If clean does not solve this issue, check ALL log in your Console view in Eclipse.

The issue may not be reported at the end of the Console view. In my case, it was a drawable that does not respect the 9-patch format. This was reported somewhere in the Console view but not at the end !!!

Sly
  • 2,105
  • 5
  • 22
  • 28
0

Delete any 9 patch drawables created in gimp and refresh.

Arunabh Das
  • 13,212
  • 21
  • 86
  • 109
0
  1. Delete bin and gen on filesystem.
  2. Refresh (F5) project in Eclipse.
Paul Turchenko
  • 831
  • 6
  • 8
0

I faced the same issue. And I fixed it by removing newly added png file. It was not able to generate resources.ap file because of one of my png file in drawable.

Bala
  • 4,427
  • 6
  • 26
  • 29
0

I got this problem after the upgrade to Android SDK Tools 15. It was also related to the PNG image as some other replies indicate. After analyzing the Eclipse Console output I found out that the process aapt.exe is crashing while processing of one of the images. More precisely it was in the step labeled as "Including resources from package". To identify the file causing the problem I scanned the Console output, found 3 calls of aapt.exe and each of them I re-ran in the Windows Console. The third one ("aapt.exe package -v -S ...") crashed on one of my PNG files. After I replaced this file (in all supported resolutions) the problem has gone.

Jan
  • 9
0

If you use SurfaceView and have recently changed the name of the package, you might want to check any XML tags that refer to the class.

inmyth
  • 8,880
  • 4
  • 47
  • 52
-3

Try run your Eclipse as administrator.

Guest
  • 1