简体   繁体   中英

Gradle error when running old Flutter app

I was trying to re-debug my old app, before there was no issue but now there is alot of issues and i can't understand them. i searched in google for some solution they mostly said its something in the gradle files but cant find the exact one for me so here is my error down there.

sorry if it is a stupid question but i need ur help

this is the error:

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
   > One or more issues found when checking AAR metadata values:

     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.camera:camera-view:1.0.0-alpha30.
     AAR metadata file: C:\Users\youss\.gradle\caches\transforms-3\5e5a33a624d6159ecc9e561e0f352c7c\transformed\jetified-camera-view-1.0.0-alpha30\META-INF\com\android\build\gradle\aar-metadata.properties.

     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.activity:activity:1.4.0.
     AAR metadata file: C:\Users\youss\.gradle\caches\transforms-3\f9f5002a34d782344e58c1658fe3e87a\transformed\jetified-activity-1.4.0\META-INF\com\android\build\gradle\aar-metadata.properties.

     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.camera:camera-lifecycle:1.1.0-alpha10.
     AAR metadata file: C:\Users\youss\.gradle\caches\transforms-3\53e0fb9fe6f529b4890301eb27dcd339\transformed\jetified-camera-lifecycle-1.1.0-alpha10\META-INF\com\android\build\gradle\aar-metadata.properties.

     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.camera:camera-core:1.1.0-alpha10.
     AAR metadata file: C:\Users\youss\.gradle\caches\transforms-3\ddb8413464745d4a1f4035872df7a0c3\transformed\jetified-camera-core-1.1.0-alpha10\META-INF\com\android\build\gradle\aar-metadata.properties.

     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.core:core:1.7.0.
     AAR metadata file: C:\Users\youss\.gradle\caches\transforms-3\23c4b0edd799c2e7eef556ade0dea96c\transformed\core-1.7.0\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 9s

this is my gradle.build in my flutter app:

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 {
    compileSdkVersion 30

    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.duckanji"
        minSdkVersion 21
        targetSdkVersion 30
        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"
}

if anything is needed please tell me and please help me thank you people.

Can I know which flutter version are you using for this project? And use complileSdkVersion 31 instead of 30 in your app/build.gradle.

You may try this:

  • use ext.kotlin_version = '1.5.10' in build.gradle
  • change compileSdkVersion and targetSdkVersion to 31 in app/build.gradle
  • in gradle-wrapper.properties change distributionUrl to this distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
  • Then flutter clean and flutter pub get and run again

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM