ungraceful failure on android [possible bug] [kinda solved]

Creating desktop or client-server database solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
SteveTX
Posts: 170
Joined: Sun Jan 17, 2010 9:00 pm

ungraceful failure on android [possible bug] [kinda solved]

Post by SteveTX » Fri Jul 19, 2013 12:06 pm

I've got an app for mobile. On desktop the database opens / creates just fine. On mobile, the handle halts and doesn't produce additional error output. The standalone settings are set to search for required inclusions, as opposed to declaring libraries/db support. On mobile I can't get revOpenDatabase command to throw an error, it just halts.

Code: Select all

command databaseOpen
   debugIt 3, ("databaseOpen: " & theDatabasePath)
   repeat for each item thisConnection in revOpenDatabases() // close all open database connections
      debugIt 4, ("closing all open databases...")
      revCloseDatabase(thisConnection)
   end repeat
   if there is not a file theDatabasePath then debugIt 2, ("Warning: No Database File Found at " & theDatabasePath)
   put revOpenDatabase("sqlite", theDatabasePath, , , , ) into theDatabaseID // Open the database, create it if it doesn't exist
   debugIt 3, ("databaseOpen: setting database ID to " & theDatabaseID)
   if "Error" is in theDatabaseID then debugIt 1, ("Database Error: " & theDatabaseID)
   if revDatabaseConnectResult(theDatabaseID) is not empty then debugIt 1, ("Database Error: " & the result)
   //initDatabase
end databaseOpen
this produces the following output for desktop on success:
databaseOpen: D:/Program Files (x86)/RunRev/LiveCode 6.1/database.sqlite
Warning: No Database File Found at D:/Program Files (x86)/RunRev/LiveCode 6.1/database.sqlite
databaseOpen: setting database ID to 1
and the following output for mobile failure:
databaseOpen: data/data/org.myapp.appname/files/database.sqlite
Last edited by SteveTX on Fri Jul 19, 2013 8:34 pm, edited 3 times in total.

Klaus
Posts: 14206
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: ungraceful failure

Post by Klaus » Fri Jul 19, 2013 12:30 pm

Hi Steve,

where is -> theDatabasePath?
On mobile you do not have write permissions in -> specialfolderpath("engine")!
Use -> specialfolderpath("documents") instead.

Just a guess...


Best

Klaus

SteveTX
Posts: 170
Joined: Sun Jan 17, 2010 9:00 pm

Re: ungraceful failure

Post by SteveTX » Fri Jul 19, 2013 7:04 pm

Klaus, it is "documents". However, when I shell into the device to look, there is no database.sqlite file in the supposed location.

Code: Select all

command setPath
   debugIt 3, "setPath"
   if the platform = "android" or the platform = "iphone" then
      put (specialFolderPath("engine") & "/resources/") into theResourcesDir
      put (specialFolderPath("engine") & "/fonts/") into theFontsDir
      put (specialFolderPath("documents") & "/database.sqlite") into theDatabasePath // The database must be in a writeable location
   else
      put (defaultFolder & "/resources/") into theResourcesDir
      put (defaultFolder & "/resources/") into theFontsDir
      put (defaultFolder & "/database.sqlite") into theDatabasePath
   end if
   debugIt 3, (" theResourcesDir: " & theResourcesDir)
   debugIt 3, (" theFontsDir: " & theFontsDir)
   debugIt 3, (" theDatabasePath: " & theDatabasePath)
end setPath

SteveTX
Posts: 170
Joined: Sun Jan 17, 2010 9:00 pm

Re: ungraceful failure

Post by SteveTX » Fri Jul 19, 2013 7:48 pm

I checked revOpenDatabases()) and that command just hung. It appears that all the rev Database related commands aren't working on android, even though I've selected to build with database support and all database drivers. I've also tried automatic, that didn't work either.

I then suspected database drivers weren't loading so I checked revGetDatabaseDriverPath()) and the handler hung on that command. So the database drivers aren't loading / are broken despite being explicitly told to build, or rev engine has a problem with android database. This is really starting to look like another bug.

Code: Select all

command databaseOpen
   debugIt 3, ("databaseOpen: " & theDatabasePath)
   if there is not a file theDatabasePath then debugIt 2, ("Warning: No Database File Found at " & theDatabasePath)
   debugIt 3, ("the database driver path is " & revGetDatabaseDriverPath())
   debugIt 3, ("the open databases are " & revOpenDatabases())
   put revOpenDatabase("sqlite", theDatabasePath, , , , ) into theDatabaseID // Open the database, create it if it doesn't exist
   set the defaultfolder to specialFolderPath("documents")
   if "Error" is in theDatabaseID then debugIt 1, ("Database Error: " & theDatabaseID)
   if revDatabaseConnectResult(theDatabaseID) is not empty then debugIt 1, ("Database Error: " & the result)
   //initDatabase
end databaseOpen

SteveTX
Posts: 170
Joined: Sun Jan 17, 2010 9:00 pm

Re: ungraceful failure on android [possible bug]

Post by SteveTX » Fri Jul 19, 2013 8:34 pm

Solved the main issue, but a bug remains. I had not checked the SQLite external for android in build settings. However, even upon doing so, revGetDatabaseDriverPath will cause the application to crash hard. It appears some rev database commands are "unsafe" for android and need to be avoided for now :/

Klaus
Posts: 14206
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: ungraceful failure on android [possible bug] [kinda solv

Post by Klaus » Sun Jul 21, 2013 5:13 pm

"revGetDatabaseDriverPath" is desktop ONLY!
A quick look into the dictionary might solve some headache from time to time... 8-)

Post Reply