简体   繁体   中英

Finished with error: Gradle task assembleRelease failed with exit code 1

When I try to build a release version of my flutter app this error occurs. I now that there're many similiar questions on StackOverflow, but I've tried a lot of things to solve it, and none of them helped.

Many people said that this is because of the conflict between one of the firebase plugins (I dont remember wich one exactly) wich migrated to AndroidX and my app which obviously didn't. So I tried to migrate, but when I press Refactor > Migrate to AndroidX... this occurs:

You need to have compileSdk set to at least 28 in your module build.gradle to migrate to AndroidX

But I have 29 compileSdk, so then I was looking how to solve this problem, I was advised to go to android module and then migrate. Well it worked, I guess, but the main problem still wasn't solved. Then I've found an issue on git, where people said to run flutter clean , this didn't help.

Here're some code:

Dependencies from android/build.gradle file:

dependencies {
    classpath 'com.android.tools.build:gradle:3.5.1'
    classpath 'com.google.gms:google-services:4.3.2'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}

Dependencies from android/app/build.gradle file:

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.google.firebase:firebase-analytics:17.2.1'
    implementation "androidx.appcompat:appcompat:1.1.0"
    implementation "androidx.core:core:1.2.0-beta01"
    implementation 'com.facebook.android:facebook-android-sdk:5.8.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

Dependencies from pubspec.yaml:

    http: ^0.12.0+2
    shared_preferences: ^0.5.3+4
    url_launcher: ^5.1.3
    intent: ^1.1.0
    firebase_core: ^0.4.0+9
    firebase_analytics: ^5.0.2
    firebase_auth: ^0.14.0+5
    cloud_firestore: ^0.12.9+5
    google_sign_in: ^4.0.7
    flutter_facebook_login: ^1.1.1
    video_player: ^0.10.2+5

Try this, Open your flutter app folder and go to android\app\build.gradle and add aaptOptions { cruncherEnabled = false } above your defaultConfig {} . Check an example below

aaptOptions { cruncherEnabled = false }
 defaultConfig {
    // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
    applicationId "com.test.test"
    minSdkVersion 16
    targetSdkVersion 30
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
}

you should check your sdk and dependecies version on File -> project structure -> modules or dependencies tab... and check that everything is up to date

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