Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to run the app locally due to database not copying properly to my device #16

Closed
atomicptr opened this issue Apr 11, 2021 · 11 comments
Assignees
Labels
bug Something isn't working

Comments

@atomicptr
Copy link
Contributor

Hey! I've been trying to build the app locally (parts of which led to #15) but there is one issue that I haven't been able to resolve yet and you might be able to help me with this.

Whenever I run the app (the version I've built myself) on my smartphone (or an Android emulator) I get the following exception:

Unhandled Exception:
DatabaseException(no such table: Kanji (code 1 SQLITE_ERROR): ,
while compiling: SELECT * FROM Kanji) sql 'SELECT * FROM Kanji' args []}

After checking the local database that gets installed on my device I can confirm that its pretty much empty (like a newly initialized sqlite DB) so this error is kinda obvious. My first thought was something along the lines of "Oh well, maybe I did something wrong with the git LFS step" but sadly the database that I have on my PC in data/dictDB.db is correct (as in it does have the required tables/data). So my assumption is that somehow it doesn't seem to copy the SQLite database that I have in data/ to my device (nor the emulator) and I think it does instead initialize a new one, which then causes the prior exception due to the data not being present.

Full "flutter run -d DEVICE_NAME" log (click to expand)
Launching lib\main.dart on DEVICE_NAME in debug mode...
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done                        62.5s
√ Built build\app\outputs\flutter-apk\app-debug.apk.
Installing build\app\outputs\flutter-apk\app.apk...                13.5s
I/flutter (30066): copying
I/flutter (30066): opening
I/flutter (30066): upgrading
I/flutter (30066): [{type: table, name: android_metadata, tbl_name: android_meta
data, rootpage: 3, sql: CREATE TABLE android_metadata (locale TEXT)}]
E/flutter (30066): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Except
ion: DatabaseException(no such table: Kanji (code 1 SQLITE_ERROR): , while compi
ling: SELECT * FROM Kanji) sql 'SELECT * FROM Kanji' args []}
E/flutter (30066): #0      wrapDatabaseException (package:sqflite/src/exception_
impl.dart:11:7)
E/flutter (30066): <asynchronous suspension>
E/flutter (30066): #1      SqfliteDatabaseMixin.txnRawQuery.<anonymous closure>
(package:sqflite_common/src/database_mixin.dart:406:30)
E/flutter (30066): <asynchronous suspension>
E/flutter (30066): #2      BasicLock.synchronized (package:synchronized/src/basi
c_lock.dart:33:16)
E/flutter (30066): <asynchronous suspension>
E/flutter (30066): #3      SqfliteDatabaseMixin.txnSynchronized (package:sqflite
_common/src/database_mixin.dart:346:14)
E/flutter (30066): <asynchronous suspension>
E/flutter (30066): #4      DBProvider.getAllKanjis (package:kanji_dictionary/res
ource/db_provider.dart:131:15)
E/flutter (30066): <asynchronous suspension>
E/flutter (30066): #5      KanjiBloc.getAllKanjis.<anonymous closure> (package:k
anji_dictionary/bloc/kanji_bloc.dart)
E/flutter (30066): <asynchronous suspension>
E/flutter (30066):
I/flutter (30066): opening
E/flutter (30066): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Except
ion: DatabaseException(no such table: Kanji (code 1 SQLITE_ERROR): , while compi
ling: SELECT * FROM Kanji) sql 'SELECT * FROM Kanji' args []}
E/flutter (30066): #0      wrapDatabaseException (package:sqflite/src/exception_
impl.dart:11:7)
E/flutter (30066): <asynchronous suspension>
E/flutter (30066): #1      SqfliteDatabaseMixin.txnRawQuery.<anonymous closure>
(package:sqflite_common/src/database_mixin.dart:406:30)
E/flutter (30066): <asynchronous suspension>
E/flutter (30066): #2      BasicLock.synchronized (package:synchronized/src/basi
c_lock.dart:33:16)
E/flutter (30066): <asynchronous suspension>
E/flutter (30066): #3      SqfliteDatabaseMixin.txnSynchronized (package:sqflite
_common/src/database_mixin.dart:346:14)
E/flutter (30066): <asynchronous suspension>
E/flutter (30066): #4      DBProvider.getAllKanjis (package:kanji_dictionary/res
ource/db_provider.dart:131:15)
E/flutter (30066): <asynchronous suspension>
E/flutter (30066): #5      KanjiBloc.getAllKanjis.<anonymous closure> (package:k
anji_dictionary/bloc/kanji_bloc.dart)
E/flutter (30066): <asynchronous suspension>
E/flutter (30066):
Activating Dart DevTools...                                         7.6s
Syncing files to device DEVICE_NAME...                                   140ms

I've invested some time trying to figure out why this doesn't work, but sadly couldn't find a solution yet and I hope that you might know how to resolve this :).

@Livinglist
Copy link
Owner

Yeah this has been a issue for me as well, but only on Android. Looking into it.

@Livinglist Livinglist self-assigned this Apr 12, 2021
@Livinglist Livinglist added the bug Something isn't working label Apr 12, 2021
@Livinglist
Copy link
Owner

@Livinglist
Copy link
Owner

Hi there. I just changed the way the database is initialized, this might fix this issue you are having.

@atomicptr
Copy link
Contributor Author

Looks like this didn't resolve the issue for me:

Syncing files to device DEVICE_NAME...
I/flutter ( 8331): opening
I/flutter ( 8331): [{type: table, name: android_metadata, tbl_name: android_metadata, rootpage: 3, sql: CREATE TABLE android_metadata (locale TEXT)}]
I/OpenGLRenderer( 8331): Initialized EGL, version 1.4
D/OpenGLRenderer( 8331): Swap behavior 2
D/vndksupport( 8331): Loading /vendor/lib64/hw/android.hardware.graphics.mapper@2.0-impl.so from current namespace instead of sphal namespace.
D/vndksupport( 8331): Loading /vendor/lib64/hw/gralloc.msm8953.so from current namespace instead of sphal namespace.
I/flutter ( 8331): opening
I/flutter ( 8331): opening
E/SQLiteLog( 8331): (1) no such table: Kanji
E/SQLiteLog( 8331): (1) no such table: Kanji
E/flutter ( 8331): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: DatabaseException(no such table: Kanji (code 1 SQLITE_ERROR): , while compiling: SELECT * FROM Kanji) sql 'SELECT * FROM Kanji' args []}
E/flutter ( 8331): #0      wrapDatabaseException (package:sqflite/src/exception_impl.dart:11:7)
E/flutter ( 8331): <asynchronous suspension>
E/flutter ( 8331): #1      SqfliteDatabaseMixin.txnRawQuery.<anonymous closure> (package:sqflite_common/src/database_mixin.dart:406:30)
E/flutter ( 8331): <asynchronous suspension>
E/flutter ( 8331): #2      BasicLock.synchronized (package:synchronized/src/basic_lock.dart:33:16)
E/flutter ( 8331): <asynchronous suspension>
E/flutter ( 8331): #3      SqfliteDatabaseMixin.txnSynchronized (package:sqflite_common/src/database_mixin.dart:346:14)
E/flutter ( 8331): <asynchronous suspension>
E/flutter ( 8331): #4      DBProvider.getAllKanjis (package:kanji_dictionary/resource/db_provider.dart:112:15)
E/flutter ( 8331): <asynchronous suspension>
E/flutter ( 8331): 
E/flutter ( 8331): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: DatabaseException(no such table: Kanji (code 1 SQLITE_ERROR): , while compiling: SELECT * FROM Kanji) sql 'SELECT * FROM Kanji' args []}
E/flutter ( 8331): #0      wrapDatabaseException (package:sqflite/src/exception_impl.dart:11:7)
E/flutter ( 8331): <asynchronous suspension>
E/flutter ( 8331): #1      SqfliteDatabaseMixin.txnRawQuery.<anonymous closure> (package:sqflite_common/src/database_mixin.dart:406:30)
E/flutter ( 8331): <asynchronous suspension>
E/flutter ( 8331): #2      BasicLock.synchronized (package:synchronized/src/basic_lock.dart:33:16)
E/flutter ( 8331): <asynchronous suspension>
E/flutter ( 8331): #3      SqfliteDatabaseMixin.txnSynchronized (package:sqflite_common/src/database_mixin.dart:346:14)
E/flutter ( 8331): <asynchronous suspension>
E/flutter ( 8331): #4      DBProvider.getAllKanjis (package:kanji_dictionary/resource/db_provider.dart:112:15)
E/flutter ( 8331): <asynchronous suspension>
E/flutter ( 8331): 

I did fully delete all data and the app beforehand just to be sure :(.

@Livinglist
Copy link
Owner

Looks like this didn't resolve the issue for me:

Syncing files to device DEVICE_NAME...
I/flutter ( 8331): opening
I/flutter ( 8331): [{type: table, name: android_metadata, tbl_name: android_metadata, rootpage: 3, sql: CREATE TABLE android_metadata (locale TEXT)}]
I/OpenGLRenderer( 8331): Initialized EGL, version 1.4
D/OpenGLRenderer( 8331): Swap behavior 2
D/vndksupport( 8331): Loading /vendor/lib64/hw/android.hardware.graphics.mapper@2.0-impl.so from current namespace instead of sphal namespace.
D/vndksupport( 8331): Loading /vendor/lib64/hw/gralloc.msm8953.so from current namespace instead of sphal namespace.
I/flutter ( 8331): opening
I/flutter ( 8331): opening
E/SQLiteLog( 8331): (1) no such table: Kanji
E/SQLiteLog( 8331): (1) no such table: Kanji
E/flutter ( 8331): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: DatabaseException(no such table: Kanji (code 1 SQLITE_ERROR): , while compiling: SELECT * FROM Kanji) sql 'SELECT * FROM Kanji' args []}
E/flutter ( 8331): #0      wrapDatabaseException (package:sqflite/src/exception_impl.dart:11:7)
E/flutter ( 8331): <asynchronous suspension>
E/flutter ( 8331): #1      SqfliteDatabaseMixin.txnRawQuery.<anonymous closure> (package:sqflite_common/src/database_mixin.dart:406:30)
E/flutter ( 8331): <asynchronous suspension>
E/flutter ( 8331): #2      BasicLock.synchronized (package:synchronized/src/basic_lock.dart:33:16)
E/flutter ( 8331): <asynchronous suspension>
E/flutter ( 8331): #3      SqfliteDatabaseMixin.txnSynchronized (package:sqflite_common/src/database_mixin.dart:346:14)
E/flutter ( 8331): <asynchronous suspension>
E/flutter ( 8331): #4      DBProvider.getAllKanjis (package:kanji_dictionary/resource/db_provider.dart:112:15)
E/flutter ( 8331): <asynchronous suspension>
E/flutter ( 8331): 
E/flutter ( 8331): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: DatabaseException(no such table: Kanji (code 1 SQLITE_ERROR): , while compiling: SELECT * FROM Kanji) sql 'SELECT * FROM Kanji' args []}
E/flutter ( 8331): #0      wrapDatabaseException (package:sqflite/src/exception_impl.dart:11:7)
E/flutter ( 8331): <asynchronous suspension>
E/flutter ( 8331): #1      SqfliteDatabaseMixin.txnRawQuery.<anonymous closure> (package:sqflite_common/src/database_mixin.dart:406:30)
E/flutter ( 8331): <asynchronous suspension>
E/flutter ( 8331): #2      BasicLock.synchronized (package:synchronized/src/basic_lock.dart:33:16)
E/flutter ( 8331): <asynchronous suspension>
E/flutter ( 8331): #3      SqfliteDatabaseMixin.txnSynchronized (package:sqflite_common/src/database_mixin.dart:346:14)
E/flutter ( 8331): <asynchronous suspension>
E/flutter ( 8331): #4      DBProvider.getAllKanjis (package:kanji_dictionary/resource/db_provider.dart:112:15)
E/flutter ( 8331): <asynchronous suspension>
E/flutter ( 8331): 

I did fully delete all data and the app beforehand just to be sure :(.

Hi there, I pushed a new change and hopefully this issue is fixed by that.

@atomicptr
Copy link
Contributor Author

Sadly still not working, can you reproduce this on an android emulator? I want to make sure its not just me 🤔

@Livinglist
Copy link
Owner

Livinglist commented Apr 12, 2021

Sadly still not working, can you reproduce this on an android emulator? I want to make sure its not just me 🤔

maybe try wiping all the data on emulator, and run flutter clean then try again? Because this patch resolved the issue on my side.

@atomicptr
Copy link
Contributor Author

atomicptr commented Apr 13, 2021

Sadly still not working, can you reproduce this on an android emulator? I want to make sure its not just me thinking

maybe try wiping all the data on emulator, and run flutter clean then try again? Because this patch resolved the issue on my side.

I'm doing that for every attempt just to be sure, also tried this with two PCs (Linux and Windows) now really weird... 🤔

@Livinglist
Copy link
Owner

Livinglist commented Apr 13, 2021

Sadly still not working, can you reproduce this on an android emulator? I want to make sure its not just me thinking

maybe try wiping all the data on emulator, and run flutter clean then try again? Because this patch resolved the issue on my side.

I'm doing that for every attempt just to be sure, also tried this with two PCs (Linux and Windows) now really weird... 🤔

Can I see the result of flutter doctor? Also your emulator configs and the console output on the first run.

@atomicptr
Copy link
Contributor Author

Thanks to knowing that it works on your end I decided to dig a bit deeper into what could be wrong on my side and realized that my local database was corrupted and I hadn't tested that thing again after checking that it worked once before but oh well.

I realized something else though, once an user has a corrupted database (for whatever reason) it's pretty much impossible to start the app again unless you completely delete all data on the device. Shouldn't the app in that case copy the database to the device again?

Nonetheless, thank you very much for your support :).

@Livinglist
Copy link
Owner

Thanks to knowing that it works on your end I decided to dig a bit deeper into what could be wrong on my side and realized that my local database was corrupted and I hadn't tested that thing again after checking that it worked once before but oh well.

I realized something else though, once an user has a corrupted database (for whatever reason) it's pretty much impossible to start the app again unless you completely delete all data on the device. Shouldn't the app in that case copy the database to the device again?

Nonetheless, thank you very much for your support :).

Actually my recent patch should fix the corrupted database as well. Maybe I can look into it later on. Thanks for reporting the problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants