Runtime Error after buling apk

Hello, I am a beginner and just managed to make my first build. It’s running fine in the simulatar but when I start the app in my phone I see the following error:

Runtime Error

 C:\Users\username\docume~1\outlaw\sandbox\38\gamePlay.lua:250: attempt to index local ‘healthDisplay’ (a nil value)

here is what healthDisplay looks like in my code:

  if health==5 then   local healthDisplay = display.newImage("/images/health.png")   healthDisplay:scale(0.6,0.6)   healthDisplay.x =screenRight - 60   healthDisplay.y=screenTop + 17   sceneGroup:insert(healthDisplay)

I have everything I’m using in one folder and it runs fine in the simulator. I don’t know whats going wrong here. Am I doing something wrong while making the apk ? Please Help.

First, the issue -

This:

local healthDisplay = display.newImage("/images/health.png")

should probably be this (no leading forward slash):

local healthDisplay = display.newImage("images/health.png") 

Second, although my module might not catch that, it will help with other common file naming issues:

http://github.com/roaminggamer/RGCaseErrorDetect

Just follow the direction on the page and this should help with other file case naming and similar issues.  You can leave it in your project when building as it turns itself off on devices.

Cheers,

Ed

Okay thanks for this I will test this out and post back

@roaminggamer

removing the forward slash did the trick! Thanks for it. I am also have one more issue if you can answer my that question too I will be thankful to you. here is that thread:

https://forums.coronalabs.com/topic/58887-readingwriting-to-file-saving-high-score-problem/

First, the issue -

This:

local healthDisplay = display.newImage("/images/health.png")

should probably be this (no leading forward slash):

local healthDisplay = display.newImage("images/health.png") 

Second, although my module might not catch that, it will help with other common file naming issues:

http://github.com/roaminggamer/RGCaseErrorDetect

Just follow the direction on the page and this should help with other file case naming and similar issues.  You can leave it in your project when building as it turns itself off on devices.

Cheers,

Ed

Okay thanks for this I will test this out and post back

@roaminggamer

removing the forward slash did the trick! Thanks for it. I am also have one more issue if you can answer my that question too I will be thankful to you. here is that thread:

https://forums.coronalabs.com/topic/58887-readingwriting-to-file-saving-high-score-problem/