Search Unity

AppBundle apk spliting by screen density

Discussion in 'Android' started by BBO_Lagoon, Sep 17, 2019.

  1. BBO_Lagoon

    BBO_Lagoon

    Joined:
    Mar 2, 2017
    Posts:
    200
    Hi,
    I would like to know if there is a way to use the AAB apk splitting like the app thinning feature on IOS build.
    As I understand in the Android App Bundle documentation a split is done on the res/drawable-{density} folders.

    Is there a way to put AssetBundle there at compile time ?
    For exemple if I have variants SD and HD, adding the SD bundle in res/drawable and the HD one on res/drawable-xxhdpi ?

    And then how to access this folder to retrieve my bundles when the game is running ?

    Thanks for any advice.
     
  2. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,167
    The files in res/ are usable as Android resources from Java/Kotlin. Unity uses its own serialization system, so we don't make much use of res/ folder other than app icons.

    So, to answer your question:
    - it is not possible to split by screen density out of the box in Unity. By using plugins and custom build pipe, one could probably add support for it, however
    - Unity doesn't make use of res/ and screen densities there, so there is not much point in doing this at all.

    Hope that helps.
     
  3. BBO_Lagoon

    BBO_Lagoon

    Joined:
    Mar 2, 2017
    Posts:
    200
    Hi Yury

    By using plugins and custom build pipe, one could probably add support for it, however

    It's exactly what I planned to do, but I'm not very familiar with Android file system.
    That's why I asked for some advice on how to put file on the res folder at compile time and how to retrieve them at runtime.

    Apparently to get files from the res folder I have to write a native plugin to read from the folder, I think I could have one to get files in res folder and copy them to the streaming asset folder on the first launch of the game for example.
    Now I Just have to find a way to add the files in the res folder at compile time ;)
     
  4. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,167
    If you're doing a custom build pipeline, you could just add the necessary files to res/ directory of the intermediate directory (next to the icons). It should be packed by Gradle automatically.