You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Xamarin Forms Android发布版Play商店下载崩溃(Android13+SQLite表缺失)

Xamarin Forms Android应用Play商店版本在Android 13上因SQLite表缺失崩溃

我为Xamarin Forms Android应用制作了新的发布版构建,试过AAB和APK两种格式,问题完全一致:通过USB手动安装APK时应用运行正常,但上传到Play商店后,用户下载安装就会崩溃。

关键现象:仅Android 13设备从Play商店下载的版本会出现此问题,Android 10设备运行正常。

捕获到的错误信息:

SQLite.SQLiteException: no such table: Landmark
  at SQLite.SQLite3.Prepare2 (SQLitePCL.sqlite3 db, System.String query) [0x0001b] in <4b0d206650714aac95636d5649d4c03f>:0 
  at SQLite.SQLiteCommand.Prepare () [0x00011] in <4b0d206650714aac95636d5649d4c03f>:0 
  at SQLite.SQLiteCommand+<ExecuteDeferredQuery>d__12`1[T].MoveNext () [0x00060] in <4b0d206650714aac95636d5649d4c03f>:0 
  at System.Collections.Generic.List`1[T].AddEnumerable (System.Collections.Generic.IEnumerable`1[T] enumerable) [0x00059] in <9c12cec805d543baa1819a17252d0f37>:0 
  at System.Collections.Generic.List`1[T]..ctor (System.Collections.Generic.IEnumerable`1[T] collection) [0x00062] in <9c12cec805d543baa1819a17252d0f37>:0 
  at System.Linq.Enumerable.ToList[TSource] (System.Collections.Generic.IEnumerable`1[T] source) [0x00018] in <f7f5e975751f438aaf310250a4760143>:0 
  at SQLite.SQLiteCommand.ExecuteQuery[T] () [0x0001c] in <4b0d206650714aac95636d5649d4c03f>:0 
  at SQLite.TableQuery`1[T].ToList () [0x0000b] in <4b0d206650714aac95636d5649d4c03f>:0 
  at YourApp.APQ.Repositories.LandmarksRepository.get_LandmarksEurope () [0x00025] in <aac048b1ac5244308321320587a44123>:0 
  at YourApp.APQ.Services.Game.GameService.GetNextQuestionEurope () [0x00011] in <aac048b1ac5244308321320587a44123>:0 

我怀疑问题和Play商店存储应用、读取SQLite数据库的方式有关,试过调整多种发布构建设置,但都没能解决。

数据库相关代码:

public List<LandmarkModel> LandmarksEurope
{
    get
    {
        if (landmarksEurope != null) return landmarksEurope;
        landmarksEurope = new List<LandmarkModel>();
        var entities = dbConn.Table<Landmark>().ToList();
        var filtereden = entities.Where(x => x.Region == "EU").ToList();
        foreach (Landmark entity in entities)
        {
            if (entity.Region == "EU")
            {
                landmarksEurope.Add(new LandmarkModel(entity));
            }
        }
        //entities.ForEach(e => flagsEurope.Add(new FlagModel(e)));
        return landmarksEurope;
    }
}

触发异常的代码位置:

var country = landmarksRepository.GetRandomFlag(c => playedCountries.Contains(c));
var options = landmarksRepository.GetRandomFlagCountries();
options.Add(country.Country);
options = options.OrderBy(a => Guid.NewGuid()).ToList();

var question = new Question
{
    Flag = Device.RuntimePlatform == Device.iOS ? $"landmarkspng/{country.ImageFileName}.png" : $"{country.ImageFileName}.png",
    Options = options,
    TheRightAnswer = country.Country
};

playedCountries.Add(country);

return currentQuestion = question;

内容的提问来源于stack exchange,提问作者Nysand

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.05 02:35:48