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.
2
Answers
Double-Check build.gradle: Ensure your project’s build.gradle file (both app-level and module-level) has the following compileOptions and kotlinOptions (if using Kotlin)
Check the JDK: Verify the installed JDK version on your Bitrise virtual machine (VM). The error suggests it might be an older version that doesn’t support Java 17.
Update JDK (if needed): If the JDK is outdated, update it to a version that supports Java 17 (e.g., OpenJDK 17 or newer).
Set JAVA_HOME: Ensure the JAVA_HOME environment variable on the Bitrise VM points to the correct JDK installation directory.
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 produceclass
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:Hope this will help resolve your issue