Search Unity

Buttons, after building the APK, are incomplete. Need assistance.

Discussion in 'Android' started by Max_Bol, Sep 29, 2019.

  1. Max_Bol

    Max_Bol

    Joined:
    May 12, 2014
    Posts:
    168
    Greetings all.

    I'm currently at this phase where I try building an Android version of my game.
    I got a bunch of tablets and phones around me with different version of Android, different specs, etc.

    I'm facing one dire issue which makes no sense at all.
    To put it in simple terms, after building the APK, some UI buttons seems to be stripped out of some part of their codes.

    If those codes were something unique or extremely complex, I would look into it, but the strange thing is that the buttons, while persistent (after multiple build, all have the same issues at the exact same buttons), have similar buttons that uses a semi-identical effect and those still works.

    An even stranger thing is that some "part" of the scripts actually work.
    While I haven't started yet to build-in some additional debug tool just for the sake of finding out what works or not. (Gotta build in a Console windows just to post whatever works or not. Big pain in the butt.)

    For most of my buttons, I'm using a single function that runs with a Integer and a Switch() statement. This allow me to easily set up multiple buttons at once and change their input effect by simply attributing a new Integer to their input effect. It normally works all right.

    I double checked and also tried all the buttons in the Editor and all works.
    I even tried to build a PC standalone version of it and it works 100% fine.

    Yet, the Android version seems to have some missing codes because all the buttons are recognized and their button behavior are shown (changing tint). Each button have their sound effect in that same script and the sound plays. Even at the end of the general button script, I'm forcing the game Event System to deselect the button since it's touch-based and not "input" based.

    Ultimately, every button run this way:
    Code (CSharp):
    1. public void ButtonEffect(int a) {
    2.             switch(a){
    3.             default:
    4.                         Debug.Log ("Button has not be set yet.");
    5.             break;
    6.             case 1:
    7.                         PlaySound(1);
    8.                         ChangeActiveMenu(0);
    9.             break;
    10.             }
    11.             EventSystem.current.SetSelectedGameObject(null);
    12. }
    Imagine that script where each case is 1 button effect. Yeah, some menu has as much as 60 cases, but it's easy to follow up if you structure things well.

    In the example above, the PlaySound(1); is a simple function that play a sound on a permanent object. (Menu sounds and BGM are all working like that.).
    The ChangeActiveMenu(0); is a function that manage what is happening when the menu changes. Making IU element disappears, updating things, etc.

    About 90% of the buttons works as intended.
    About 8% of the buttons play the sound, but not the action following (like ChangeActiveMenu() above). Note that some other button uses the same stuff, but work 100%. They are also deselect.
    2% of the buttons don't play the sound, but do deselects.

    At first, after looking up if the button had some sort of special stuff, I though it might have something to do with whenever a button save/load something, but strangely the problem occurs even on some of the button that simply change some object visibility with SetActive(). Also, I divided the saving process into 2 save files : Options & Game saves and the Options (which uses the same process as the Game save, but toward a different target file) works 100% while I can't yet verify the Game Save because every buttons that precedes the parts where I can check it fails to fully work. (It's really like a curse. That button that add a character and save? Don't work. That menu that allow you to check the character list? The one in the menu before it doesn't work.) It's totally inconsistent which is why I have lost about a lot of time just trying to find out the how it happens.

    I got the build from over 30 days ago which works 100%.
    Even some part that doesn't work now works in the previous build.

    Has anyone ever experienced the same kind of problem?
    Any idea about why some button have their script stripped from certain codes while other don't (even if the code is 99% identical)?

    To top it off, I'm having the worse time of my life with completely insane illogical stuff that has never happened before. It all started after I tried to build some Android build.

    While I tried to build a PC version to see if the problem occurs in a build that isn't in the Editor, just in case. Made the build, then the Windows tells me I lack permission to access the file... then BitDefender instantly erase the .exe file without even asking me. (Because the file has a treat called "Suspicious.Cloud.2.Nu0AaCw5D5mi") It's not even send in quarantine... but deleted. Poof!
    Try to launch the game without the .exe.
    Then I add the whole Unity projects' folder to the Bitdefender's exclusion and try to rebuild the game.
    Now, the build fails and the reason being "Moving file Failed : Access is Denied" in that exact folder I made the previous build in. I'm thinking "Well, maybe the AV did something and the folder is corrumpted or something. Try building it in a new folder result in the SAME error.
     
  2. Max_Bol

    Max_Bol

    Joined:
    May 12, 2014
    Posts:
    168
    An update on the stuff I have tried.

    I have tried different kinds of build of the same project.

    PC (Windows) Build works 99.99%*
    WebGL build works 99.99%*
    Here's a link to try out the game in WebGL: Link
    (It's a link toward my own website on which I put a special public HTTL folder in which I put stuff I allow people to freely access. The quality of having an unlimited storage for web hosting service with my website, I guess.)

    * The missing 0.01% is some sort of crash that happens only once in every instance often.
    My guess is that it's related to how Unity compile and uses the OS register. I might have to force up a bit of loading time just to allow Unity to properly compile before loading. Still, once the game has launched once (and mostly crashed), it works normally ever after because the registry were created prior to the crash.

    I don't have any iOS or Mac devices so I can't test them out yet.

    I'll be trying to try it on a Linux Rasberry pie3 later.

    The problem is persistent when building for Android regardless of if I'm building with Mono or IL2CPP backend which usually means it might be related to something within the APK or JDK.

    I'll be trying to replicate the problem in a small project and I'll submit a bug report at some point.

    This problem has put some heavy setback on my goal of publishing the project onto the Google Store.

    In case some might wonder Why haven't you tried to build some development build before?, note that I did tried mobile builds before. I haven't tried any build since the point where I couldn't because the game is so much optimized toward low garbage collection and recycling blocks of data that it had to be build as 1 piece up to a certain point.

    To give everyone an idea, the game is fully in 3D and yet it can run at 40 FPS on a device that has barely 1GB of RAM and a Dual Cores CPU @ 1.2Ghz. It runs at 20 FPS on my LG-K121 smart phone which is a low-end smartphone from 2015. (It has difficulty properly launch Googe Play since 2 years.)

    As a matter of fact, the WebGL version of the game linked above works on MOBILE browsers!
    It's a 3D game that renders in a browser on my tablets.
    On a small tablet (8") with 1GB of RAM, 1.3Ghz QuadCore Cpu, it runs at approx. 15-20 FPS in Chrome.
    On a medium tablet (10") with 2GB of RAM, 1.3Ghz QuadCore Cpu, it runs at approx. 20-25 FPS in Chrome.

    And yet, building an Android build has issues.
     
  3. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Your Debug.Log statements will show in the Android device logs, a very easy way to debug a build when running on a phone, using "adb logcat | grep -i unity" which I use almost every day for troubleshooting customer issues. Handy skill to have!