JakeWharton / timber

A logger with a small, extensible API which provides utility on top of Android's normal Log class.
https://jakewharton.github.io/timber/docs/5.x/
Apache License 2.0
10.43k stars 957 forks source link

Timber 4.7.1 appears to require JDK 1.8 #327

Closed byencho closed 6 years ago

byencho commented 6 years ago

We have a project that is currently not compatible with JDK 1.8. When updating from version 4.7.0 to 4.7.1 we get the following error:

Error:Error converting bytecode to dex:
Cause: Dex cannot parse version 52 byte code.
This is caused by library dependencies that have been compiled using Java 8 or above.
If you are using the 'java' gradle plugin in a library submodule add 
targetCompatibility = '1.7'
sourceCompatibility = '1.7'
to that submodule's build.gradle file.

This appears to be related to the version bump for the Jetbrains annotations (https://github.com/JakeWharton/timber/commit/28aa40af827686bb5d4b8c481d582e9e3a04a7f9#diff-c197962302397baf3a4cc36463dce5eaL29). The docs for the annotations starting with version 16.0.1 mention they require JDK 1.8:

annotations artifact require JDK 1.8 or higher. If your project is compiled using JDK 1.5, 1.6 or 1.7 you can use annotations-java5 artifact instead.

This is first mentioned at https://github.com/JetBrains/java-annotations/commit/fda1bd27cac5b7964d64a5a2586a853460d301c2#diff-04c6e90faac2675aa89e2176d2eec7d8 .

Is JDK 1.8 meant to be an intentional dependency for Timber 4.7.1 and up?

dgadelha commented 6 years ago

Hey,

Can you check if adding this to your build.gradle works for your project?

implementation 'org.jetbrains:annotations-java5:16.0.2'
implementation ('com.jakewharton.timber:timber:4.7.1') {
    exclude group: 'org.jetbrains'
}

The plain Timber implementation worked fine for me in a Kotlin-only project (with no explicit targetCompatibility set to 1.8), but it could be probably because Kotlin might include the needed stuff for JetBrains Annotations. Just wanted to check if this method works with your project.

Thanks!

byencho commented 6 years ago

@dgadelha Thanks for the suggestion but that didn't seem to help. I should note that I'm using an older version of gradle so technically I used:

    compile 'org.jetbrains:annotations-java5:16.0.2'
    compile ('com.jakewharton.timber:timber:4.7.1') {
        exclude group: 'org.jetbrains'
    }

but that should be equivalent. I also tried other variations on forcing a different version of the annotations, such as

    compile ('org.jetbrains:annotations:15.0') { force = true }
    compile 'com.jakewharton.timber:timber:4.7.1'

Based on the output of gradlew dependencies, that seemed to successfully override the dependency but I'm still getting the build error.

dgadelha commented 6 years ago

@byencho Sad to hear it didn't help. Looks like we'd need to wait for an update from @JakeWharton then.

Until a solution comes, I guess you can keep using the previous version of Timber.

Thanks!

dabitdev commented 6 years ago

confirmed here too :(

JakeWharton commented 6 years ago

I don't think I'm going to "fix" this. With AS / AGP 3.2 desugar has moved into D8 and should just work. With AS / AGP 3.1 you can enable it by setting android.enableD8.desugaring=true in gradle.properties. The Android toolchain is long overdue in making Java 8 the default, and with 3.2 becoming stable it's finally time where libraries don't have to worry about it anymore.

byencho commented 6 years ago

OK, seems fair. Thanks for checking! I'll close this out.