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

Multi Database Modules works on 3.0.1 but not on 3.1.1 #979

Closed
ec84b4 opened this issue Sep 11, 2016 · 23 comments
Closed

Multi Database Modules works on 3.0.1 but not on 3.1.1 #979

ec84b4 opened this issue Sep 11, 2016 · 23 comments

Comments

@ec84b4
Copy link

ec84b4 commented Sep 11, 2016

DBFlow Version: 3.1.1
Bug: Multi module no longer works

Description:
when using version 3.0.1 multi module works fine but when updated to version 3.1.1 i get this error and it can't find the generated database holder class (it exists in android studio i can open it but can't build the project)

Warning:File for type 'com.raizlabs.android.dbflow.config.FordDatabaseFord_Database' created in the last round will not be subject to annotation processing.
Warning:File for type 'com.raizlabs.android.dbflow.config.FordModuleGeneratedDatabaseHolder' created in the last round will not be subject to annotation processing.
Warning:The following options were not recognized by any processor: '[targetModuleName]'
@ec84b4 ec84b4 changed the title Multi Database Modules works on 3.01 but not on 3.1.1 Multi Database Modules works on 3.0.1 but not on 3.1.1 Sep 11, 2016
@trevjonez
Copy link
Contributor

Those are simply warning and will not cause your build to fail. Because of the way the Filer api works you can not overwrite a file that was generated in previous generation rounds.

As such these classes that are deferred to the final round need to be aware of all models, converters etc are not generated until the final round of processing. The generated classes them selves do not have annotations that are inputs to other tools so it causes no issue.

@ec84b4
Copy link
Author

ec84b4 commented Sep 12, 2016

so what is the reason that compiler can't find the generated helper class when trying to build the project ?

this is the exact error given in gradle:

error: cannot find symbol
import com.raizlabs.android.dbflow.config.FordGeneratedDatabaseHolder;
                                         ^
  symbol:   class FordGeneratedDatabaseHolder
  location: package com.raizlabs.android.dbflow.config
warning: File for type 'com.raizlabs.android.dbflow.config.FordDatabaseFord_Database' created in the last round will not be subject to annotation processing.
warning: File for type 'com.raizlabs.android.dbflow.config.FordGeneratedDatabaseHolder' created in the last round will not be subject to annotation processing.
warning: The following options were not recognized by any processor: '[targetModuleName]'
1 error
2 warnings

 FAILED

FlowManager.initModule(FordGeneratedDatabaseHolder.class);

this is what I'm trying to do and the compiler doesn't seem to be able to find FordGeneratedDatabaseHolder class; but i can see that the file is generated.

i tested this on 2 different projects and the same thing happened but it works fine on version 3.0.1

I can't figure out what causes the problem

build.gradle:

apply plugin: 'com.neenbedankt.android-apt'
def dbflow_version = "3.1.1"

apt {
    arguments {
        targetModuleName 'Ford'
    }
}

@ec84b4
Copy link
Author

ec84b4 commented Nov 8, 2016

Any follow up on this ?

@agrosner
Copy link
Owner

have you tried 4.0.0-beta3?

@agrosner
Copy link
Owner

agrosner commented Jan 1, 2017

will reopen if issue still persists on that version.

@agrosner agrosner closed this as completed Jan 1, 2017
@jackwang1
Copy link

jackwang1 commented Jun 2, 2017

I'm running into this issue on 4.0.2. Using annotationProcessor instead of apt.

Edit: should add that in addition to SomeNameGeneratedDatabaseHolder not importable, I'm also seeing the issue where only 1 database holder when multiple modules are specified.

@yeduRaghav
Copy link

yeduRaghav commented Jun 6, 2017

This issue exists for me.'
I see the similar message @Hister sees.

import com.raizlabs.android.dbflow.config.ClientGeneratedDatabaseHolder;
^
symbol: class ClientGeneratedDatabaseHolder
location: package com.raizlabs.android.dbflow.config
warning: File for type 'com.raizlabs.android.dbflow.config.MYClientDatabaseMYClientDb_Database' created in the last round will not be subject to annotation processing.
warning: File for type 'com.raizlabs.android.dbflow.config.ClientGeneratedDatabaseHolder' created in the last round will not be subject to annotation processing.
warning: The following options were not recognized by any processor: '[targetModuleName]'

I was using 3.0.1, wanted to update to 4.0.3 (yes, really behind, I know!).
I use annotation processor instead of the apt.

I have two separate GenertedDatabaseHolders, both build fine on version 3.0.1
I tried upgrading to 4.0.3.
The first databaseHolder builds, but the second one doesn't.

In order to find out which version update was causing the issue, I tried updating version one by one, towards 4.0.3 from builds 3.0.1.

It started to fail building the second database holder on 3.1.1 and on all versions after.

I shall try to revert and try using apt and upgrade to 4.0.3 and see if it works.

UPDATE :
I tried apt and the updation fails, the second database module does not compile.

@andriipanasiuk
Copy link

andriipanasiuk commented Jun 8, 2017

I have the same issue.
DBFlow 4.0.2
Using annotationProcessor, not apt
Gradle 2.3.0

Module specific ModuleGeneratedDatabaseHolder.java file is generated in build/generated/source/apt/debug/com/raizlabs/android/dbflow/config along with EventDatabaseEvents_Database.java file.

@jackwang1
Copy link

Went back to 3.0.1, gradle 2.2.1 and apt since I need multiple modules. Still can't get multiple generated database holders.

@yeduRaghav or anyone else, do you have any sample code of it working?

@chaleao
Copy link

chaleao commented Jun 9, 2017

@jackwang1 is your configuration something similar the setup below?

build.gradle (Module 1)

apply plugin: 'com.neenbedankt.android-apt'

buildscript {
    dependencies {
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
    }
}

apt {
    arguments {
        targetModuleName 'Mod 1'
    }
}

def dbflow_version = "3.0.1"

build.gradle (Module 2)

apply plugin: 'com.neenbedankt.android-apt'

buildscript {
    dependencies {
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
    }
}

apt {
    arguments {
        targetModuleName 'Mod 2'
    }
}

def dbflow_version = "3.0.1"

then wherever you are initializing your DBflow from

  FlowManager.init(new FlowConfig.Builder(this)
                .addDatabaseHolder(Module1GeneratedDatabaseHolder.class)
                .addDatabaseHolder(Module2GeneratedDatabaseHolder.class)
                .build());

The setup on the project I'm working on it's similar the setup above and it's working fine with Apt and Dbflow 3.0.1.

@jackwang1
Copy link

I have the following structure:

Root build.gradle - what you have in app
app build.gradle - what you have in module 1
Module build.gradle - what you have in module 2

One requirement I have is app has module as dependency. Same problem I'm seeing with 4.0.3, which is database holder only generated for app, and not module.

@chaleao
Copy link

chaleao commented Jun 9, 2017

@jackwang1 are you building you FlowManager like below?

 FlowManager.init(new FlowConfig.Builder(this)
                .addDatabaseHolder(Module1GeneratedDatabaseHolder.class)
                .addDatabaseHolder(Module2GeneratedDatabaseHolder.class)
                .build());

I have the same dependency requirement as you.

@jackwang1
Copy link

jackwang1 commented Jun 9, 2017

Yes, though cannot add the second module since database holder for it is not generating.

Oh, and my second module is a background service.

@trevjonez
Copy link
Contributor

the information in this issue thread is mostly un-actionable. When it comes to build failures like this your best bet would be to make a demo project that exhibits the issue. If it is a runtime issue fork and issue a pr with failing tests.

@jackwang1
Copy link

Was finally able to get 3.0.1 working with multiple modules. Seems ordering of dependencies in build.gradle matters.

@trevjonez Haven't looked at the unit tests, but here's a repo I quickly put together to show difference between 3.0.1 and 4.0.3.

@trevjonez
Copy link
Contributor

@jackwang1 I made a small change to the timing that the processor outputs files. It is beyond me why it was necessary but should resolve your problem (assuming it gets merged). Until then you can target my develop snapshots.

this patch file can be applied to your example project to show you what all I changed.

dbflow_mrp_fix.diff.txt

@jackwang1
Copy link

Thanks @trevjonez

@andriipanasiuk
Copy link

Thanks @trevjonez
Your develop-SNAPSHOT version works great!
Looking forward for it being merged into RaizLabs production version.

@yeduRaghav
Copy link

yeduRaghav commented Jun 19, 2017

@andriipanasiuk @trevjonez @jackwang1 can anyone tell me how to use the develop-snapshot ?
I don't know what to do. Thank you!

@trevjonez
Copy link
Contributor

the workaround that jackwang is using is to depend on a jitpack of my fork from the develop branch.

def dbflow_version = "develop-SNAPSHOT"
compile "com.github.trevjonez.DBFlow:dbflow:${dbflow_version}"
etc...

@jackwang1
Copy link

@yeduRaghav master branch of my example project is using develop-SNAPSHOT https://github.com/jackwang1/DBFlow-SQLCipher

@yeduRaghav
Copy link

yeduRaghav commented Jun 19, 2017

Thank you guys, one last question, so this is equivalent to the latest DBFlow version?

@trevjonez
Copy link
Contributor

as of about 8 days ago, yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants