skip to Main Content

I’m trying to run this ready-made app, but it wasn’t working, so I had to update the AGP. After doing that, I keep getting this error. I’m a novice with Dart and Android, so…
please let me know if you need more info, I included the versions I’m using.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
   > An issue was found when checking AAR metadata:

       1.  Dependency ':flutter_local_notifications' requires core library desugaring to be enabled
           for :app.

           See https://developer.android.com/studio/write/java8-support.html for more
           details.

* 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.
> Get more help at https://help.gradle.org.

BUILD FAILED in 2s

flutter doctor -v

[√] Flutter (Channel stable, 3.10.0, on Microsoft Windows [Version 10.0.22631.4317], locale en-US)
    • Flutter version 3.10.0 on channel stable at C:flutterflutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 84a1e904f4 (1 year, 6 months ago), 2023-05-09 07:41:44 -0700
    • Engine revision d44b5a94c9
    • Dart version 3.0.0
    • DevTools version 2.23.1

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at C:UsersAAppDataLocalAndroidsdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: C:Program FilesAndroidAndroid Studiojrebinjava
    • Java version OpenJDK Runtime Environment (build 21.0.3+-12282718-b509.11)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:Program FilesGoogleChromeApplicationchrome.exe

[X] Visual Studio - develop for Windows
    X Visual Studio not installed; this is necessary for Windows development.
      Download at https://visualstudio.microsoft.com/downloads/.
      Please install the "Desktop development with C++" workload, including all of its default components

[√] Android Studio (version 2024.2)
    • Android Studio at C:Program FilesAndroidAndroid Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 21.0.3+-12282718-b509.11)

[√] VS Code (version 1.95.1)
    • VS Code at C:UsersAAppDataLocalProgramsMicrosoft VS Code
    • Flutter extension version 3.100.0

[√] Connected device (4 available)
    • sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64    • Android 14 (API 34) (emulator)
    • Windows (desktop)            • windows       • windows-x64    • Microsoft Windows [Version 10.0.22631.4317]
    • Chrome (web)                 • chrome        • web-javascript • Google Chrome 122.0.6261.112
    • Edge (web)                   • edge          • web-javascript • Microsoft Edge 130.0.2849.68

[√] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.

appbulid.gradle

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    namespace "code_level_1"
    compileSdkVersion 34
    ndkVersion "25.1.8937393"

    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.dbestech.shop_app_code_level_1"
        // 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 25
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

    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 {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

androidbulid.gradle


buildscript {
    ext.kotlin_version = '1.7.10'
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:8.3.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

tasks.register("clean", Delete) {
    delete rootProject.buildDir
}

I tried a few solutions such as this but nothing have worked.

2

Answers


  1. In your android/app/build.gradle add coreLibraryDesugaring inside dependencies:

    dependencies {
        // Add this [coreLibraryDesugaring] inside [dependencies]
        coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4'
    }
    

    This will enable core library desugaring.

    Login or Signup to reply.
  2. You are missing several key steps in the integration. Based on the documentation, you need to do the following for Android:

    1. Add the following inside your app level build.gradle file:

      dependencies {
          coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.2.2'
      }
      
    2. Use either gradle version 7.3.1 or higher

      classpath 'com.android.tools.build:gradle:7.3.1'
      
    3. Add these libraries to avoid specific crashes on Android 12L devices

      dependencies {
           implementation 'androidx.window:window:1.0.0'
           implementation 'androidx.window:window-java:1.0.0'
      }
      
    4. Make sure your compileSdkVersion is at least 34

    I also wrote an article about integrating flutter local notifications which you can read here.
    And you can see the source code of an application I made which integrated flutter local notifications here.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search