Lua runtime errors on device, but not in simulator

I’ve recently been running into this problem when testing my app on device, but I don’t get any errors on the simulator.

Testing on an iPad 2, I get the following message in the console and the app stops executing instructions:

<notice>: Lua Runtime Error: lua_pcall failed with status: 2, error message is: Nil string: ''<br>

This happens before any assets are loaded, so the screen remains black.

Then, it spits this out:

<br><br>Feb 3 14:56:58 unknown dataaccessd[54] <notice>: 18e790|DA|Error|AccountID: XXXXXXXX-XXXX-4E1D-XXXX-XXXXXXXXXXXXX ("Exchange")<br> Stats DAStatusReport 0x19b010: {<br> DASRAccountType = Exchange;<br> DASRDisplayName = Exchange;<br> DASRFailedNetworkRequests = 2;<br> DASRPersistentUUID = "XXX";<br> DASRTimeInNetworking = "10.75413697957993";<br> DASRTimeSpan = "470889.9707400203";<br> }<br> is <asdaemonaccount:>: accountID XXXXX persistentUUID XXXXX<br> DATaskManager <astaskmanager:> state:Nominal<br> Active exclusive task: (null)<br> Queued exclusive tasks: (null)<br> Independent tasks: (null)<br> Held independent tasks: (null)<br> Modal-held independent tasks: (null)<br> Active queued task: (null)<br> Queued tasks: (null)<br> Active modal task: (null)<br> Queued modal tasks: (null)<br> <br> Associated with account: <asdaemonaccount:>: accountID XXXXX persistentUUID XXXXX<br> <br> Policy manager: <asdaemonpolicymanager:><br> Number of tasks in task to ID map: 0<br> Get Options task: (null)<br> Policy Key Update task: (null)<br> Last ping HBI 0<br> _foldersToMonitorById: 5:Inbox<br> _folderIdsWithUnacknowledgedPings: <br> _busyFolderIds: <nscountedset:> ()<br> _pingBlacklistFolderIds: {(<br> )}<br> =======<br><br>...<br>
and so on.

I’m in the process of narrowing down the problem, but in the meantime I thought I’d ask if this has happened to anyone else. Anyone know what could be causing it? I thought it might be sound related as I just added that to the app, but after removing it all I still have the same problem. [import]uid: 120 topic_id: 21349 reply_id: 321349[/import] </nscountedset:></asdaemonpolicymanager:></asdaemonaccount:></astaskmanager:></asdaemonaccount:>

Well, I’ve narrowed it down to having something to do with reading files.

This is my code for reading and writing json files from tables:

local jsonFile = function( filename, base )  
  
 -- set default base dir if none specified  
 if not base then base = system.ResourceDirectory; end  
  
 -- create a file path for corona i/o  
 local path = system.pathForFile( filename, base )  
  
 -- will hold contents of file  
 local contents  
  
 -- io.open opens a file at path. returns nil if no file found  
 local file = io.open( path, "r" )  
  
 if file then  
 -- read all contents of file into a string  
 contents = file:read( "\*a" )  
 io.close( file ) -- close the file after using it  
 end  
  
 return contents  
end  
local jsonSave = function( filename, dataTable, base )  
  
 print("blah " .. tostring(base))  
  
 if not base then base = system.DocumentsDirectory; end  
  
 --encode table into json string  
 local jsonString = json.encode( dataTable )  
  
  
 -- create a file path for corona i/o  
 local path = system.pathForFile( filename, base )  
  
  
 -- io.open opens a file at path. Creates one if doesn't exist  
 local file = io.open( path, "w" )  
  
 if file then  
 --write json string into file  
 file:write( jsonString )  
 -- close the file after using it  
 io.close( file )  
 end  
  
  
end  

and this is how i’m calling it:

settingsData = json.decode(jsonFile("settings.json", docsPath))  

and my docsPath is:

local docsPath = system.DocumentsDirectory  

It still works fine in the simulator, but not on the device. Is it a permissions issue? Is there something glaring that I’m overlooking? [import]uid: 120 topic_id: 21349 reply_id: 84597[/import]