bluelinelabs / LoganSquare

Screaming fast JSON parsing and serialization library for Android.
Apache License 2.0
3.21k stars 306 forks source link

Not working with Gradle Plugin 3.4.1 and gradle 5.1.1 #230

Closed lexy1105 closed 5 years ago

lexy1105 commented 5 years ago

When i try use logansquare recently, i got this error http://prntscr.com/nwsuck Please check and let me know Maybe fasterxml-jackson-core:2.5.1 is not compatible with gradle plugin 3.4.1 and gradle 5.1.1 Please check and let me know Thanks

elephant-cf commented 5 years ago

I have a project with settings com.android.tools.build:gradle:3.3.2 and
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip It builds succesffully.

When i change settings to com.android.tools.build:gradle:3.4.1 and distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip build fault.

"Maybe fasterxml-jackson-core:2.5.1 is not compatible with gradle plugin 3.4.1 and gradle 5.1.1"

No. I' ve got another errors. The project does not use fasterxml-jackson-core directly The compiler gives an error that does not exist generated parser classes (NoClassDefFoundError)

markproxy commented 5 years ago

I see the same "cannot find symbol" errors shown in the screenshot posted by @yang511, for the JsonParser and JsonGenerator classes in com.fasterxml.jackson.core that are referenced from logansquare's ObjectMapperInjector class. The logansquare project does use fasterxml-jackson-core directly; it's referenced in core/build.gradle: compile 'com.fasterxml.jackson.core:jackson-core:2.5.1'.

I don't understand the exact nature of the incompatibility yet, but it definitely seems related to fasterxml-jackson-core.

markproxy commented 5 years ago

I was able to get the build to work by explicitly including my own dependency on jackson-core:2.5.1 in my project's build.gradle file:

    implementation 'com.bluelinelabs:logansquare:1.3.7' // LoganSquare runtime library
    implementation 'com.fasterxml.jackson.core:jackson-core:2.5.1' // Dependency of LoganSquare no longer detected automatically by gradle
    kapt 'com.bluelinelabs:logansquare-compiler:1.3.7'
    kapt 'com.fasterxml.jackson.core:jackson-core:2.5.1'

I suspect the issue here is that logansquare's compile dependency on jackson-core:2.5.1 is being interpreted by the latest gradle as non-transitive. The core/build.gradle file in the logansquare codebase should be updated to use api instead of compile.

elephant-cf commented 5 years ago

Works after adding dependency implementation 'com.fasterxml.jackson.core:jackson-core:2.5.1' Thanks a lot.

lexy1105 commented 5 years ago

OK, thanks

markproxy commented 5 years ago

@yang511 - I'd recommend keeping this ticket open until LoganSquare's dependency on jackson-core is made transitive. Users of the library shouldn't have to add the dependency to their own projects.