Viventum
Viventum

Reputation: 1

SQLite error on releasing android-app with XAMARIN.NET and SQLite

I am working with VS 2017 and XAMARIN/Android and SQLite. In "debug" mode there is no problem. When i try to run the android "release" mode on the smart phone i become following error:

Unhandled Exception: System.Exception: Cannot create a table without columns (does 'SolarmonAndroidApp.Models.TicketPageModels.TicketType' have public properties?)

How can i properly configure the app to install the SQLite_DB on Android mobile phone.

Model:

using SQLite;
using System;
using System.Collections.Generic;
using System.Text;

namespace SolarmonAndroidApp.Models.TicketPageModels
{
    public class TicketType
    {
        [PrimaryKey, AutoIncrement]
        public int Id { get; set; }

        public int _Id { get; set; }
        public string Name { get; set; }
        public bool IsActive { get; set; }
        public bool IsFixed { get; set; }
    }
}

Calls:

        _sql.CreateTable<TicketAction>();
        _sql.CreateTable<TicketType>();
        _sql.CreateTables<Park, Section, Ticket, User>();
        _sql.CreateTables<Row, Inverter, Number, Pool, Attachment>();
        _sql.CreateTable<CatchLog>();
        _sql.CreateTable<AppSettings>();
        _sql.CreateTables<TicketChecklist, TicketCheckpoint, SubTicket>();

Upvotes: 0

Views: 228

Answers (1)

Philippe Banwarth
Philippe Banwarth

Reputation: 17755

Comments recap :

It seems that the problem was linked (pun intended) to the linker. It is the part of the build process that tries to remove unused code, with the laudable goal of reducing the APK size, but is sometimes too aggressive.

This can be changed in the project's properties (for a release build) : Android Options tab, Linker properties.

The safest choice for Linking is None but it results in huge APKs, so it is usually only useful to check if build problem is related to the linking process.

The best choice is almost always Sdk Assemblies Only : All of your code is left untouched, and most of the unused code is removed.

Upvotes: 1

Related Questions