Flutter Android - Gradle task bundleRelease failed with exit code 1
It's a minor issue, Run "Flutter clean" and then "Flutter build appbundle" or "Flutter build apk".
That should fix the issue
raddesso
Updated on December 15, 2022Comments
-
raddesso over 1 year
I am trying to run the command "
flutter build appbundle --verbose
" to generate the android version of my app and i am receiving the error "Gradle task bundleRelease failed with exit code 1
".I don't know yet a lot of things about gradle and your dependencies to each package, I have read some stack-overflow answers, refactored the
bundle.properties
file among other things without success. Here is my build information:flutter build appbundle --verbose
part of output:flutter_secure_storage:bundleLibCompileRelease [ ] ********************************************************* [ ] WARNING: This version of firebase_messaging will break your Android build if it or its dependencies aren't compatible with AndroidX. [ ] See xxxxxxx for more information on the problem and how to fix it. [ ] This warning prints for all Android build failures. The real root cause of the error may be unrelated. [ ] ********************************************************* [ ] 90 actionable tasks: 6 executed, 84 up-to-date [ +426 ms] Running Gradle task 'bundleRelease'... (completed in 11,3s) [ +4 ms] "flutter appbundle" took 20.362ms. Gradle task bundleRelease failed with exit code 1 #0 throwToolExit (package:flutter_tools/src/base/common.dart:28:3) #1 _buildGradleProjectV2 (package:flutter_tools/src/android/gradle.dart:751 :5) <asynchronous suspension> #2 buildGradleProject (package:flutter_tools/src/android/gradle.dart:494:14 ) <asynchronous suspension> #3 buildAppBundle (package:flutter_tools/src/android/app_bundle.dart:43:10) <asynchronous suspension> #4 BuildAppBundleCommand.runCommand (package:flutter_tools/src/commands/bui ld_appbundle.dart:47:11) <asynchronous suspension> #5 FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/fl utter_command.dart:490:18) #6 _asyncThenWrapperHelper.<anonymous closure(dart:async-patch/async_patc h.dart:71:64) #7 _rootRunUnary (dart:async/zone.dart:1132:38) #8 _CustomZone.runUnary (dart:async/zone.dart:1029:19) #9 _FutureListener.handleValue (dart:async/future_impl.dart:137:18) #10 Future._propagateToListeners.handleValueCallback (dart:async/future_impl .dart:678:45) #11 Future._propagateToListeners (dart:async/future_impl.dart:707:32) #12 Future._completeWithValue (dart:async/future_impl.dart:522:5) #13 Future._asyncComplete.<anonymous closure(dart:async/future_impl.dart:5 52:7) #14 _rootRun (dart:async/zone.dart:1124:13) #15 _CustomZone.run (dart:async/zone.dart:1021:19) #16 _CustomZone.runGuarded (dart:async/zone.dart:923:7) #17 _CustomZone.bindCallbackGuarded.<anonymous closure(dart:async/zone.dar t:963:23) #18 _microtaskLoop (dart:async/schedule_microtask.dart:41:21) #19 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5) #20 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:116: 13) #21 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dar t:173:5)
Android (parent) build.gradle:
buildscript { repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.5.1' classpath 'com.google.gms:google-services:4.0.1' } } allprojects { repositories { google() jcenter() } } rootProject.buildDir = '../build' subprojects { project.buildDir = "${rootProject.buildDir}/${project.name}" } subprojects { project.evaluationDependsOn(':app') } task clean(type: Delete) { delete rootProject.buildDir } //solving error subprojects { project.configurations.all { resolutionStrategy.eachDependency { details -> if (details.requested.group == 'com.android.support' && !details.requested.name.contains('multidex') ) { details.useVersion "27.1.0" } } } }
App (child) build.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 Exception("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" def keystoreProperties = new Properties() def keystorePropertiesFile = rootProject.file('key.properties') if (keystorePropertiesFile.exists()) { keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) } android { compileSdkVersion 28 buildToolsVersion "28.0.3" /* lintOptions { disable 'InvalidPackage' }*/ defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "br.com.xxxx.xxxx" minSdkVersion 28 targetSdkVersion 28 versionCode flutterVersionCode.toInteger() versionName flutterVersionName testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } signingConfigs { release { keyAlias keystoreProperties['keyAlias'] keyPassword keystoreProperties['keyPassword'] storeFile file('key.jks') storePassword keystoreProperties['storePassword'] } } buildTypes { release { signingConfig signingConfigs.release minifyEnabled true shrinkResources false //useProguard true //proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } flutter { source '../..' } dependencies { testImplementation 'junit:junit:4.12' implementation 'com.google.firebase:firebase-analytics:17.2.0' implementation 'com.google.firebase:firebase-messaging:20.0.0' androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0' androidTestImplementation 'androidx.test:runner: 1.2.0' implementation 'com.google.firebase:firebase-core:17.0.0' implementation 'com.google.firebase:firebase-iid:17.1.1' } apply plugin: 'com.google.gms.google-services' com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true
Flutter / Dart pubspec.yaml
version: 1.0.0+1 environment: sdk: ">=2.1.0 <3.0.0" dependencies: flutter: sdk: flutter # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^0.1.2 firebase_messaging: ^5.1.6 carousel_pro: ^1.0.0 http: ^0.12.0+2 fluro: ^1.5.0 share: ^0.6.1+1 transparent_image: ^1.0.0 photo_view: ^0.4.2 carousel_slider: ^1.3.0 intl: ^0.15.8 expandable: ^3.0.0+1 url_launcher: ^5.1.2 keyboard_avoider: ^0.1.2 flutter_secure_storage: ^3.2.1+1 keyboard_visibility: ^0.5.6 fluttertoast: ^3.1.0 image_picker: 0.6.0+17 image_cropper: ^1.1.0 shared_preferences: 0.5.3+4 cached_network_image: ^1.1.0 rxdart: ^0.22.2 dio: 3.0.3 path: 1.6.4 uuid: 2.0.2 flutter_app_badger: ^1.0.3+2 badges: ^1.0.0 flutter_local_notifications: ^0.8.4 #device_id: ^0.2.0 dev_dependencies: flutter_test: sdk: flutter # For information on the generic Dart part of this file, see the # following page: https://www.dartlang.org/tools/pub/pubspec # The following section is specific to Flutter. flutter: # The following line ensures that the Material Icons font is # included with your application, so that you can use the icons in # the material Icons class. uses-material-design: true
Do you all have any suggestion to solve this problem?
I have also tried to migrate to AndroidX without success.