greenrobot / greenDAO

greenDAO is a light & fast ORM solution for Android that maps objects to SQLite databases.
http://greenrobot.org/greendao/
12.63k stars 2.89k forks source link

Support Jack toolchain / Java 1.8 #407

Closed TheBlusky closed 7 years ago

TheBlusky commented 8 years ago

Hello, I am new with greenDAO. I am running with Java 1.8 (Jack enabled).

When trying to compile the APK files are not generated, so I get the following error :

Error:D:\Developpement\AndroidStudio\StashMobile\app\src\main\java\pm\stash\stashmobile\StashMobile.java:9: The import pm.stash.stashmobile.database.models.DaoMaster cannot be resolved Error:D:\Developpement\AndroidStudio\StashMobile\app\src\main\java\pm\stash\stashmobile\StashMobile.java:26: DaoSession cannot be resolved to a type Error:D:\Developpement\AndroidStudio\StashMobile\app\src\main\java\pm\stash\stashmobile\StashMobile.java:31: DaoMaster cannot be resolved to a type Error:D:\Developpement\AndroidStudio\StashMobile\app\src\main\java\pm\stash\stashmobile\StashMobile.java:33: DaoMaster cannot be resolved to a type Error:D:\Developpement\AndroidStudio\StashMobile\app\src\main\java\pm\stash\stashmobile\StashMobile.java:37: DaoSession cannot be resolved to a type

If I manually run the graddle task "greendao", "DaoMaster", "DaeSession" and DAO files are correctly generated. But then, compilation give the following error :

Information:Gradle tasks [:app:assembleDebug] Error:Library reading phase: file 'D:\Developpement\AndroidStudio\StashMobile\app\build\intermediates\packaged\debug\classes.zip' is an invalid library Error:com.android.jack.JackAbortException: Library reading phase: file 'D:\Developpement\AndroidStudio\StashMobile\app\build\intermediates\packaged\debug\classes.zip' is an invalid library Error:com.android.jack.library.LibraryReadingException: Library reading phase: file 'D:\Developpement\AndroidStudio\StashMobile\app\build\intermediates\packaged\debug\classes.zip' is an invalid library Error:com.android.jack.library.LibraryFormatException: file 'D:\Developpement\AndroidStudio\StashMobile\app\build\intermediates\packaged\debug\classes.zip' is an invalid library Error:Execution failed for task ':app:transformJackWithJackForDebug'.

com.android.build.api.transform.TransformException: com.android.jack.api.v01.CompilationException: Library reading phase: file 'D:\Developpement\AndroidStudio\StashMobile\app\build\intermediates\packaged\debug\classes.zip' is an invalid library Information:BUILD FAILED Information:Total time: 0.925 secs

Is there anything I missed ? I really don't know how to debug this.

Thanks :-)

greenrobot-team commented 8 years ago

Does this also happen with Jack disabled (you will likely have to disable Java 8 support)? I assume Jack is the root cause as it changes how the toolchain works. We will likely have to udpate the plugin to add Jack support. Edit: see also the bottom of the Jack docs.

jackOptions {
    enabled false
}

-ut

TheBlusky commented 8 years ago

Hello ! Finally, I removed Jack options, disabled Java 8, and now it's working fine. I guess there is currently no ORM working with Jack and Java 8 :-)

Thanks again !

greenrobot-team commented 8 years ago

We probably still want to have a look at Jack support in the future, reopening. -ut

Freesword commented 8 years ago

hi! how to resolve this problem? i have the same problem with u

greenrobot-team commented 8 years ago

@Freesword As said, the greenDAO Gradle plugin currently does not support Jack. You will have to stick to using javac and Java 7. -ut

bmax-moblin commented 8 years ago

I managed to build my project with Jack and Java 8 after moving the generated classes (DaoMaster, DaoSession, xxxDAO) to 'src/main/java'. So, i guess it refuses to see custom generated/source files.

greenrobot-team commented 7 years ago

This should be fixed with the next update where we include the generated sources and the greendao task differently.

Edit: tested with an example project, the upcoming release should fix this. -ut

jmendezv commented 7 years ago

Same issue here :(

Reakleases commented 7 years ago

@jmendezv , do you use rxbinding?

greenrobot-team commented 7 years ago

@jmendezv @Reakleases This should no longer be an issue with classpath 'org.greenrobot:greendao-gradle-plugin:3.2.1'. Do you still have problems? Please get us a small example project so we can reproduce the issue. -ut

Reakleases commented 7 years ago

yes I had problem till rxbinding was in dependency of project(3.2.1 included)

irshadsparky commented 7 years ago

i found solution in my case there is a red error in my code which is not show in compile time.when i see my full code it have a miner mistake so i repared it and it work .

ULooper commented 6 years ago

what should i do

greenrobot-team commented 6 years ago

Jack is officially dead and replaced by Java 8 desugaring. Please submit a new issue if there are issues with the new Android Java 8 support. -ut