Ich verwende Sqlite
in einem Xamarin Forms Portable
Projekt und ich meine Bewerbung erfolgreich auf iOS
und UWP
laufen. Unter Android kann ich meine Anwendung auf einem Android 6.0-Emulator ausführen, aber in Android Oreo stürzt sie beim Start ab, obwohl sie installiert ist. Ich stehe vor dem folgenden Problem.Xamarin Forms - Sqlite android Oreo runtime.JavaProxyThrowable
Ausgabe:
android.runtime.JavaProxyThrowable: bei (Wrapper-Managed-to-native) SQLite.Net.Platform.XamarinAndroid.SQLiteApiAndroidInternal: sqlite3_open_v2 (byte [], IntPtr &, int, IntPtr) bei SQLite.Net.Platform.XamarinAndroid.SQLiteApiAndroid.Open (System.Byte [] Dateiname, SQLite.Net.Interop.IDbHandle & db, System.Int32 Flags, System.IntPtr zvfs) [0x00000] in < 8dbf6f f85082469fb9d4dfaa9eae6b69>: 0 bei SQLite.Net.SQLiteConnection..ctor (SQLite.Net.Interop.ISQLitePlatform sqlitePlatform, System.String DatabasePath, SQLite.Net.Interop.SQLiteOpenFlags openFlags, System.Boolean storeDateTimeAsTicks, SQLite.Net. IBlobSerializer Serializer System.Collections.Generic.IDictionary
2[TKey,TValue] tableMappings, System.Collections.Generic.IDictionary
2 [TKey, TValue] extraTypeMappings, SQLite.Net.IContractResolver Resolver) [0x000a2] in < 8f2bb39aeff94a30a8628064be9c7efe>: 0 bei SQLite.Net.SQLiteConnectionWithLock..ctor (SQLite.Net.Interop.ISQLitePlatform sqlitePlatform, SQLite.Net.SQLiteConnectionString connectionString, System.Coll ections.Generic.IDictionary2[TKey,TValue] tableMappings, System.Collections.Generic.IDictionary
2 [TKey, TValue] extraTypeMappings) [0x0002e] in < 8f2bb39aeff94a30a8628064be9c7efe>: 0 bei project.Models.Database + <> c__DisplayClass1_0. < .ctor> b__0() [0x0001d] in < 7df232f34ab8474d9153e3809af4eda8>: 0 bei SQLite.Net.Async.SQLiteAsyncConnection.GetConnection() [0x00000] in < 563d605f9f014eeeb32fd4a27b4d142e>: 0 bei SQLite.Net.Async.SQLiteAsyncConnection + < > c__DisplayClass11_0.b__0 () [0x00006] in < 563d605f9f014eeeb32fd4a27b4d142e>: 0 bei System.Threading.Tasks.Task`1 [TResult] .InnerInvoke() [0x0000f] in : 0 bei System.Threading.Tasks.Task .Execute() [0x00010] in : 0 um mono.java.lang.RunnableImplementor.n_run (native Methode) um mono.java.lang.RunnableImplement or.run (RunnableImplementor.java30)
bei android.os.Handler.handleCallback (Handler.java:789) um android.os.Handler.dispatchMessage (Handler.java:98) um android.os.Looper .loop (Looper.java:164) um android.app.ActivityThread.main (ActivityThread.java:6541) um java.lang.reflect.Method.invoke (Native Methode) um com.android.internal.os. Zygote $ MethodAndArgsCaller.run (Zygote.java:240) bei com.android.internal.os.ZygoteInit.main (ZygoteInit.java: 767)
Um die Verbindung zu erstellen:
public Database(string databaseName)
{
var pathToDatabaseFile = DependencyService.Get<Interfaces.ISQLite>().GetLocalPathToFile(databaseName);
var platform = DependencyService.Get<Interfaces.IPlatformProvider>().GetPlatform();
_connection = new SQLiteAsyncConnection(() =>
new SQLiteConnectionWithLock(platform, new SQLiteConnectionString(pathToDatabaseFile, false)));
_connection.CreateTableAsync<SqlitePage>().Wait();
}
In jedem Projekt GetPlatform
und GetLocalPathToFile
sind implementiert:
return new SQLitePlatformAndroid();
und
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), fileName);
Die Pakete Ich benutze für SQLite sind:
- SQLite.Net.Async-PCL
- SQLite.Net.Core-PCL
- SQLite.Net-PCL
Irgendwelche Ideen?