[3.0.0-beta1]Table is not registered with a Database. Did you forget the @Table annotation?
But I have the folowing structure:
@Database(name = WeatherDB.NAME, version = WeatherDB.VERSION)
public class WeatherDB {
public static final String NAME = "Weather";
public static final int VERSION = 1;
}
And table:
@Table(database = WeatherDB.class)
public class WeatherTable extends BaseModel {
@Column
@PrimaryKey
private long dateStamp;
@Column
private double dayTemperature;
@Column
private double minTemperature;
@Column
private double maxTemperature;
@Column
private double nightTemperature;
@Column
private double eveTemperature;
@Column
private double mornTemperature;
@Column
private int humidity;
@Column
private String description;
@Column
private double windSpeed;
//getters and setters
}
Full stacktrace:
Process: me.bitfrom.weatherapp, PID: 3939
com.raizlabs.android.dbflow.structure.InvalidDBConfiguration: Table: me.bitfrom.weatherapp.database.WeatherTable is not registered with a Database. Did you forget the @Table annotation?
at com.raizlabs.android.dbflow.config.FlowManager.getDatabaseForTable(FlowManager.java:109)
at com.raizlabs.android.dbflow.config.FlowManager.getModelAdapter(FlowManager.java:271)
at com.raizlabs.android.dbflow.config.FlowManager.getTableName(FlowManager.java:68)
at com.raizlabs.android.dbflow.sql.language.From.<init>(From.java:55)
at com.raizlabs.android.dbflow.sql.language.Select.from(Select.java:58)
at me.bitfrom.weatherapp.ui.fragments.TodaysWeatherFragment.onViewCreated(TodaysWeatherFragment.java:31)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:908)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
at android.app.BackStackRecord.run(BackStackRecord.java:834)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1452)
at android.app.FragmentManagerImpl$1.run(FragmentManager.java:447)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:211)
at android.app.ActivityThread.main(ActivityThread.java:5389)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1020)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:815)
I have the same problem
@MaciejCzekanski are you using Dagger 2 in your project?
@KChernenko Yes, I can't make them both work at the same time. Do you have any solution?
Are you using proguard? If so, this config might help (solved the issue in our case)
-keep class * extends com.raizlabs.android.dbflow.config.DatabaseHolder { *; }
@simplysoft unfortunatelly proguard is disabled. I think it doesn't work in our case (mine and @MaciejCzekanski 's) because of Dagger 2.
Yes, I don't use Proguard. I'm not sure what I've changed, but now I get compile-time error, that Dagger's Component class is missing. When I remove @Table annotation then it compiles, but obviously crashes at runtime with error "Table is not registered with a Database".
@MaciejCzekanski have the same problem. Lets mark @agrosner here to infrom.
There are issues with annotation processors and how order can matter. Dagger2 has some issues with that, and unfortunately I do not know of a solution of how to fix that
This same error is almost making me now think of an alternative ORM
Finally it works for me! I had forgotten to add the Application class on the manifest
<application android:name=".App.TotoApp":
@amugox I have Application class referenced in manifest and it doesn't work. Do you also use Dagger 2?
I am getting same error using Dagger 2 =/
I'm getting the same error but just on one of my project, with the exact same database configuration, the one working is the android-testing project.
And I'm not using Dagger 2 :-1: :cry:
A workaround I am using to face this in my development process is doing Build -> Build Project and then run it again. =/
are you guys using 2.0.0+ of the Gradle plugin with instant run enabled?
Yes, I am using classpath 'com.android.tools.build:gradle:2.0.0-alpha7' with instant run enabled.
Im 95% sure its an instant run bug.
+1 ProGuard rule fixed things for me. I suggest it be added a consumer proguard rule for the library?
-keep class * extends com.raizlabs.android.dbflow.config.DatabaseHolder { *; }
Hi all
We are having the same problem here, in instrumented unit tests. I am using Dagger 1.2.2 and the build tools are version 1.5.0.
I have an abstract test case that injects the dependencias using dagger:
public abstract class FlowTestCase extends InstrumentationTestCase {
ObjectGraph objectGraph;
public FlowTestCase() {
FlowLog.setMinimumLoggingLevel(FlowLog.Level.I);
}
protected void setUp(){
objectGraph = ObjectGraph.create(new AndroidTestModule(getInstrumentation().getContext())).plus(getModules().toArray());
objectGraph.inject(this);
}
But I get the error while trying to delete the tables in the setUp in each test:
@RunWith(AndroidJUnit4.class)
public class ExampleTest extends FlowTestCase {
@Inject
LocalDataManager localDataManager;
@Override
protected List<Object> getModules() {
return new ArrayList<>();
}
@Before
public void setUp() {
super.setUp();
Delete.tables(MyTable.class);
}
@After
public void tearDown() {
Delete.tables(MyTable.class);
}
The injected LocalDataManager executes the FlowManager.init(context);
I can confirm that this issue is caused by instant run. I disabled it and it fixed the issue.