skip to Main Content

Anyone know why I might be getting this error when trying to run my flutter app on android in debug mode?

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:device_info_plus:compileDebugJavaWithJavac’.

error: invalid source release: 17

  • Try:

Run with –stacktrace option to get the stack trace.
Run with –info or –debug option to get more log output.
Run with –scan to get full insights.

BUILD FAILED in 19s
Error: Gradle task assembleDebug failed with exit code 1

My flutter version is: 3.3.2.

Dependencies:

flutter_native_splash: ^2.4.0
  provider: ^6.1.2
  shared_preferences: ^2.2.2
  http: ^1.2.1
  internet_connection_checker: ^1.0.0+1
  package_info_plus: ^6.0.0
  permission_handler: ^11.3.1
  flutter_svg: ^2.0.10+1
  flutter_inappwebview: ^6.0.0
  dart_rss: ^3.0.2
  intl: ^0.19.0
  settings_ui: ^2.0.2
  url_launcher: ^6.2.5
  qr_code_scanner: ^1.0.1
  html: ^0.15.4
  share_plus: ^8.0.2
  showcaseview: ^2.0.3
  restart_app: ^1.2.1
  flutter_expandable_fab: ^2.0.0
  flutter_rating_bar: ^4.0.1
  flutter_staggered_grid_view: ^0.7.0
  html_unescape: ^2.0.0
  readmore: ^2.2.0
  cached_network_image: ^3.3.1
  device_info_plus: ^10.0.1
  firebase_core: ^2.27.2
  firebase_analytics: ^10.9.0
  cloud_firestore: ^4.15.10

build.gradle file:

plugins {
    id "com.android.application"
    id "kotlin-android"
    id "dev.flutter.flutter-gradle-plugin"
}

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'
}

android {
    namespace "com.example.app"
    compileSdkVersion flutter.compileSdkVersion
    ndkVersion flutter.ndkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.app"
        // You can update the following values to match your application needs.
        // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
        minSdkVersion 23
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName

        multiDexEnabled 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.debug
        }
    }
}

flutter {
    source '../..'
}

dependencies {}

Thanks anymore info that is need I am happy to provide, not sure what other info might be needed to investigate this issue.

2

Answers


  1. Chosen as BEST ANSWER

    For anyone experiencing this issue, the problem here was related to android studio being out of date.

    Updated android studio and re-built my project and it works fine now.


  2. The temporary fix is to downgrade these packages for now:

    device_info_plus: 9.1.2
    package_info_plus: 5.0.1
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search