我在Xamarin Forms Portable
项目中使用Sqlite
,我成功运行我的应用程序iOS
和UWP
。在Android上,我可以在Android 6.0模拟器上运行我的应用程序,但在Android Oreo中,虽然安装了应用程序,但它在启动时崩溃。我面临以下问题。Xamarin Forms - Sqlite android Oreo runtime.JavaProxyThrowable
问题:
android.runtime.JavaProxyThrowable:在(包装管理到本机) SQLite.Net.Platform.XamarinAndroid.SQLiteApiAndroidInternal:sqlite3_open_v2 (字节[],IntPtr的&, INT,IntPtr的)在 SQLite.Net.Platform.XamarinAndroid.SQLiteApiAndroid.Open (System.Byte []的文件名,SQLite.Net.Interop.IDbHandle &分贝, System.Int32标志,System.IntPtr zvfs)[0x00000]在 < 8dbf6f f85082469fb9d4dfaa9eae6b69>:0在 SQLite.Net.SQLiteConnection..ctor(SQLite.Net.Interop.ISQLitePlatform sqlitePlatform,System.String databasePath, SQLite.Net.Interop.SQLiteOpenFlags openFlags,System.Boolean storeDateTimeAsTicks,SQLite.Net。 IBlobSerializer串行器, System.Collections.Generic.IDictionary
2[TKey,TValue] tableMappings, System.Collections.Generic.IDictionary
2 [TKEY的,TValue] extraTypeMappings,SQLite.Net.IContractResolver分解)[0x000a2]在 < 8f2bb39aeff94a30a8628064be9c7efe>:0在 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]在< 8f2bb39aeff94a30a8628064be9c7efe>:0 在project.Models.Database + <> c__DisplayClass1_0。 < .ctor> b__0() [0x0001d]在< 7df232f34ab8474d9153e3809af4eda8>:0在 SQLite.Net.Async.SQLiteAsyncConnection.GetConnection()[0x00000]在 < 563d605f9f014eeeb32fd4a27b4d142e>:0在 SQLite.Net.Async.SQLiteAsyncConnection + < > c__DisplayClass11_0.b__0 ()[0x00006]在< 563d605f9f014eeeb32fd4a27b4d142e>:0在 System.Threading.Tasks.Task`1 [TResult] .InnerInvoke()[0x0000f]在 :0在 System.Threading.Tasks.Task .Execute()[0x00010] in :0 at mono.java.lang.RunnableImplementor.n_run(Native Method)at mono.java.lang.RunnableImplement or.run(RunnableImplementor.java:30)
at android.os.Handler.handleCallback(Handler.java:789)at android.os.Handler.dispatchMessage(Handler.java:98)at android.os.Looper .loop(Looper.java:164)at android.app.ActivityThread.main(ActivityThread.java:6541)at java.lang.reflect.Method.invoke(Native Method)at com.android.internal.os。 Zygote $ MethodAndArgsCaller.run (Zygote.java:240)at com.android.internal.os.ZygoteInit.main (ZygoteInit。Java的:767)
为了创建连接:
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();
}
在每一个项目GetPlatform
和GetLocalPathToFile
实现:
return new SQLitePlatformAndroid();
和
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), fileName);
的包我用于Sqlite的是:
- SQLite.Net.Async-PCL
- SQLite.Net.Core-PCL
- SQLite.Net-PCL
任何想法?