Adrian Alejo
Adrian Alejo

Reputation: 91

How can I publish my VIsual Studio Code built application as an APK?

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.

Upvotes: 1

Views: 3000

Answers (5)

Kaushik Chandru
Kaushik Chandru

Reputation: 17792

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

Upvotes: 0

MndTheNerd
MndTheNerd

Reputation: 1

For Debug APK:

flutter build apk

For Release APK:

flutter build apk --release

For App Bundle:

flutter build appbundle

Upvotes: 0

Vishal Zaveri
Vishal Zaveri

Reputation: 1557

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.

Upvotes: 0

ch271828n
ch271828n

Reputation: 17617

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.

Upvotes: 1

quim
quim

Reputation: 224

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

flutter build apk --no-shrink

Upvotes: 0

Related Questions