0

UPDATE: When I delete app storage, it starts to work. I don´t understand...

When I generate a signed APK for my project and I install it to my phone, app crashes. When I debug the app, it works correctly.

I use Android Studio 3 and I disabled instant run.

Using logcat, I get the following exception:

2019-01-15 19:19:30.594 7317-7317/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: me.agomezgz.bng.programa, PID: 7317
java.lang.RuntimeException: Unable to start activity ComponentInfo{me.agomezgz.bng.programa/me.agomezgz.bng.programa.SplashActivity}: android.database.sqlite.SQLiteException: no such table: comentario (code 1 SQLITE_ERROR):  

3 Answers3

1

it complains about no such table: comentario ...which means that table comentario had not been previously created - and that the stack-trace is just a follow-up error. see the build output for the ProGuard warnings (or even add them to the question); there might something obfuscated, which should not have been obfuscated. the code of the database class is completely irrelevant (simply because it works, while not being obfuscated); only the build-log matters. adding -verbose into the ProGuard configuration might help to obtain some more details.

Martin Zeitler
  • 1
  • 19
  • 155
  • 216
  • @AlfredoDavidGómezSanmartin this is highly unlikely when using ProGuard with the `-verbose` switch... most likely it displays hundreds to thousands of warnings in `release` mode, depending on the size of the code-base, after the line `ProGuard, version 6.0.3` – Martin Zeitler Jan 16 '19 at 19:34
0

change your database onCreate method to this :

db.execSQL("CREATE TABLE IF NOT EXISTS comentario(_id integer,
nome text not null,
correo text not null,
texto text not null,
idLoc integer not null, primary key (_id));");
mostafa3dmax
  • 997
  • 7
  • 18
0

UPDATE: When I delete app storage, it starts to work. I don´t understand...

You had an earlier version of the database file around that did not have that table. Clearing app storage removed the database file and forced sqlite helper onCreate() to run again.

See When is SQLiteOpenHelper onCreate() / onUpgrade() run?

Why it worked in debug is that the debug package is another application id and has a separate private directory where the database files are stored. That database file did not have this problem.

laalto
  • 150,114
  • 66
  • 286
  • 303