marcinm marcinm - 1 month ago 14x
Android Question

Gradle compile commpability exception, payU

I have an issue with compiling the latest payU library. I use compile options for my project:

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8

because I use retrolambda (lib allowing to use lambdas on Android) in my project. After adding the payU library

compile('') {
exclude group: '', module: 'support-v4'

compile('') {
exclude group: '', module: 'support-v4'

I receive a compile 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.

I use many other libs in this, but only after adding this one I receive this error. I tried to even add it using a separate module with compatibility 1.7, but it didn't help. Probably something like compileOptions for a single dependency could help, but I cannot find it in gradle.

I also checked the payU sample app and they use compileOptions compatibility 1.7, but I cannot change this since all my lambdas wouldn't compile in that case.

Do you have any idea how this can be solved? For now I think that only adding compileOptions 1.7 to the payU lib would solve this, but I cannot do this.


I got in touch with PayU's tech support and I received info that one more group needs to be excluded from gradle import.

exclude group: 'org.jetbrains', module: 'annotations'

needs to be added to both PayU lib imports.