Unity issue: non-java resources are not included in final apk

Prehistory

Starting from January I’m working for a company called GetSocial. We are focused on powering more engagement, players and revenue for games by providing easy-to-integrate social building blocks. We already have Android and iOS SDK published, and my first task was to build Unity SDK on top of native ones.

Actually an issue

Recently I found that non-java resources (e.g. images, properties, xml configurations) from included jar libraries are not copied to the final apk during Unity Android build. As a result as soon as we try to load them from a java side - application crashes with I/WindowState﹕ WIN DEATH: Window... exception.

During native Android SDK development, we had the similar issue but it was easily solved by additional gradle configuration. In the case of Unity there is no easy way to modify apk build process. For sure you can make some magic with apk decompilation, modifying and packaging back, but that’s not the solution we’re looking for.

Here is a simplified diagram for Android apk build process:

Temporary solution

For a temporary solution, there are two approaches:

Magic with Android SDK. Create a wrapper for apkbuilder tool and add missing resources in this step. This approach could be the only way if you don’t have access to library source code.

Hassle with source code. If you’re missing configuration files and have access to source code, it’s possible to hardcode values directly to java code to remove all references to resources.

About

Hi, my name is Vitaliy. My background includes mobile application and game development, tech leadership and conference organization. Nowadays, I'm leading development of the next generation in-app marketing tools at the Dutch startup GetSocial. I'm a frequent speaker at conferences, an active member of various technical communities and a founder of the Google Developers Group Lviv.