Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android 10 release version results in file is not a database error #1241

Open
VAI2MU opened this issue Jul 5, 2024 · 1 comment
Open

Android 10 release version results in file is not a database error #1241

VAI2MU opened this issue Jul 5, 2024 · 1 comment

Comments

@VAI2MU
Copy link

VAI2MU commented Jul 5, 2024

When running the Release version of the app on Android 10, connection to the database is successfully established but on the first attempt to execute an SQL command an exception with the message "file is not a database" happens.

Used in a .net 8.0 Maui application

Packages in use:
PackageReference Include="sqlite-net-sqlcipher" Version="1.8.116"
PackageReference Include="SQLitePCLRaw.bundle_e_sqlcipher" Version="2.1.8"

Also tried with:
PackageReference Include="sqlite-net-sqlcipher" Version="1.9.172"
PackageReference Include="SQLitePCLRaw.bundle_e_sqlcipher" Version="2.1.8"

This issue doesn't appear on the same Android 10 device on Debug mode. It also doesn't appear on any iOS devices or Android 11 devices.

@JonathanWebsdale
Copy link

Seeing the same problem when migrating from Xamarin.Forms application to .NET 8 MAUI.

Attempting to open a connection to an encrypted DB generated using "sqlite-net-sqlcipher" Version="1.5.231" in our Xamarin.Forms app, with our .NET Maui app, using "sqlite-net-sqlcipher" Version="1.9.172"

var connectionString = new SQLiteConnectionString(<DBPath>, SQLiteOpenFlags.Create | SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.ProtectionComplete | SQLiteOpenFlags.SharedCache | SQLiteOpenFlags.FullMutex, true, <DBKey>);
var connection = new SQLite.SQLiteAsyncConnection(connectionString); 

var table = await connection.ExecuteScalarAsync<string>(mySelectQuery);

Results in an exception with the result "SQLite.SQLite3+Result.NonDBFile"

at SQLite.SQLite3.Prepare2(sqlite3 db, String query)
at SQLite.SQLiteCommand.Prepare()
at SQLite.SQLiteCommand.ExecuteScalarString
at SQLite.SQLiteAsyncConnection.<>c__DisplayClass82_01[[System.String, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].<ExecuteScalarAsync>b__0(SQLiteConnectionWithLock conn) at SQLite.SQLiteAsyncConnection.<>c__DisplayClass33_01[[System.String, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].b__0()

Attempting to re-compile and run the .NET MAUI application with version "1.5.231" of the package does work on Android in debug mode, however causes a different exception when attempting to run in iOS.

System.MissingMethodException: Method not found: string SQLitePCL.raw.sqlite3_column_text(SQLitePCL.sqlite3_stmt,int)
at SQLite.SQLiteCommand.ReadCol(sqlite3_stmt stmt, Int32 index, ColType type, Type clrType)
at SQLite.SQLiteCommand.ExecuteScalarString
at SQLite.SQLiteConnection.ExecuteScalar[String](String query, Object[] args)
at SQLite.SQLiteConnection..ctor(String databasePath, SQLiteOpenFlags openFlags, Boolean storeDateTimeAsTicks, Object key)
at SQLite.SQLiteConnectionWithLock..ctor(SQLiteConnectionString connectionString, SQLiteOpenFlags openFlags)
at SQLite.SQLiteAsyncConnection..ctor(String databasePath, SQLiteOpenFlags openFlags, Boolean storeDateTimeAsTicks, Object key)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants