Linking assets between desktop and android project in libgdx

Here is a little tip you might find useful when working with two different eclipse projects in your libgdx project.

It is a common scenario to have multiple assets like sounds, textures, animations etc. which you want to reference in your desktop project and in you android project. The simplest way to solve this problem is to simply copy the content in each project but this causes constant work as you need to keep those two in sync.

When on linux, one possible solution is to create a symlink from one assets folder to the other. That works fine but does not work on every platform. Another approach is to create a resource link inside eclipse. This only works when starting your project from within eclipse and is of course not honored by a continuous build system you might use. Additional measures are required (like actually copying the assets or symlinking).

Here is how linking in eclipse is done. Place all you assets in the assets folder of your android project (the assets folder is a prerequisite for an android project). Next open your file explorer. Go to the android project and drag the assets folder from the android project to you desktop project inside eclipse. Eclipse will ask you to either copy, link or link and recreate the folder structure. We choose to link.

When you start your android project it finds the resource because they are physically in your android project and when starting the desktop project, the link allows eclipse to gather the assets from the android project. The cool thing is that eclipse is realizing, that the source assets folder is in the workspace and therefore creates the link relative to the workspace root. That means you can share this linked config accross multiple dev systems with different folder structures. Hope this helps.