0

I am getting this error while running my flutter app.

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

A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction The minCompileSdk (31) specified in a dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties) is greater than this module's compileSdkVersion (android-30). Dependency: androidx.work:work-runtime:2.7.0-rc01. AAR metadata file: C:\Users\HP.gradle\caches\transforms-2\files-2.1\8fcba37f766c3622d8dbd30df4e98577\work-runtime-2.7.0-rc01\META-INF\com\android\build\gradle\aar-metadata.properties.

  • 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 8s Exception: Gradle task assembleDebug failed with exit code 1

Below is my AndroidManifest file

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.owaslo.sukithasagayo.caregiver">
<uses-permission android:name="android.permission.INTERNET"/>
<application
    android:label="Sukitha Sagayo Member"
    android:icon="@mipmap/launcher_icon">
    <activity
        android:name=".MainActivity"
        android:launchMode="singleTop"
        android:theme="@style/LaunchTheme"
        android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
        android:hardwareAccelerated="true"
        android:windowSoftInputMode="adjustResize">
        <!-- Specifies an Android theme to apply to this Activity as soon as
             the Android process has started. This theme is visible to the user
             while the Flutter UI initializes. After that, this theme continues
             to determine the Window background behind the Flutter UI. -->
        <meta-data
          android:name="io.flutter.embedding.android.NormalTheme"
          android:resource="@style/NormalTheme"
          />
        <!-- Displays an Android View that continues showing the launch screen
             Drawable until Flutter paints its first frame, then this splash
             screen fades out. A splash screen is useful to avoid any visual
             gap between the end of Android's launch screen and the painting of
             Flutter's first frame. -->
        <meta-data
          android:name="io.flutter.embedding.android.SplashScreenDrawable"
          android:resource="@drawable/launch_background"
          />
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>
    <!-- Don't delete the meta-data below.
         This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
    <meta-data
        android:name="flutterEmbedding"
        android:value="2" />
</application>
</manifest>

Below is my app/build.gradle file

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 from: 
 "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

 //Load the key.properties file into the keystoreProperties 
 object.
 def keystoreProperties = new Properties()
 def keystorePropertiesFile = rootProject.file('key.properties')
 if (keystorePropertiesFile.exists()) {
 keystoreProperties.load(new 
 FileInputStream(keystorePropertiesFile))
 }

 android {
    compileSdkVersion 30

    defaultConfig {
        // TODO: Specify your own unique Application ID 
   (https://developer.android.com/studio/build/application-id.html).
    applicationId "com.owaslo.sukithasagayo.caregiver"
    minSdkVersion 19
    targetSdkVersion 30
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
}

signingConfigs {
    release {
        keyAlias keystoreProperties['keyAlias']
        keyPassword keystoreProperties['keyPassword']
        storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
        storePassword keystoreProperties['storePassword']
    }
}
buildTypes {
    release {
        signingConfig signingConfigs.release
    }
}

}

 flutter {
    source '../..'
  }

Please help !!!

2 Answers2

1

Set kotlin version

kotlin_version = '1.6.0'

in the /android/build.gradle file

Kasujja Muhammed
  • 422
  • 6
  • 11
0

Please share your app/ build.gradle file for which sdk version are you using? seems to be you are using android api level 30 and one of dependency has android api level 31 and its conflicting.

Hardik Mehta
  • 2,195
  • 1
  • 11
  • 14
  • I added the build.gradle file – Kavishka Rajapakshe Jan 21 '22 at 06:04
  • Please change compileSdkVersion to 31 and targetSdkVersion to 31 and try – Hardik Mehta Jan 21 '22 at 06:06
  • Execution failed for task ':app:mergeDexDebug'. > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade > com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: The number of method references in a .dex file cannot exceed 64K. Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html ......I get this error now :( – Kavishka Rajapakshe Jan 21 '22 at 06:17
  • this is multidex related issue. Please follow this : for that https://stackoverflow.com/questions/36785014/the-number-of-method-references-in-a-dex-file-cannot-exceed-64k-api-17 – Hardik Mehta Jan 21 '22 at 06:36