1

I'm trying to build an App Bundle in Visual Studio Code but it always failing and it shows:

    FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:shrinkReleaseResources'.
> org.xml.sax.SAXParseException; lineNumber: 6; columnNumber: 7; Attribute "keep" bound to namespace "http://schemas.android.com/tools" was already specified for element "resources".

* 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

Here are the dependecies that I used in my project:

  dependencies:
  flutter:
    sdk: flutter

  sqflite: ^2.0.0+3
  intl: ^0.17.0
  syncfusion_flutter_calendar: ^19.2.62
  provider: ^5.0.0
  cupertino_icons: ^1.0.2  
  material_design_icons_flutter: ^5.0.5955-rc.1
  curved_navigation_bar: ^1.0.1
  responsive_text_field: ^0.1.4
  flutter_datetime_picker: ^1.5.1
  datetime_picker_formfield: ^2.0.0
  flutter_local_notifications: ^8.1.1+1
  table_calendar: ^3.0.2
  shared_preferences: ^2.0.8
  shared_preferences_web: ^2.0.2
  firebase_auth: ^3.1.2
  cloud_firestore: ^2.5.3
  firebase_core: ^1.7.0
  flutter_spinkit: ^5.1.0
  fluttertoast: ^8.0.8
  image_picker: ^0.8.4+2
  image_cropper: ^1.4.1
  photo_view: ^0.13.0
  rxdart: ^0.27.2
  badges: ^2.0.1
  profanity_filter: ^2.0.0

and also when I'm having trouble when do I run the --stacktrace to figure out the error. I tried in terminal but it looks like there's no stacktrace command in there.

Adrian Alejo
  • 91
  • 10
  • 2
    Please add code and data as text ([using code formatting](//stackoverflow.com/editing-help#code)), not images. Images: A) don't allow us to copy-&-paste the code/errors/data for testing; B) don't permit searching based on the code/error/data contents; and [many more reasons](//meta.stackoverflow.com/a/285557). Images should only be used, in addition to text in code format, if having the image adds something significant that is not conveyed by just the text code/error/data. – Suraj Rao Nov 06 '21 at 16:14
  • looks like you have to check your android XML resources. Maybe you added tools:keep twice. – Eugene Kuzmenko Nov 06 '21 at 20:53
  • Share your AndroidManifest.xml file, I guess the issue is with your XML file, did you edit it when configuring firebase? – Mr Random Nov 16 '21 at 02:37

5 Answers5

1

Firstly,

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.

Please run with --debug or --scan and paste outputs here. Without much information it is quite hard to spot the bug.

Secondly,

org.xml.sax.SAXParseException; lineNumber: 6; columnNumber: 7; Attribute "keep" bound to namespace "http://schemas.android.com/tools" was already specified for element "resources".

this is related to the resource files. Please list what plugins you have used in your flutter app (e.g. paste your pubspec.yaml). Also list what modifications you made to the android directory of flutter app.

ch271828n
  • 15,854
  • 5
  • 53
  • 88
0

To build a flutter apk with no errors I always do the following (on terminal):

flutter build apk --no-shrink
quim
  • 203
  • 3
  • 8
0

You can also try this:

  1. Clean, build & run the project on the android platform.
  2. Then just open it in an android folder like this.
  3. Then just follow generate normal android signed .apk steps like this.

Note: make sure the android folder opened project must be sync, clean, Build & error-free then only you can able to generate android singed apk.

Vishal Zaveri
  • 1,372
  • 2
  • 5
  • 12
0

For Debug APK:

flutter build apk

For Release APK:

flutter build apk --release

For App Bundle:

flutter build appbundle
Peter Csala
  • 17,736
  • 16
  • 35
  • 75
0

Delete .idea folder from your project root. Delete pubspec.lock. run flutter clean, then flutter pub get and try again.

Kaushik Chandru
  • 15,510
  • 2
  • 12
  • 30