I have found many questions related to this issue. The difference here is that this error only happens on bitrise build.
I can build locally release and development mode, and the build works, that is why I am thinking if maybe it could have to do with the bitrise configuration.
The full error is
Execution failed for task ':package_info_plus:compileReleaseJavaWithJavac'.
> error: invalid source release: 17
(I am not using this package_info_plus directly, it must be a dependency in one of the libraries)
What I have tried
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
builds locally, does not build on bitrise
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = '17'
}
does not build on bitrise, did not try locally
My flutter version is 3.22.2 stable, windows for local machine and macos for bitrise
Edit: So it seems to me that none of these changes in my build.gradle will have any effect if the issue is within the package_info_plus. The only library which I use that uses this package is sentry. So I tried downgrading sentry to the version I had before but I am still having the issue.
Any help is appreciated.
This behaviour happens because of package_info_plus
's android configuration. Both Kotlin and Java targets are set to 17. This setting means that compiler will produce class
files suitable for 17 version of JDK. Of course, JDK 11 (in case of default on bitrise) knows nothing about JDK 17.
Unfortunately, there is not much you can do only with build.gradle
configuration since these settings do not override each other.
Now, Bitrise part of the question. As per documentation, default JDK version on bitrise builders is 11
. Good news is it is possible to set JDK to 17. Here is what you need to do:
In your bitrise.yaml
you have to add these configuration, before any android-related steps:
primary:
steps:
- set-java-version@1:
inputs:
- set_java_version: '17'
Hope this will help resolve your issue