Null Object Reference When I Try To Build Room
Solution 1:
I have encountered the same problem. The simple solution would be is to go to your database class and check if the package is set in the top of the file
Example:
package com.example.app
This will set which package this class belongs to.
Solution 2:
I had the same problem, thanks to @Jéwôm', the link he provided - https://teratail.com/questions/118177 and Google Translator I found a solution.
That japanese guy whom Jéwôm' mentioned found out that this bug occured because of damaged/wrong directory structure in project files.
His directory seemed like this:
app
|-manifests
|-java
|-com.example.user.applyName
|-MainActivity
|-SubActivity // インスタンスを生成するActivity
|-AppDatabase
|-Dairy
|-DairyDao
|-res
And he solved the problem by moving files "AppDatabase", "Dairy" and "DairyDao" to the same folder as "MainActivity" and "SubActivity".
In my case I didn't have badly structured directory structure, but I moved all kotlin files to other folder (in my case from "com.example.myAppName" to "com.example.myAppName (androidTest)" and then moved them back (back to "com.example.myAppName"). Then I rebuilt that project. This somehow worked for me.
Solution 3:
The problem was from some imports (by coping the class from an other project).
Post a Comment for "Null Object Reference When I Try To Build Room"