0

I have a number of different Android applications building in Eclipse / ADT that share common code and assets. Sharing the common source code folder is easy as I can use Link Source in the Build Path set-up. This works great.

These programs also share the content that's in the assets folder. At the moment I'm duplicating, which is a bit inelegant and error-prone.

Is it trivially possible to tell Eclipse / ADT to use a common assets folder in a similar way that it is trivial to have it share a source code folder? I can't find any similar option or tool.


Notes:

  • I am not looking for a 'library' solution (indeed that seems fraught with issues anyway, and I did try that previously and hit issues like this one). In any case that's less relevant for assets, and I'm looking for simplicity.

  • It doesn't matter if the shared assets folder has to contain a superset of the needs of all the applications.

  • Assets. Not "resources".

  • I'm using ADT version 22.2

  • For many complex reasons, symbolically linking the folders will not suffice. (You do not want to know the details. You'd never believe them anyway.)

Community
  • 1
  • 1
Cheeseminer
  • 2,948
  • 1
  • 20
  • 36

1 Answers1

1

Sharing the common source code folder is easy as I can use Link Source in the Build Path set-up

I would not count on that working over the long haul.

At the moment I'm duplicating, which is a bit inelegant and error-prone.

Alas, given your other restrictions, I suspect that it is your only option, though you could take some steps to reduce the error-prone aspect (e.g., script that synchronized the contents).

Long-term, Gradle for Android will be The One True Answer for all builds, Eclipse included. At that point, I expect your "Link Source" will break. However, at that time, you should be able to cut over to Gradle for your builds.

Gradle allows developers to override the default locations of all sorts of directories, including the assets directory. You should be able to set up a build.gradle file that points to some common location for the assets directory, overriding the default location that looks inside the project itself.

It's unclear why you think that symlinks/hardlinks will not work for you as a stopgap measure. You might wish to consider asking a separate StackOverflow question, explaining what you have tried and what problems you encountered with that technique, whether you think we will believe them or not.

Bear in mind that while Eclipse handles the javac step for the Android build, everything else is largely handled by external tools (e.g., aapt). Those will be oblivious to things that exist solely in Eclipse-land. Conversely, that's why symlinks/hardlinks should work, as from the standpoint of those tools, such items should be treated the same as actual files in the filesystem. Hence, the reason why "Link Source" works is not because Android really supports it, but that Android presently delegates that one piece of the build to Eclipse itself. Once Google adds Gradle for Android support for Eclipse (which I hope will be before the end of 2014), then I would expect Eclipse to be completely cut out of the build process, and I expect "Link Source" to fail at that point.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491