Xamarin.Forms应用程序在设备上的MigrateAsync而非模拟器上崩溃

时间:2019-06-03 15:02:01

标签: c# android sqlite xamarin.forms

我只是想将IPoint结构保存到移动设备上的SQLite数据库中。 因此,我在主项目中添加了一些nuget包:

  • Microsoft.EntityFrameworkCore.Sqlite.NetTopologySuite
  • NetTopologySuite

在添加了这些软件包并添加了代码之后,该应用开始在Android上崩溃。
编辑:我还尝试了该项目的旧版本,但在我的设备上没有任何工作。但是它们都可以在模拟器上工作。

通过查看VS输出获得的崩溃信息:

Loading reference 1 of /storage/emulated/0/Android/data/com.companyname.MyApp/files/.__override__/SQLitePCLRaw.provider.e_sqlite3.dll asmctx DEFAULT, looking for SQLitePCLRaw.core, Version=1.1.12.351, Culture=neutral, PublicKeyToken=1488e028ca7ab535
Assembly Ref addref SQLitePCLRaw.provider.e_sqlite3[0x7c6e295880] -> SQLitePCLRaw.core[0x7c6e295600]: 3
Loading reference 2 of /storage/emulated/0/Android/data/com.companyname.MyApp/files/.__override__/SQLitePCLRaw.batteries_v2.dll asmctx DEFAULT, looking for SQLitePCLRaw.core, Version=1.1.12.351, Culture=neutral, PublicKeyToken=1488e028ca7ab535
Assembly Ref addref SQLitePCLRaw.batteries_v2[0x7c6e295380] -> SQLitePCLRaw.core[0x7c6e295600]: 4
DllImport attempting to load: 'e_sqlite3'.
DllImport error loading library '/storage/emulated/0/Android/data/com.companyname.MyApp/files/.__override__/libe_sqlite3': 'dlopen failed: library "/storage/emulated/0/Android/data/com.companyname.MyApp/files/.__override__/libe_sqlite3" not found'.
DllImport error loading library '/storage/emulated/0/Android/data/com.companyname.MyApp/files/.__override__/libe_sqlite3.so': 'dlopen failed: library "/storage/emulated/0/Android/data/com.companyname.MyApp/files/.__override__/libe_sqlite3.so" not found'.
DllImport error loading library '/system/lib/libe_sqlite3': 'dlopen failed: library "/system/lib/libe_sqlite3" not found'.
DllImport error loading library '/system/lib/libe_sqlite3.so': 'dlopen failed: library "/system/lib/libe_sqlite3.so" not found'.
DllImport error loading library 'libe_sqlite3': 'dlopen failed: library "libe_sqlite3" not found'.
DllImport loaded library 'libe_sqlite3.so'.
DllImport searching in: 'e_sqlite3' ('libe_sqlite3.so').
Searching for 'sqlite3_libversion_number'.
DllImport searching in: 'e_sqlite3' ('libe_sqlite3.so').
Searching for 'sqlite3_open_v2'.
DllImport searching in: 'e_sqlite3' ('libe_sqlite3.so').
Searching for 'sqlite3_errcode'.
DllImport searching in: 'e_sqlite3' ('libe_sqlite3.so').
Searching for 'sqlite3_errmsg'.
DllImport searching in: 'e_sqlite3' ('libe_sqlite3.so').
Searching for 'sqlite3_extended_errcode'.
/proc/self/maps:
12c00000-12c40000 rw-p 00000000 00:05 14095                              /dev/ashmem/dalvik-main space (region space) (deleted)
12c40000-12dc0000 ---p 00040000 00:05 14095                              /dev/ashmem/dalvik-main space (region space) (deleted)
12dc0000-12e80000 rw-p 001c0000 00:05 14095                              /dev/ashmem/dalvik-main space (region space) (deleted)
12e80000-12fc0000 ---p 00280000 00:05 14095                              /dev/ashmem/dalvik-main space (region space) (deleted)
12fc0000-13d80000 rw-p 003c0000 00:05 14095                              /dev/ashmem/dalvik-main space (region space) (deleted)
13d80000-13f40000 rw-p 01180000 00:05 14095                              /dev/ashmem/dalvik-main space (region space) (deleted)
13f40000-14140000 ---p 01340000 00:05 14095                              /dev/ashmem/dalvik-main space (region space) (deleted)
14140000-32c00000 rw-p 01540000 00:05 14095                              /dev/ashmem/dalvik-main space (region space) (deleted)
70711000-70729000 rw-p 00000000 103:35 3156951                           /data/dalvik-cache/arm64/system@framework@boot.art
70729000-7072b000 r--p 00018000 103:35 3156951                           /data/dalvik-cache/arm64/system@framework@boot.art
7072b000-70737000 rw-p 00000000 103:35 3156961                           /data/dalvik-cache/arm64/system@framework@boot-com.nxp.nfc.nq.art
70737000-70738000 r--p 0000c000 103:35 3156961                           /data/dalvik-cache/arm64/system@framework@boot-com.nxp.nfc.nq.art
70738000-70743000 rw-p 00000000 103:35 3156975                           /data/dalvik-cache/arm64/system@framework@boot-qcom.fmradio.art
70743000-70744000 r--p 0000b000 103:35 3156975                           /data/dalvik-cache/arm64/system@framework@boot-qcom.fmradio.art
70744000-70745000 rw-p 00000000 103:35 3156989                           /data/dalvik-cache/arm64/system@framework@boot-com.qualcomm.qti.camera.art
70745000-70746000 r--p 00001000 103:35 3156989                           /data/dalvik-cache/arm64/system@framework@boot-com.qualcomm.qti.camera.art
70746000-70748000 rw-p 00000000 103:35 3157035                           /data/dalvik-cache/arm64/system@framework@boot-QPerformance.art
70748000-70749000 r--p 00002000 103:35 3157035                           /data/dalvik-cache/arm64/system@framework@boot-QPerformance.art
70749000-7074a000 rw-p 00000000 103:35 3157057                           /data/dalvik-cache/arm64/system@framework@boot-UxPerformance.art
7074a000-7074b000 r--p 00001000 103:35 3157057                           /data/dalvik-cache/arm64/system@framework@boot-UxPerformance.art
7074b000-70a0e000 rw-p 00000000 103:35 3157066                           /data/dalvik-cache/arm64/system@framework@boot-core-oj.art
70a0e000-70a22000 r--p 002c3000 103:35 3157066                           /data/dalvik-cache/arm64/system@framework@boot-core-oj.art
70a22000-70b57000 rw-p 00000000 103:35 3157070                           /data/dalvik-cache/arm64/system@framework@boot-core-libart.art
70b57000-70b69000 r--p 00135000 103:35 3157070                           /data/dalvik-cache/arm64/system@framework@boot-core-libart.art
70b69000-70ba8000 rw-p 00000000 103:35 3157083                           /data/dalvik-cache/arm64/system@framework@boot-conscrypt.art
Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x20 in tid 13951 (ame.MyApp), pid 13951 (ame.MyApp)

使用Android监视器为我提供了以下附加信息:

A/libc(28156): Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x20 in tid 28156 (ame.MyApp), pid 28156 (ame.MyApp)
I/crash_dump64(28338): obtaining output fd from tombstoned, type: kDebuggerdTombstone
I//system/bin/tombstoned(1045): received crash request for pid 28156
I/crash_dump64(28338): performing dump of process 28156 (target tid = 28156)
A/DEBUG(28338): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
A/DEBUG(28338): Build fingerprint: 'Nokia/Dragon_00WW/DRG_sprout:9/PPR1.180610.011/00WW_3_53B:user/release-keys'
A/DEBUG(28338): Revision: '0'
A/DEBUG(28338): ABI: 'arm64'
A/DEBUG(28338): pid: 28156, tid: 28156, name: ame.MyApp  >>> com.companyname.MyApp <<<
A/DEBUG(28338): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x20
A/DEBUG(28338): Cause: null pointer dereference
A/DEBUG(28338):     x0  0000000000000000  x1  0000000000000000  x2  0000000000000000  x3  0000007fc1de5410
A/DEBUG(28338):     x4  0000007c7dd749a0  x5  0000007fc1de54a0  x6  0000000000000000  x7  0000000000000000
A/DEBUG(28338):     x8  0000000000000000  x9  0000000000000000  x10 0000000000000000  x11 0000000000000000
A/DEBUG(28338):     x12 0000000000000000  x13 0000000000000000  x14 0000000000000000  x15 aaaaaaaaaaaaaaab
A/DEBUG(28338):     x16 0000007c6dad71f8  x17 0000007c6d8fe670  x18 0000000000000008  x19 0000007c6daee560
A/DEBUG(28338):     x20 0000000000000002  x21 0000000000000000  x22 0000000000000000  x23 000000000000007f
A/DEBUG(28338):     x24 0000000000000000  x25 0000000000000000  x26 0000007fc1de5590  x27 0000007c64bbefd8
A/DEBUG(28338):     x28 0000007c7dd74000  x29 0000007fc1de48b0
A/DEBUG(28338):     sp  0000007fc1de48b0  lr  0000007c6d845658  pc  0000007c6d8fe678
A/DEBUG(28338): backtrace:
A/DEBUG(28338):     #00 pc 0000000000177678  /data/app/Mono.Android.DebugRuntime-u_iAVw3y0OJVoxGy3Ukx5w==/lib/arm64/libmonosgen-64bit-2.0.so (mono_jit_info_get_method+8)
E//system/bin/tombstoned(1045): Tombstone written to: /data/tombstones/tombstone_09
W/ActivityManager(1476):   Force finishing activity com.companyname.MyApp/md57495425bdd6658bb1d21a5a4e075bb9f.MainActivity
E/lowmemorykiller(794): Error writing /proc/28156/oom_score_adj; errno=22

我将Assembly Linking设置为None,但是我也尝试使用SDK only

执行迁移时,应用程序加载,数据库加载,完成配置并关闭(崩溃甚至没有触发异常)。

    public async Task PrepareDatabase()
    {
        var path = DependencyService.Get<IFileHelper>().GetDatabaseFilePath("MyApp.db");

        Debug.WriteLine($"Database path: {path}");

        try
        {
            Context = new DataContext(path);
            await Context.Database.MigrateAsync(); //The app closes after stepping in here.
        }
        catch (Exception e)
        {
            Console.WriteLine(e); //It does not enter in here.
        }
    }

我不确定这是怎么回事。

编辑:

项目通常在模拟器上启动,只是设备无法通过MigrateAsync行。

我已经从设备上卸载了该应用程序,但是没有成功。

1 个答案:

答案 0 :(得分:0)

因此,此问题是由安装VS 2019的16.1.1版本触发的。

https://github.com/xamarin/xamarin-android/issues/2920

正在修复。