This has been happening on my circleci environment. I was able to solve this locally by installing java 17 and using it.
I was somewhat able to deduce what I need to do from this thread, but I’m not sure how to replicate it on CircleCI/Fastlane.
I’ve tried the following:
- Adding this to my
build.gradle
coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = '17'
}
kotlin {
jvmToolchain(17)
}
- Adding a step in circle CI to install jdk 17
All of these still get me the error
Execution failed for task ':device_info_plus:compileReleaseJavaWithJavac'. > error: invalid source release: 17
My Fastfile looks like this:
default_platform(:android)
platform :android do
desc "Submit a new prod release build"
lane :prod_release do |options|
build_number = options[:build_number]
begin
Dir.chdir "../.." do
sh("flutter", "clean")
sh("flutter", "pub", "get")
sh("flutter", "build", "appbundle", "--build-number=#{build_number}", "--flavor=prod", "-t", "lib/main_prod.dart")
end
upload_to_play_store(
track: 'internal',
aab: '../build/app/outputs/bundle/prodRelease/app-prod-release.aab',
package_name: 'com.appname.members',
)
on_success("Successfully released Android pre-release build")
rescue => exception
on_error(exception)
raise
end
end
desc "Submit a new staging release build"
lane :staging_release do |options|
build_number = options[:build_number]
begin
add_badge(dark: true, glob: "/app/src/main/res/mipmap-*/ic_launcher*.png",)
Dir.chdir "../.." do
sh("flutter", "clean")
sh("flutter", "pub", "get")
sh("flutter", "build", "appbundle", "--build-number=#{build_number}", "--flavor=staging", "-t", "lib/main_staging.dart")
end
upload_to_play_store(
track: 'internal',
aab: '../build/app/outputs/bundle/stagingRelease/app-staging-release.aab',
package_name: 'com.appname.members.staging',
)
on_success("Successfully released Android staging-release build")
rescue => exception
on_error(exception)
raise
end
end
My android/app/build.gradle
looks like this:
plugins {
id "com.android.application"
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
id 'com.google.gms.google-services'
id 'com.google.firebase.crashlytics'
}
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
namespace 'com.appname.members'
compileSdk flutter.compileSdkVersion
ndkVersion flutter.ndkVersion
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
applicationId "com.appname.members"
minSdkVersion 28
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
ndk {
abiFilters 'arm64-v8a', 'armeabi-v7a'
}
}
compileOptions {
coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = '17'
}
kotlin {
jvmToolchain(17)
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
v1SigningEnabled false
v2SigningEnabled true
}
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.release
minifyEnabled true
shrinkResources false
proguardFiles getDefaultProguardFile(
'proguard-android-optimize.txt'),
'proguard-rules.pro'
}
}
flavorDimensions "default"
productFlavors {
staging {
dimension "default"
applicationIdSuffix ".staging"
manifestPlaceholders = [appName: "Recora Staging", isStaging: true, isProduction: false]
}
prod {
dimension "default"
applicationIdSuffix ""
manifestPlaceholders = [appName: "Recora", isStaging: false, isProduction: true]
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.0"
implementation 'com.google.firebase:firebase-messaging:21.0.0'
implementation 'com.google.android.play:core:1.10.0'
implementation 'com.google.android.play:core-ktx:1.8.1'
implementation 'com.polidea.rxandroidble2:rxandroidble:1.11.1'
implementation "com.google.android.material:material:1.5.0"
implementation 'androidx.window:window:1.0.0'
implementation 'androidx.window:window-java:1.0.0'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
}
and my circle ci config:
version: "2.1"
orbs:
flutter: circleci/[email protected]
android: circleci/[email protected]
parameters:
manual-staging-run:
type: boolean
default: false
workflows:
build:
jobs:
- lint_and_test:
filters:
branches:
ignore:
- staging
- main
deploy_staging:
jobs:
- lint_and_test:
filters:
branches:
only: staging
- deploy_staging_android:
requires:
- lint_and_test
deploy_prod:
jobs:
- lint_and_test:
filters:
branches:
only: main
- deploy_prod_android:
requires:
- lint_and_test
manual_deploy_staging:
when: << pipeline.parameters.manual-staging-run >>
jobs:
- lint_and_test
- deploy_staging_android:
requires:
- lint_and_test
commands:
setup_env:
steps:
- checkout
- flutter/install_sdk_and_pub:
version: 3.19.5
- run:
name: Install Zoom SDK
command: flutter pub run zoom:unzip_zoom_sdk
run_fastlane:
parameters:
fastlane_lane:
default: "staging_release"
type: string
platform:
default: ""
type: string
steps:
- run:
no_output_timeout: 30m
name: Fastlane
command: bundle exec fastlane <<parameters.fastlane_lane>> build_number:$CIRCLE_BUILD_NUM
working_directory: <<parameters.platform>>
build_android:
parameters:
flavor:
default: staging
type: string
output_dir:
default: output
type: string
steps:
- setup_env
- flutter/install_android_gradle_dependencies
- flutter/install_android_gem
- run: echo "$PLAY_STORE_UPLOAD_KEY" | base64 --decode > android/appname-health-keystore
- run: echo "$PLAY_STORE_UPLOAD_KEY_INFO" | base64 --decode > android/key.properties
- run: echo "$SUPPLY_JSON_KEY_DATA" > android/play-store-credentials.json
- run_fastlane:
fastlane_lane: <<parameters.flavor>>_release
platform: android
# - run_fastlane:
# fastlane_lane: <<parameters.flavor>>_apk
# platform: android
- store_artifacts:
path: <<parameters.output_dir>>
destination: outputs
jobs:
deploy_staging_android:
description: Deploy Staging build to internal testers in Play Store
executor:
name: android/android-machine
tag: 2023.02.1
steps:
- build_android:
flavor: staging
output_dir: android/build/app/outputs/flutter-apk/app-staging-release.apk
deploy_prod_android:
description: Deploy Prod build to internal testers in Play Store
executor:
name: android/android-machine
tag: 2023.02.1
steps:
- build_android:
flavor: prod
output_dir: android/build/app/outputs/flutter-apk/app-prod-release.apk
lint_and_test:
description: Run flutter analyze and Unit Tests
docker:
- image: "ghcr.io/cirruslabs/flutter:3.19.5"
steps:
- checkout
- flutter/install_pub
- run: echo 'export PATH="$PATH":"$HOME/.pub-cache/bin"' >> $BASH_ENV
- run:
name: Install junitreport
shell: "/bin/bash --login -eo pipefail"
command: dart pub global activate junitreport
- run: mkdir test-results
- run:
name: Run flutter analysis
command: flutter analyze
- run:
name: Run Unit Test
command: flutter test --machine | tojunit -o test-results/unit-test-report.xml
- store_test_results:
path: test-results