Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

How to detect if application binary is split?

Discussion in 'Android' started by AgentParsec, Oct 3, 2016.

  1. AgentParsec

    AgentParsec

    Joined:
    May 5, 2012
    Posts:
    403
    My app was compiled for the Google Play Store with the split binary, and it includes the code to download the .obb file if it's missing. However, I recently compiled the app for Amazon (which doesn't use split binaries), and ran into a problem. Currently, the app detects if the platform is android-based, and if so it does the .obb file check. Since Amazon is also an android platform, it's doing this check as well, causing an error when it doesn't find the .obb file.

    Is there any way to determine automatically at runtime whether or not the binary was split, or do I have to manually change something in the game before I build?
     
  2. jason_yak

    jason_yak

    Joined:
    Aug 25, 2016
    Posts:
    502
    I'm curious about the best way to do this also.. so far I've seen that you can do something like:

    Code (CSharp):
    1. if ( Application.dataPath.ToLowerCase().Contains(".obb") ) { }
     
    vuplex likes this.
  3. jason_yak

    jason_yak

    Joined:
    Aug 25, 2016
    Posts:
    502
    So I think the above will work when there is actually an obb file available, but it's not going to tell you whether it's meant to be a build that has been split and that the obb file isn't available (has been deleted or incorrectly installed). So it's not really a bullet proof way of knowing if the particular build running is using the split option or not.
     
  4. AgentParsec

    AgentParsec

    Joined:
    May 5, 2012
    Posts:
    403
    What I'll probably end up doing is just set a bool somewhere in the loading script, check it when it needs to bypass that, and uncheck it when it doesn't.
     
  5. jason_yak

    jason_yak

    Joined:
    Aug 25, 2016
    Posts:
    502
    Yea I think it's best to just have some hard and fast logic. I've got a custom compiler pipeline for my app, I'm going to inject a custom define / script symbol before compiling if the split binary option is ticked.