greenDAO icon indicating copy to clipboard operation
greenDAO copied to clipboard

NoSuchMethodError: CompilerOptions.versionToJdkLevel with Android Gradle Plugin 2.3.0-alpha1

Open Quarx2k opened this issue 10 years ago • 25 comments

Hello. I have a problem with migration to greendao3. I follow guide http://greenrobot.org/greendao/documentation/updating-to-greendao-3-and-annotations/

New classes generated successfully. Gradle greendao plugin added and applied. But while compiling, i get error:

Caused by: java.lang.NoSuchMethodError: org.eclipse.jdt.internal.compiler.impl.CompilerOptions.versionToJdkLevel(Ljava/lang/Object;)J
        at org.eclipse.jdt.core.dom.ASTConverter.<init>(ASTConverter.java:91)
        at org.eclipse.jdt.core.dom.CompilationUnitResolver.convert(CompilationUnitResolver.java:285)
        at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:1216)
        at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:812)
        at org.greenrobot.greendao.codemodifier.EntityClassParser.parse(EntityClassParser.kt:25)

I tried clean project, remove .gradle dir, nothing helps. Full stacktrace: http://pastebin.com/shPg8Wi7

Android studio 2.3. Gradle: com.android.tools.build:gradle:2.3.0-alpha1. Greendao 3.2.0.

What can be wrong? Thanks :)

Quarx2k avatar Nov 11 '16 21:11 Quarx2k

Same issue with me, using gradle 2.2.2 is fine, upgrade to 2.3.0-aplha1 have this issue.

thunde91 avatar Nov 13 '16 05:11 thunde91

Yes, with 2.2.2 is ok. Downgraded for now

Quarx2k avatar Nov 13 '16 22:11 Quarx2k

Will keep this open for reference if this still is broken once the final 2.3.0 version of the Android Gradle Plugin is released. alpha is rather early and things are expected to be broken. -ut

greenrobot-team avatar Nov 14 '16 10:11 greenrobot-team

Just for notify: gradle:2.3.0-alpha2 + greendao3.2.1, same problem.

Quarx2k avatar Nov 24 '16 10:11 Quarx2k

the same also happen gradle:2.3.0-aplha3 and gradle:2.3.0-beta1

thunde91 avatar Dec 14 '16 10:12 thunde91

It seems to work with gradle:2.3.0-beta2. My app did not crash when creating the DB :)

romainhamm avatar Jan 12 '17 16:01 romainhamm

@NeoSyder Does that include Gradle 3.3 in your set up?

greenrobot avatar Jan 16 '17 10:01 greenrobot

Yep exactly, I use Gradle 3.3

romainhamm avatar Jan 17 '17 10:01 romainhamm

I'm having this problem with:

  • gradle 3.3
  • classpath 'com.android.tools.build:gradle:2.3.0-beta2'
  • classpath 'org.greenrobot:greendao-gradle-plugin:3.2.1'
  • compile 'org.greenrobot:greendao:3.2.0'

caarmen avatar Jan 21 '17 15:01 caarmen

Testing this now. Will update with results.

Working configurations

  • Android Studio 2.2.3 (current stable release), Android Plugin 2.2.3 (current stable), Gradle 3.3 (current stable)
  • Android Studio 2.3 Beta 2, Android Plugin 2.3.0-beta2, Gradle 3.3

Broken configuations

  • none so far

-ut

greenrobot-team avatar Jan 23 '17 10:01 greenrobot-team

@caarmen I saw you already removed it: but make sure to move the buildscript block to the very top of your file. Also, try to include the greenDAO plugin in the root buildscript block at the same level as the Android plugin.

Update: can reproduce error if plugin is not defined at the same level as the Android Gradle plugin. This is likely a similar issue as #442.

Update: the Android Gradle Plugin has updated to org.eclipse.jdt.core.compiler:ecj:4.6.1 from 4.5.1. This has changed the signature of CompilerOptions.versionToJdkLevel(Object) to CompilerOptions.versionToJdkLevel(String). The greenDAO Gradle plugin currently uses org.eclipse.scout.sdk.deps:org.eclipse.jdt.core:3.11.0.v20150602-1242 which excpects the old signature.

-ut

greenrobot-team avatar Jan 23 '17 10:01 greenrobot-team

tested on 2.3 beta 3 , still same issue

thunde91 avatar Jan 26 '17 15:01 thunde91

Sorry for the delay!

Moving the greendao plugin classpath to the root build.gradle file fixed this issue! Thanks :)

I didn't have to change the position of the buildscript block in my app/build.gradle file.

caarmen avatar Jan 28 '17 10:01 caarmen

解决方法就是:buildscript 放到application下

ximencx avatar Mar 03 '17 03:03 ximencx

I have fixed this issue. I put this classpath 'org.greenrobot:greendao-gradle-plugin:3.2.1' in the application's buildscript not the top. Then making this classpath to the top and resolved it.

wodis avatar Mar 03 '17 04:03 wodis

classpath 'org.greenrobot:greendao-gradle-plugin:3.2.1' with stable Android studio 2.3 is not working. Same error.

catalin-florescu avatar Mar 03 '17 10:03 catalin-florescu

Move "lasspath 'org.greenrobot:greendao-gradle-plugin:3.2.1'" to the root build.gradle file. I have it worked with Android Studio 2.3.

svladim avatar Mar 03 '17 10:03 svladim

I also confirm i fixed the issue in Android Studio 2.3 by moving the classpath 'org.greenrobot:greendao-gradle-plugin:3.2.1' from app.gradle file to project build.gradle file

smarques84 avatar Mar 03 '17 12:03 smarques84

It does work when moving the classpath to the root build.gradle file. However, I have a multi-project setup where not all of the subprojects actually use greenDAO. Is there currently an option to get the build working without moving the classpath?

PattaFeuFeu avatar Mar 03 '17 12:03 PattaFeuFeu

@PattaFeuFeu not sure we will have to wait for @greenrobot-team to provide a fix

smarques84 avatar Mar 03 '17 12:03 smarques84