How do I solve Execution failed for task ‘:device_info_plus:compileReleaseJavaWithJavac’. > error: invalid source release: 17 on CircleCI?

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

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật