No issue in Corona Simulator, but there are MAJOR issues after app is compiled into an apk

Hello!

I have encountered a problem with my app.  My friends are also having a similar issue with their apps.

In Corona simulator the app works perfectly, but once it is compiled into an apk and run on a phone, the app doesn’t work.  To be more specific; certain objects aren’t shown, like the background.  The timer also doesn’t work.

Here are some images of the app working in Corona:

[spoiler]

The Help Screen:

[/spoiler]

The game  not  working on my Phone.

[spoiler]

01fe44f0f7.png

The Help Screen:

e047c0e370.png

[/spoiler]

Here is the main.lua file:

[spoiler]

--Author: Oliver Duce --App: Base Defend! --Date: 2015 --Define the variables rotateAmt = 5 rotateMin = -90 rotateMax = 40 turretRotation = 0 turretForce = 1000 playerPoints = 0 targetHit = false timeLeft = 500 --Define the functions function makeInterface( ) --up button upButton = display.newImage('up\_button.png', 30, 100) upButton:scale(0.3, 0.3) upButton:addEventListener('touch', moveUp) --down button downButton = display.newImage('down\_button.png', 30, 160) downButton:scale(0.3, 0.3) downButton:addEventListener('touch', moveDown) --fire button fireButton = display.newImage('fire\_button.png', 590, 130) fireButton:addEventListener('touch', fire) --display turret parts turretBase = display.newImage('turretB.png', 160, 300) turretBase:scale(0.2, 0.2) turretBarrel = display.newImage('turretTop.png', 162, 285) turretBarrel:scale(0.2, 0.2) turretBarrel.anchorX = 0.2335907335 turretBarrel.anchorY = 0.7861635220 --display score scoreDisplay = display.newText( ('Points: ' .. playerPoints), 330, -10, native.systemFont, 20 ) scoreDisplay:setFillColor( 0, 0, 255 ) scoreDisplay:translate(display.contentHeight /2, 30) --Show Help function showHelp( ) transition.to(helpScreen, {time = 500, y = helpScreen.height/2}) end --Hide Help function hideHelp( ) transition.to(helpScreen, {time = 500, y = -helpScreen.height}) end --Display the help button helpBtn = display.newImage('helpBtn.png', 590, 330) helpBtn:addEventListener ("tap", showHelp) --Display the graphic off screen helpScreen = display.newImage('helpScroll.png') helpScreen.x = 101 helpScreen.y = -helpScreen.height helpScreen:toFront() helpScreen:addEventListener('tap', hideHelp) end function update( ) --decrease the time counter timeLeft = timeLeft - 1 scoreDisplay.text = 'Points: ' .. playerPoints .. ' Time: ' .. timeLeft --check if the time has run out if (timeLeft \<= 0) then --display the final score scoreDisplay.text = 'Final Score: ' .. playerPoints --remove all of the screen objects display.remove(turretBase) display.remove(turretBarrel) display.remove(target) display.remove(upButton) display.remove(downButton) display.remove(fireButton) --display the 'game over' sign gameOver = display.newText("Game Over", 320, 180, native.systemFont, 50 ) gameOver:setFillColor( 255, 0, 0 ) end --check if the target has been hit if (targetHit == true) then targetHit = false playerPoints = playerPoints + 5 timeLeft = timeLeft + 100 Hit = display.newImage('hit.png', target.x--[[250]], target.y)--145 Hit:scale (0.3, 0.3) --replace the target with the hit picture transition.dissolve(Hit, target, 1000, 0) display.remove(bullet) --put the target back to a random position target.x = math.random(300, 500 ) target.y = math.random(50, 300 ) end end function onCollide(event) targetHit=true end function fire(event) --only fire at the beginning of a touch event if (event.phase == 'began') then media.playSound('bang.wav') bullet = display.newImage('cannonball.png') --move the image bullet.x, bullet.y = turretBarrel:localToContent(220, -30) bullet:scale(0.3, 0.3) bullet.rotation = turretRotation --apply physics to the turretball physics.addBody( bullet, { density=10.0, friction=10.0, radius=5 } ) --determine the appropriate ratio of horizontal to vertical force force\_x = math.cos(math.rad(turretRotation)) \* turretForce force\_y = math.sin(math.rad(turretRotation)) \* turretForce --fire the turretball bullet:applyForce( force\_x, force\_y, bullet.x, bullet.y ) end end function moveDown(event) --only move the barrel if the touch event started if (event.phase == 'began') then turretRotation = turretRotation + rotateAmt if (turretRotation \>= rotateMax) then turretRotation = rotateMax end turretBarrel.rotation = turretRotation fireButton.rotation = turretRotation end end function moveUp(event) --only move the barrel if the touch event started if (event.phase == 'began') then turretRotation = turretRotation - rotateAmt if (turretRotation \<= rotateMin) then turretRotation = rotateMin end turretBarrel.rotation = turretRotation fireButton.rotation = turretRotation end end function makeTarget( ) target = display.newImage('plane.png') target:scale(0.3, 0.3) target.x = math.random(300, 510) target.y = math.random(50, 220) physics.addBody(target,{density=1.0, friction=0.5, bounce=0.05, radius=25}) target.bodyType = 'static' target:addEventListener('collision', onCollide) end --Define control structure function init( ) display.setStatusBar(display.HiddenStatusBar) background = display.newImage('bg2.png', 320, 180) soundtrack = media.playSound('soundtrack.mp3', true) physics = require('physics') physics.setDrawMode('normal') physics.start( ) makeInterface( ) makeTarget( ) Runtime:addEventListener('enterFrame', update) end --Call the code init( ) &nbsp;

[/spoiler]

Here is the config.lua:
[spoiler]

application = { content = { width = 360, height = 640, scale = "zoomStretch", fps = 60 } }

[/spoiler]

And finally, the build.settings:

[spoiler]

settings = { orientation = { default = "landscape", } }

[/spoiler]

How do I fix this?  Help would be greatly appreciated!

Thank you,

-Oliver

When issues like this arise, more often than not it’s a case-sensitivity issue. The simulator is not picky about incorrect uppercase/lowercase letters in file names, but devices are. For example, since your background image is not showing up on device, and your code references “bg2.png” (all lower-case), make sure that the file name is all lower-case, because if the file is actually called “BG2.png”, then that’s not going to work on the device, even if it works in the Simulator. Of course, it might be something else, but it sure sounds like you’ve got a simple case of incorrect capitalization in your code. If so, then it’s an easy (if tedious) fix. Good luck!

Thanks. I’ll check it out.

require my module (https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2015/01/caseDetectError.zip) to your project (at top of main) and it will tell you about case errors as it encounters them in the simulator.

The zip includes the module and a sample usage.

It provides checking for (LUA and Resource file-accessing):

  • require()
  • display.* functions
  • graphics.* functions
  • widget.* functions
  • composer.* functions

Also its very important to learn to debug your code by looking at the device’s console log.  We have a great guide on debugging here:

http://docs.coronalabs.com/guide/basics/debugging/index.html

This should be a built-in corona “check box” option when running the simulator. So many folks run into this, and I can’t imagine it’s that crazy of a thing to support (especially with a pre-existing community module).

When issues like this arise, more often than not it’s a case-sensitivity issue. The simulator is not picky about incorrect uppercase/lowercase letters in file names, but devices are. For example, since your background image is not showing up on device, and your code references “bg2.png” (all lower-case), make sure that the file name is all lower-case, because if the file is actually called “BG2.png”, then that’s not going to work on the device, even if it works in the Simulator. Of course, it might be something else, but it sure sounds like you’ve got a simple case of incorrect capitalization in your code. If so, then it’s an easy (if tedious) fix. Good luck!

Thanks. I’ll check it out.

require my module (https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2015/01/caseDetectError.zip) to your project (at top of main) and it will tell you about case errors as it encounters them in the simulator.

The zip includes the module and a sample usage.

It provides checking for (LUA and Resource file-accessing):

  • require()
  • display.* functions
  • graphics.* functions
  • widget.* functions
  • composer.* functions

Also its very important to learn to debug your code by looking at the device’s console log.  We have a great guide on debugging here:

http://docs.coronalabs.com/guide/basics/debugging/index.html

This should be a built-in corona “check box” option when running the simulator. So many folks run into this, and I can’t imagine it’s that crazy of a thing to support (especially with a pre-existing community module).