Hey @CoronaStaff ,
I got a really weird building bug, that breaks my entire project.
Sadly I’m not able to reproduce it on a smaller scale, so I hope my discription is enough to suggest a solution.
In short
I got a number of functions called in a row (around 10) and each function calls other stuff inside itself. When I remove one of those functions (no matter which) everthing works fine, but when they are all in, the built apk file is around 3,5 MB smaller and crashes on start.
The setup
My project is devided into several modules (files) that are all loaded at the start. Every screen in my game is a single file (I don’t use composer) and there is a “master” module that handles all the screens.
At the start of the app this master module calls the “draw” functions of every screen in the game one after another, which than create all the games graphics.
The problem
In the simulator everything works fine and when I build the project (for android) there are no errors or warnings, it just builds the project. But when I test the app on a device, it crashes immediately after launch (sometimes a previously created graphic is shown for hlf a second).
The testing
I tested my code and the builds alot after that. Fortunetly I had a working build one day earlier and the strange thing is, that the newer not working build was about 3,5 MB smaller, than the working one. (assets stayed the same) I unpacked both APK files to look for the cause of the loss in size. In fact some off the classes.dex files were missing or smaller.
I used that as a starting point, commented out everything and commented it back in one after another. Finally, I found the cause. As I mentioned above I loaded all screens one after another and when I removed the last screen from this list, the build worked fine.
The thing is, it doesn’t matter, which one is the last screen. I switched their order and as long as the draw function of the last screen (no matter which screen was the last) wasn’t called, the build worked fine (right file size) and worked on my device.
But it gets stranger from here on:
I removed everything from that last function, so the last draw function (which caused the bug) was empty, and commented it back in. Despite that the bug still occured!
As the bug basically occured an calling an empty function I thought it should work with any function. So I removed the last draw function call and replaced it with math.random(). And guess what, the bug occured.
--this build works TitleScreen:draw(graphicObj) PregameScreen:draw(graphicObj) GameScreen:draw(graphicObj) PauseScreen:draw(graphicObj) ResultScreen:draw(graphicObj) VideoScreen:draw(graphicObj) RestartScreen:draw(graphicObj) OptionsScreen:draw(graphicObj)
--this build fails TitleScreen:draw(graphicObj) PregameScreen:draw(graphicObj) GameScreen:draw(graphicObj) PauseScreen:draw(graphicObj) ResultScreen:draw(graphicObj) VideoScreen:draw(graphicObj) RestartScreen:draw(graphicObj) OptionsScreen:draw(graphicObj) math.random()
It also works to put the last function into the function before:
--this build fails TitleScreen:draw(graphicObj) PregameScreen:draw(graphicObj) GameScreen:draw(graphicObj) PauseScreen:draw(graphicObj) ResultScreen:draw(graphicObj) VideoScreen:draw(graphicObj) RestartScreen:draw(graphicObj) OptionsScreen:draw(graphicObj) CreditsScreen:draw(graphicObj)
--this build works TitleScreen:draw(graphicObj) PregameScreen:draw(graphicObj) GameScreen:draw(graphicObj) PauseScreen:draw(graphicObj) ResultScreen:draw(graphicObj) VideoScreen:draw(graphicObj) RestartScreen:draw(graphicObj) OptionsScreen:draw(graphicObj) --at the top of this function CreditsScreen:draw(graphicObj) is called
The thoughts
Soo, I think it maybe has something to do with the fuction stack, maybe there are too many functions on that stack (which the compiler couldn’t handle)? I don’t know. I tested with the current stable and daily builds unfortunetly I was not able to test for iOS yet.
Would be really great to get some help here (in fact I’m quite nervous, as I have to fullfill a milestone on monday), thanks alot allready 
If there are any detail questions, let me know.