I'm running into a problem opening a connection on SQL Lite 3 for Android 9 devices. If anyone could help it'd be much appreciated.
**Logcat error dump:**
07-15 19:25:54.573 17006 17063 E Unity : The connection original database timed out:FILE:jar:file:///data/app/Test01.TinyProductions.SatelliteScramble-0GsiyBEDcgggr5RPeginBg==/base.apk!/assets/GameRepo.s3db
07-15 19:25:54.573 17006 17063 E Unity :
07-15 19:25:54.573 17006 17063 E Unity : (Filename: ./Runtime/Export/Debug.bindings.h Line: 45)
07-15 19:25:54.573 17006 17063 E Unity :
07-15 19:25:54.575 17006 17063 E Unity : DllNotFoundException: sqlite3
07-15 19:25:54.575 17006 17063 E Unity : at (wrapper managed-to-native) Mono.Data.Sqlite.UnsafeNativeMethods.sqlite3_open_v2(byte[],intptr&,int,intptr)
CPU: Snapdragon 855
Android version: 9
The game is working on another test device I've got handy (lower android version) and in Unity Editor on Windows, I've got all of my DLLs set up and have the necessary libsqlite3.so files (for both x86 and ARM architectures) under directories:
Android>libs>x86
Android>libs>armeabi-v7a
respectively.
According to the sqlite API, sqlite3 should work up to API level 27 (my best guess is that since this Android version is on API 28 sqlite hasn't yet released an update for this API level). If this is the case, can anyone suggest any alternatives to SQL Lite?
**An Example from DatabaseManager.cs**
In the below, you can see GetConnection:String and Start:Void - two example methods in which a connection to my database should be established. This is working on lower versions of Android OS and in Windows, but not on the Android 9 device and currently unconfirmed on iPhone (though I should be getting confirmation by the end of the month).
String GetConnection() {
String conn, path = "";
switch (Application.platform) {
case RuntimePlatform.Android:
{
path = "URI=file:" + Application.persistentDataPath;
conn = Path.Combine(path, "GameRepo.s3db");
if (!File.Exists(conn)) {
WWW load = new WWW("jar:file://" + Application.dataPath + "!/assets/GameRepo.s3db");
try
{
while (!load.isDone)
{
if (timer > loadTimeout)
{
throw new FileLoadException("The connection original database timed out", load.url);
}
timer += Time.deltaTime;
}
File.WriteAllBytes(Application.persistentDataPath + "/GameRepo.s3db", load.bytes);
}
catch (FileLoadException e) {
Debug.LogError(e.Message + ":FILE:" + e.FileName);
}
}
break;
}
case RuntimePlatform.OSXPlayer:
{
path = "URI=file:" + Application.dataPath + "/Raw";
conn = Path.Combine(path, "GameRepo.s3db");
break;
}
default:
{
path = "URI=file:" + Application.dataPath + "/StreamingAssets";
conn = Path.Combine(path, "GameRepo.s3db");
break;
}
}
return conn;
}
void Start()
{
conn = GetConnection();
Debug.Log(conn);
dbconn = (IDbConnection)new SqliteConnection(conn);
dbconn.Open(); //Open connection to the database.
IDbCommand dbcmd = dbconn.CreateCommand();
string sqlQuery = "SELECT * FROM Puzzle";
dbcmd.CommandText = sqlQuery;
IDataReader reader = dbcmd.ExecuteReader();
while (reader.Read())
{
string puzzleName = reader.GetString(0);
int difficulty = reader.GetInt32(1);
string buttonSpriteUrl = reader.GetString(2);
int puzzleID = reader.GetInt32(3);
}
reader.Close();
reader = null;
dbcmd.Dispose();
dbcmd = null;
dbconn.Close();
dbconn = null;
}
**Expection**: I should be able to connect to an SQLite database on my Android device. Whenever I need to generate a new puzzle piece, I should be able to get the URL to that puzzle piece from my database, along with some information on the puzzle. Whenever I add a player to my device's high scores list, they are added there.
**Reality**: Whenever a connection to SQLite is "opened", I get the DLLNotFoundException, even though all of the necessary dlls are on my system, and all of the correct libs directories have been configured correctly with libsqlite.so for both ARM and x86 architectures
↧