3

So I have a fitness application which involves the use of a database which stores all info.

Up until now, I have always used virtual devices to run this application.

Each time I make changes to this apps database, I wipe the data from each emulator, increase database version number and then run the app and it all works perfectly fine.

The other day I decided to use my Huawei P20 Pro instead of an emulator, I ran the app and it worked perfectly.

However, after making changes to the database (and increasing version number) the database is no longer being initialised on my P20 Pro and I am getting the following error message:

E/AwareLog: AtomicFileUtils: readFileLines file not exist: android.util.AtomicFile@b9caac1
E/MemoryLeakMonitorManager: MemoryLeakMonitor.jar is not exist!
E/AwareLog: AtomicFileUtils: readFileLines file not exist: android.util.AtomicFile@a6b9e54

I have spent hours searching online for the cause of the problem, however I have not had much luck.

Those who have received the same error message all seem to be Huawei users...

MemoryLeakMonitor.jar is not exist! | Huawei Phone

(I'm not sure if this is related).

Does anyone know of what the error message means, and why I am not able to initialise my applications database on my physical device?

Database Class (Relevant code)

@Database(entities = {Junction.class, Exercise_Workout_Goals.class, Exercises.class, ExerciseType.class, Workouts.class,
        WorkoutType.class, Log_Entries.class, ChildExercises.class, ChildParentExerciseJunction.class}, version = 53, exportSchema = false)


    public static synchronized ExerciseDatabase getInstance(Context context) {
       
        if (instance == null) {
              
                instance = Room.databaseBuilder(context.getApplicationContext(),
                        ExerciseDatabase.class, "exercise_database")
                        
                        .fallbackToDestructiveMigration()
                 
                        .addCallback(roomCallback)
                        .build();
            }


        return instance;
    }

   
Josh Brett
  • 77
  • 3
  • 18
  • 1
    Do not post the whole code. Post only relevant part – Marcin Orlowski Jul 04 '20 at 16:32
  • Maybe that error message is not related to your database. If it's not on the store yet maybe you could just remove all those migrations. Did your try to uninstall it from the phone manually to give it a "fresh start"? What exactly did you change before the error? – einUsername Jul 04 '20 at 19:09
  • 1
    I added some more exercises to the database, and cleared the log entry table. I have uninstalled it from the phone in the same way you would any other app, however I am not sure if the apps data is still stored somewhere on the phone even after deletion – Josh Brett Jul 05 '20 at 07:32
  • @JoshBrett I think the error you posted is not related to your db. Besides `fallbackToDestructiveMigration()` would automatically delete everything in the older db when the db version is changed and create a new one. In my app, everything works fine although I only switched the version number between 1 and 2(saw u reached to 53 xD) and tested on API level 29 in Samsung. Can you test in another phone ? – cgb_pandey Jul 16 '20 at 08:48
  • I have tested it on 6 different emulators and it worked perfectly fine on all. I do not have another physical android device to test it on unfortunately. – Josh Brett Jul 16 '20 at 16:20
  • 1
    Does your HUAWEI phone have internet connection? Do you also delete the cache of the application? – Gokhan Dilek Jul 17 '20 at 13:48
  • @Gokhan Dilek Wow, it turns out all I needed to do was to clear cache and clear data. Not sure why but it is working now. Please could you put this as an answer so I can accept it as correct? (It would also be great if you could explain why this error happened in the first place). – Josh Brett Jul 17 '20 at 18:21
  • This type of situations happend when you application logic is inconsistent with the data already saved in the database. Most application do this. – David Innocent Jul 17 '20 at 19:01
  • Is this a big issue? (If so is there a way to stop this happening?) – Josh Brett Jul 17 '20 at 19:04
  • @JoshBrett You said that db was no longer being initialized but does the app crash? In logs you might wanna filter with `room` keyword to find out room specific warnings. You can programmatically clear cache though as : https://stackoverflow.com/a/6898278/9167710 – cgb_pandey Jul 18 '20 at 01:07

1 Answers1

2

It is a good practice to also clear the cache and app data when you reinstall the app.

Cache is used when your application wants to access the data again.

App data stores information like settings and database. Possibly, your app was referring to the old database and/or user settings and when the app was reinstalled, it may have a different table and structure which then crashed the app. In your case, deleting the app data worked(when you do this, it clears the cache too). Please also see this: https://www.androidpolice.com/2020/05/26/clear-app-cache-data-android/

Gokhan Dilek
  • 4,314
  • 4
  • 21
  • 24