capacitor icon indicating copy to clipboard operation
capacitor copied to clipboard

[Bug]: Capacitor not set isCoreLibraryDesugaringEnabled

Open GuilhermeAbreu opened this issue 6 months ago • 3 comments

Capacitor Version

💊 Capacitor Doctor 💊

Latest Dependencies:

@capacitor/cli: 7.2.0 @capacitor/core: 7.2.0 @capacitor/android: 7.2.0 @capacitor/ios: 7.2.0

Installed Dependencies:

@capacitor/cli: 7.2.0 @capacitor/ios: 7.2.0 @capacitor/core: 7.2.0 @capacitor/android: 7.2.0

Error: ➜ android git:(LO2-775) ✗ ./gradlew assembleRelease

Configure project :app WARNING: Using flatDir should be avoided because it doesn't support any meta-data formats.

Configure project :capacitor-cordova-android-plugins WARNING: Using flatDir should be avoided because it doesn't support any meta-data formats.

Task :app:checkReleaseAarMetadata FAILED

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':app:checkReleaseAarMetadata'.

A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction 2 issues were found when checking AAR metadata:

   1.  Dependency 'com.google.android.gms:play-services-tasks:18.3.0' requires core library desugaring to be enabled
       for :app.
 
       See https://developer.android.com/studio/write/java8-support.html for more
       details.
 
   2.  Dependency 'com.google.android.gms:play-services-basement:18.7.0' 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.

https://developers.google.com/android/guides/releases#april_14_2025 April 14, 2025 The latest update of play-services-maps (v19.2.0) includes improvements for attribution.

The latest updates to the play-services-base, play-services-basement, and play-services-tasks libraries include the following changes:

Added an aar-metadata.properties file inside each AAR, which enforces the following:

Your app must be built with Android Gradle Plugin (AGP) v8.2.0 or higher.

Your app must set isCoreLibraryDesugaringEnabled = true. Learn how to enable Java 8+ API desugaring support.

Artifacts released on maven.google.com com.google.android.gms:play-services-maps:19.2.0 com.google.android.gms:play-services-base:18.7.0 com.google.android.gms:play-services-basement:18.7.0 com.google.android.gms:play-services-tasks:18.3.0

This update made the capacitor is not configuring the capacitor.build.gradle correctly and the mandatory parameter isCoreLibraryDesugaringEnabled is not set, which generated an error when generating the apk

android { defaultConfig { // Required when setting minSdkVersion to 20 or lower multiDexEnabled true }

compileOptions {
    // Flag to enable support for the new language APIs
    coreLibraryDesugaringEnabled true
    // Sets Java compatibility to Java 8
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

}

dependencies { // For AGP 7.4+ coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.3' // For AGP 7.3 // coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.2.3' // For AGP 4.0 to 7.2 // coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.9' }

Other API Details

npm --version    
10.8.2

node --version
v20.18.2

java --version
openjdk 21.0.5 2024-10-15 LTS
OpenJDK Runtime Environment Temurin-21.0.5+11 (build 21.0.5+11-LTS)
OpenJDK 64-Bit Server VM Temurin-21.0.5+11 (build 21.0.5+11-LTS, mixed mode, 

gradle -v
------------------------------------------------------------
Gradle 8.11
------------------------------------------------------------

Platforms Affected

  • [ ] iOS
  • [x] Android
  • [ ] Web

Current Behavior

// DO NOT EDIT THIS FILE! IT IS GENERATED EACH TIME "capacitor update" IS RUN

android { compileOptions { sourceCompatibility JavaVersion.VERSION_21 targetCompatibility JavaVersion.VERSION_21 } }

apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle" dependencies { ............

}

if (hasProperty('postBuildExtras')) { postBuildExtras() }

Expected Behavior

when running npm capacitor update it should set the mandatory field

android { defaultConfig { // Required when setting minSdkVersion to 20 or lower multiDexEnabled true }

compileOptions {
    // Flag to enable support for the new language APIs
    coreLibraryDesugaringEnabled true
    // Sets Java compatibility to Java 8
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

}

dependencies { // For AGP 7.4+ coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.3' // For AGP 7.3 // coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.2.3' // For AGP 4.0 to 7.2 // coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.9' }

Project Reproduction

qualquer projeto com build no android apk

Additional Information

No response

GuilhermeAbreu avatar May 05 '25 20:05 GuilhermeAbreu

Workaround

open the file /android/app/build.gradle

add the following settings

Image

open the android folder and run ./gradlew build

GuilhermeAbreu avatar May 07 '25 11:05 GuilhermeAbreu

Can you add a sample project where this fails?

markemer avatar Jun 02 '25 14:06 markemer

This issue needs more information before it can be addressed. In particular, the reporter needs to provide a minimal sample app that demonstrates the issue. If no sample app is provided within 15 days, the issue will be closed. Please see the Contributing Guide for how to create a Sample App. Thanks! Ionitron 💙

ionitron-bot[bot] avatar Jun 02 '25 14:06 ionitron-bot[bot]

closing since no sample app was provided and seems related to play-services-maps dependency, which is not part of Capacitor.

jcesarmobile avatar Jul 07 '25 10:07 jcesarmobile

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.

ionitron-bot[bot] avatar Aug 06 '25 11:08 ionitron-bot[bot]