0

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>();
16
  • i think the exception is pretty self explanatory, does your TicketType class from Models > TicketPageModelsm have public properties? post your class here so we can help Commented Jul 30, 2019 at 10:39
  • You need to post the code that gives you the error. We cannot help you otherwise. Maybe start by 1. How you try to create the table?, 2. How you defined the class for which you want to create the table? Commented Jul 30, 2019 at 10:39
  • it does not work only in release mode ?, i.e. does it work in debug mode ? Commented Jul 30, 2019 at 11:40
  • @bwt yes in debug mode no problem Commented Jul 30, 2019 at 11:46
  • 1
    What is the linking mode (project's Properties / Android Options / Linking ) ? Is it Sdk and user assemblies ? Commented Jul 30, 2019 at 12:06

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.