widget.newButton: defaultFile definition expected, got nil

Corona did not show any errors or warnings during when I ran it but when it was converted into .apk, the app could not run! (The orange coloured ones are the part that I think is causing the error) 

local storyboard = require( “storyboard” )

local scene = storyboard.newScene()

require “sqlite3”

function scene:createScene( event )

local group = self.view

local widget = require( “widget” )

local path = system.pathForFile(“scv.db”, system.DocumentsDirectory)

db = sqlite3.open( path ) 

local Sbidayuh

local Siban

local Spenan

local Sulu

local Smelanau

local Smalay

local Schinese

for row in db:nrows(“SELECT * FROM house LIMIT 1;”) do

if (row.bidayuh==“yes”) then

Sbidayuh = “image/house/barok_dicop.png”

else

Sbidayuh = “image/house/bidayuh_button-01.png”

end 

if (row.iban==“yes”) then

Siban = “image/house/iban_cop-01.png”

        else

Siban = “image/house/iban_button-01.png”

end 

if (row.penan==“yes”) then

Spenan = “image/house/penan_cop-01.png”

else

Spenan = “image/house/penan_button-01.png”

end 

  

if (row.ulu==“yes”) then

Sulu = “image/house/orgulu_cop-01.png”

else

Sulu = “image/house/orgulu_button-01.png”

end 

if (row.melanau==“yes”) then

Smelanau = “image/house/melanau_cop-01.png”

else

Smelanau = “image/house/melanau_button-01.png”

end 

if (row.malay==“yes”) then

Smalay = “image/house/melayu_cop-01.png”

else

Smalay = “image/house/melayu_button-01.png”

end 

if (row.chinese==“yes”) then

Schinese = “image/house/cina_cop-01.png”

else

Schinese = “image/house/cina_button-01.png”

end 

end

    local image1 = display.newImage( “image/mapkosong-01.png”, 720, 1024)

image1:setReferencePoint( display.CenterReferencePoint )

    image1.x = display.contentWidth * 0.5

    image1.y = display.viewableContentHeight * 0.5

image1:scale( 1, 1.2)

display.setDefault( “background”, 255, 255, 255 )

local locationnxt = widget.newButton { label = “”,defaultFile = Sbidayuh,

    overFile = “image/house/bidayuh_besar-01.png”, onEvent = buttonnxtTapped }

    locationnxt.x = display.contentWidth/2 + (display.contentWidth*0.30)

    locationnxt.y = display.contentHeight -(display.contentHeight*0.40)

local locationibn = widget.newButton { label = “”,defaultFile = Siban,

    overFile = “image/house/iban_besar-01.png”, onEvent = buttonibnTapped }

    locationibn.x = display.contentWidth/2 + (display.contentWidth*0.30)

    locationibn.y = display.contentHeight -(display.contentHeight*0.61)

local locationpn = widget.newButton { label = “”,defaultFile = Spenan,

    overFile = “image/house/penan_besar-01.png”, onEvent = buttonpnTapped }

    locationpn.x = display.contentWidth/2 + (display.contentWidth*0.27)

    locationpn.y = display.contentHeight -(display.contentHeight*0.82)

local locationulu = widget.newButton { label = “”,defaultFile = Sulu,

    overFile = “image/house/orgulu_besar-01.png”, onEvent = buttonuluTapped }

    locationulu.x = display.contentWidth/2 + (display.contentWidth*-0.08)

    locationulu.y = display.contentHeight -(display.contentHeight*0.86)

local locationmln = widget.newButton { label = “”,defaultFile = Smelanau,

    overFile = “image/house/melanau_besar-01.png” , onEvent = buttonmlnTapped }

locationmln.x = display.contentWidth/2 + (display.contentWidth*-0.23)

    locationmln.y = display.contentHeight -(display.contentHeight*0.68)

local locationmly = widget.newButton { label = “”,defaultFile = Smalay,

    overFile = “image/house/melayu_besar-01.png”, onEvent = buttonmlyTapped }

    locationmly.x = display.contentWidth/2 + (display.contentWidth*-0.30)

    locationmly.y = display.contentHeight -(display.contentHeight*0.49)

local locationcna = widget.newButton { label = “”,defaultFile = Schinese,

    overFile = “image/house/cina_besar-01.png”, onEvent = buttoncnaTapped }

    locationcna.x = display.contentWidth/2 + (display.contentWidth*-0.33)

    locationcna.y = display.contentHeight -(display.contentHeight*0.27)]]–

local locationext = widget.newButton { label = “”,defaultFile = “image/exit_button-02.png”,

    overFile = “image/exit_button-02.png”, onEvent = buttonextTapped }

    locationext.x = display.contentWidth/2 + (display.contentWidth*-0.30)

    locationext.y = display.contentHeight -(display.contentHeight*0.05)

local locationref = widget.newButton { label = “”,defaultFile = “image/restart-02.png”,

    overFile = “image/restart-02.png”, onEvent = buttonrefTapped }

    locationref.x = display.contentWidth/2 + (display.contentWidth*0.3)

    locationref.y = display.contentHeight -(display.contentHeight*0.05)

 group:insert( image1 )

 group:insert( locationnxt)

 group:insert( locationibn)

 group:insert( locationpn)

 group:insert( locationulu)

 group:insert( locationmln)

 group:insert( locationmly)

 group:insert( locationcna)

 group:insert( locationext)

 group:insert( locationref)

  for row in db:nrows(“SELECT * FROM first LIMIT 1;”) do

if (row.gerbang == “yes”) then

local g1 = display.newImage( “image/pintu_gerbang_kanan-01.png”, 720, 1024)

g1:setReferencePoint( display.CenterReferencePoint )

local w,h = display.contentWidth, display.contentHeight

transition.from( g1, { time=1800, alpha=1.0, x=(w-400), y=(h-500) } )

transition.to( g1, { time=1800, alpha=1.0, x=(w-10), y=(h-500) } ) 

g1:scale(1,1.5)

group:insert( g1)

local g2 = display.newImage( “image/pintu_gerbang_kiri-01.png”, 720, 1024)

g2:setReferencePoint( display.CenterReferencePoint )

local w,h = display.contentWidth, display.contentHeight

transition.from( g2, { time=1700, alpha=1.0, x=(w-380), y=(h-500) } )

transition.to( g2, { time=1700, alpha=1.0, x=(w-760), y=(h-500) } )  

g2:scale(1,1.5)

group:insert( g2)

   end

end

end

function buttonnxtTapped( event )

local b = [[UPDATE first SET gerbang=‘no’ WHERE id=1;]]

db:exec(   b  )

if event.phase == “ended” then

for row in db:nrows(“SELECT * FROM bidayuh LIMIT 1;”) do

if (row.ob1==“yes” or row.ob2==“yes” or row.nb1==“yes” or row.nb2==“yes” or row.lh1==“yes” or row.lh2==“yes”)

then storyboard.showOverlay( “bidayuh.gameresume”, {isModal=true})

else

storyboard.showOverlay( “bidayuh.bidayuhHistory”, {isModal=true})

end

end

return true

end

end

function buttonibnTapped( event )

local b = [[UPDATE first SET gerbang=‘no’ WHERE id=1;]]

db:exec(     b  )

if event.phase == “ended” then

for row in db:nrows(“SELECT * FROM iban LIMIT 1;”) do

if (row.lh1==“yes” or row.lh2==“yes”)

then storyboard.showOverlay( “iban.gameresume”, {isModal=true})

else

storyboard.showOverlay( “iban.ibanHistory”, {isModal=true})

end

end

return true

end

end

function buttonpnTapped( event )

local b = [[UPDATE first SET gerbang=‘no’ WHERE id=1;]]

db:exec(       b   )

if event.phase == “ended” then

for row in db:nrows(“SELECT * FROM penan LIMIT 1;”) do

if (row.penan1==“yes” or row.penan2==“yes”)

then storyboard.showOverlay( “penan.gameresume”, {isModal=true})

else

storyboard.showOverlay( “penan.penanHistory”, {isModal=true})

end

end

return true

end

end

function buttonuluTapped( event )

local b = [[UPDATE first SET gerbang=‘no’ WHERE id=1;]]

db:exec(    b    )

if event.phase == “ended” then

for row in db:nrows(“SELECT * FROM ulu LIMIT 1;”) do

if (row.ulu1==“yes” or row.ulu2==“yes”)

then storyboard.showOverlay( “ulu.gameresume”, {isModal=true})

else

storyboard.showOverlay( “ulu.uluHistory”, {isModal=true})

end

end

return true

end

end

function buttonmlnTapped( event )

local b = [[UPDATE first SET gerbang=‘no’ WHERE id=1;]]

db:exec(     b    )

if event.phase == “ended” then

for row in db:nrows(“SELECT * FROM melanau LIMIT 1;”) do

if (row.mln1==“yes” or row.mln2==“yes”)

then storyboard.showOverlay( “melanau.gameresume”, {isModal=true})

else

storyboard.showOverlay( “melanau.melanauHistory”, {isModal=true})

end

end

return true

end

end

function buttonmlyTapped( event )

local b = [[UPDATE first SET gerbang=‘no’ WHERE id=1;]]

db:exec(   b  )

if event.phase == “ended” then

for row in db:nrows(“SELECT * FROM malay LIMIT 1;”) do

if (row.mly1==“yes” or row.mly2==“yes”)

then storyboard.showOverlay( “malay.gameresume”, {isModal=true})

else

storyboard.showOverlay( “malay.malayHistory”, {isModal=true})

end

end

return true

end

end

function buttoncnaTapped( event )

local b = [[UPDATE first SET gerbang=‘no’ WHERE id=1;]]

db:exec(     b  )

if event.phase == “ended” then

for row in db:nrows(“SELECT * FROM chinese LIMIT 1;”) do

if (row.fh1==“yes” or row.fh2==“yes” )

then storyboard.showOverlay( “chinese.gameresume”, {isModal=true})

else

storyboard.showOverlay( “chinese.chineseHistory”, {isModal=true})

end

end

return true

end

end

function buttonextTapped( event )

local b = [[UPDATE first SET gerbang=‘no’ WHERE id=1;]]

db:exec(   b   )

if event.phase == “ended” then

  storyboard.showOverlay( “mainexit”, {isModal=true})

return true

end 

end

function buttonrefTapped( event )

local b = [[UPDATE first SET gerbang=‘no’ WHERE id=1;]]

db:exec(  b   )

if event.phase == “ended” then

storyboard.showOverlay( “restart”, {isModal=true})

return true

end

end

function scene:enterScene( event )

    local group = self.view

end

function scene:exitScene( event )

local group = self.view

end

function scene:destroyScene( event )

local group = self.view

end

local function onKeyEvent( event )

   local phase = event.phase

   local keyName = event.keyName

   print( event.phase, event.keyName )

   if ( “back” == keyName and phase == “up” ) then

      if ( storyboard.currentScene == “mainmap” ) then

         native.requestExit()

      

      end

   end

   return true  

end

Runtime:addEventListener( “key”, onKeyEvent )

scene:addEventListener( “createScene”, scene )

scene:addEventListener( “enterScene”, scene )

scene:addEventListener( “exitScene”, scene )

scene:addEventListener( “destroyScene”, scene )

return scene

Hi @farahnorman95,

In almost every case, this is because of a case mismatch in an actual file name and the name you typed in your code. For example, maybe the actual file name is “Barok_dicop.png” but you accidentally typed “barok_dicop.png” in your code. The Corona Simulator is very forgiving on this point (it will allow case mismatches) but real devices will not accept that. Please check that you matched cases exactly on all of your file names and folders.

Take care,

Brent

Hi @farahnorman95,

In almost every case, this is because of a case mismatch in an actual file name and the name you typed in your code. For example, maybe the actual file name is “Barok_dicop.png” but you accidentally typed “barok_dicop.png” in your code. The Corona Simulator is very forgiving on this point (it will allow case mismatches) but real devices will not accept that. Please check that you matched cases exactly on all of your file names and folders.

Take care,

Brent