Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How To Exclude Files in "/res" Folder of an Android Eclipse Project

Is there any way to exclude certain files under the /res folder from being processed by the Android builder?

I have several Android projects, which I build using Eclipse. I uploaded these projects in our version-control system. The problem is, the version-control adds some "project.pj" file to every folder.

Because of these project.pj files, my projects won't build in Eclipse anymore. I get errors because the builder tries to process these files under /res. I know I can exclude these files for the /src and /gen folders, but how do I exclude them for the /res (and /assets) folders?

like image 799
rainai Avatar asked Feb 15 '12 07:02

rainai


People also ask

How do I exclude files in eclipse?

Navigate to the file/folder you want to exclude. Right Click -> Resource -> Exclude from build.

What is exclude file?

If you exclude a file from a Web Site project (not Web Application), Visual Studio will simply add the . exclude extension to that file. If you remove the extension, that file will be included again. It's up to you if you still need those files or not.

How do I exclude files from Visual Studio project?

In Visual Studio, right-click on the file to be excluded from build, choose Properties, Configuration Properties -> General -> Excluded From Build -> Yes -> OK.


3 Answers

If you prefix any file name with a period (.) it'll be hidden from Eclipse and not included in your build.

If you're on a computer running Windows, you'll still be able to see them without issue in the Explorer. If you're on a Mac, you'll need to make sure that hidden files are being revealed if you ever want to find the file again.

like image 118
ArtOfWarfare Avatar answered Nov 14 '22 23:11

ArtOfWarfare


actually, there are a couple of ways to get aapt to ignore such resources.

one such way is with the --ignore-assets to command-line invocation, if you can affect that (perhaps in build.xml if used).

you can also use aapt.ignore.assets= in your ant.properties, if you have that.

like image 30
john.k.doe Avatar answered Nov 15 '22 00:11

john.k.doe


aapt is the program that processes the files under res/. There's no way to tell it to ignore certain files. So, short answer: you can't. Your VCS is poorly suited to Android projects. Have you heard of git?

That said, your build system can be extended to move these unwanted files out of the way, run aapt, and then move them right back. As you're using Eclipse, accomplishing this means hacking its Android plugin to add these additional steps. Or perhaps writing your own plugin that performs these steps around a call to the Android plugin -- I've never hacked on Eclipse myself, and wouldn't want to. To have any other build system (e.g. using maven, or ant, or make, or scripts) do this is as simple as understanding how that system does anything. Eclipse is just way more involved. As a final option, you can write your own scripts in the project directory that move these .pj files around, and run these scripts yourself at appropriate times, without getting any help from Eclipse.

like image 22
Julian Fondren Avatar answered Nov 15 '22 00:11

Julian Fondren