c# – APK android app crash when installed but runs fine when connected via USB from Visual Studio


I’m using Visual Studio Xamarin Forms with C#, I’m getting the data from and API and a database located on a server, until then everything went fine, I tested an apk and worked fine.
Now I have made some changes because my app has to simulate working the same when there’s no internet connection, so I implemented SQLite using nuget sqlite-net-pcl. So when my app has internet connection will store some values in local database, and if at any moment detects no internet will go and take the lastest info from the local database. I have been testing using my phone connected via USB and works great. So I created the Apk file again and after installing shows my main page and even a picker with data from the API, but when I clicked the first button it crashes or just closes without any message.

I don’t know what can be really usefull here but basically this is my local database connection (this code line appears in every page)

private SQLiteConnection db = new SQLiteConnection(System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "LocalDB.db3"));

this is an example of how I insert and get data from the local database

private void InsertPisterosLocal()
        {
            //first delete table data
            //db.DeleteAll<T_Pisteros>();
            db.DropTable<T_Pisteros>();
            db.CreateTable<T_Pisteros>();

            foreach (var item in PisterosLista)
            {
                var DatosRegistro = new T_Pisteros
                {
                    PisteroID = item.PisteroID,
                    PisteroN = item.PisteroN
                };
                var num = db.Insert(DatosRegistro);
            }
        }

public void GetPisterosLocal()
        {
            try
            {
                db.CreateTable<T_Pisteros>();
                List<T_Pisteros> PisterosLista = new List<T_Pisteros>();
                PisterosLista = db.Table<T_Pisteros>().ToList();
                pck_Pisteros.ItemsSource = PisterosLista;
            }
            catch (Exception)
            {
                throw;
            }
        }

then this is the manifest (again I don’t know if can be of any help

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.gearsofsoftware.servlottery" android:installLocation="auto">
    <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="28" />
    <application android:label="Premios Servicentro" android:icon="@mipmap/icon"></application>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
</manifest>

I’m really praying someone can help me here, I feel like this is a dead end for me, I have no clue what to do 🙁