Search Unity

Issue: non-Java resources from jar libraries are not included in final apk

Discussion in 'Android' started by vzasadnyy, Feb 18, 2015.

  1. vzasadnyy

    vzasadnyy

    Joined:
    Jun 10, 2013
    Posts:
    13
    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 case of Unity, there is no easy way to modify apk build process.

    There was a similar issue reported before. Suggested solution was to copy missing resources to Assets/StreamingAssets folder, but it's not going to work for us because we're using third party jar We need to find a way to modify apk build process.

    Just for reference, here is a simplified (complete workflow) diagram for Android apk build process:

    Sample Unity project can be downloaded here.

    Any ideas how to solve this issue?
     
  2. hd.exo

    hd.exo

    Joined:
    Jul 24, 2014
    Posts:
    7
    I think you can unpack the jar and copy its the contents of its res/ folder to Plugins/Android/res/
     
  3. vzasadnyy

    vzasadnyy

    Joined:
    Jun 10, 2013
    Posts:
    13
    Actually no. There is no res/ folder inside a jar. In our case, we're missing java properties file located in com.company package (aka com/company/ folder).
     
  4. tgraupmann

    tgraupmann

    Joined:
    Sep 14, 2007
    Posts:
    828
    I ran into exactly the same issue and filled bug report case 679543.

    In my case the JAR contains "strings.properties" and "strings_zh.properties" which are not being included.
     
  5. vzasadnyy_getsocial

    vzasadnyy_getsocial

    Joined:
    Mar 5, 2015
    Posts:
    1
    In our case, we were missing .properties file as well. As we had access to library source code, we hardcoded values from properties file directly to java code.

    It's a quick fix rather than a solution but had to deal with a problem ASAP.
     
  6. TLO

    TLO

    Joined:
    Oct 16, 2013
    Posts:
    3
    So did anyone find a workaround for this?

    I've got 3 .properties files in a jar file that I think Unity might be removing. How can I stop that happening?