Closed KChernenko closed 8 years ago
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.
It happens for me. I am not using dagger, proguard is disabled. I am using android annotations and gradle com.android.tools.build:gradle:2.0.0-alpha7.
It is works well when project is rebuild every time before run.
use 2.0.0-beta2 - they explicitly fixed the issue: http://tools.android.com/recent/androidstudio20beta2availableincanarychannel
Dagger2 and other annotation-processor based libraries and plugins: In 2.x we've been using the new "incremental Java compilation" feature in Gradle,
but this feature does not work well with annotation processor.
In beta2, we automatically turn off incremental compilation if a project appears to be using annotation processors through the "android-apt" plugin.
Manually wired processors will still fail (see https://github.com/google/dagger/issues/298).
EDIT: Unfortunately, this issue still exists in 2.0 Beta 3
there are a few potential factors associated with why it fails. 1 is gradle plugin for Android. What version are you using of the Android gradle plugin?
still exists in 2.0 Beta 4. Issue disappeared when disable Instant Run.
classpath 'com.android.tools.build:gradle:2.0.0-beta4'
still not fixed 2.0 Beta 5.
Seems was fixed in com.android.tools.build:gradle:2.0.0-beta6
Any idea on whether they disabled instant run for any non-compatible apt they find/instant run works seamlessly with dbflow
Bummer. Instant run fixed the issue for me as well. Too bad as instant run is pretty sweet. Thanks for finding that solution everyone.
I am seeing this issue in dbflow version 3.1.1. Disabled instant run on my studio the gradle version being used is 2.1.3. Even with 2.0.0-beta6, its not working.
@agrosner request your help here. Thank you.
@TeddyGammel Please make sure you have initialized FlowConfig in your Application class!
I'm having this problem as well. DaggerApplicationComponent and DaggerConfigPersistentComponent simply aren't getting created properly when I enable DBFlow. Looks like i'll need to go with a different ORM... :-(
Ensure you dont have any compile issues. also that you didnt muck up one of the other annotation processor dependant libs, as that will cause side effects in other annotation processors. Ensure incremental compilation is not interfering with annotation processing (it should be fixed as of 2.2.2) If your Dagger2 components are not getting generated, its likely its supressing DBFlow issues or you have an error in Dagger2.
Having done some more experimentation, it seems not to be DBFlow at fault, but rather android-apt. As you alluded to, as of the gradle 2.2.x plugin, this lib is deprecated ( https://bitbucket.org/hvisser/android-apt/wiki/Migration ) and dagger fails the generation step when I include it. But when I try to add dbflow's compile directives, i get:
Error:(151, 0) Could not find method apt() for arguments [com.github.Raizlabs.DBFlow:dbflow-processor:4.0.0-beta2] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Any suggestions for working with DBFlow using the newest gradle plugin?
But I have the folowing structure:
And table:
Full stacktrace: