1

When I update my package to image_picker: ^0.6.0+9 getting build error. I have already migrate Android X.

Error: Launching lib/main.dart on vivo V3 in debug mode... Initializing gradle... Resolving dependencies... Running Gradle task 'assembleDebug'... D8: Program type already present: android.support.v4.media.MediaBrowserCompat$CustomActionCallback

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.

    com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes. Program type already present: android.support.v4.media.MediaBrowserCompat$CustomActionCallback

  • 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 2s

The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.


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

Parmendra kumar
  • 203
  • 2
  • 3
  • 7

4 Answers4

9

Make Sure to follow the guide to support AndroidX

https://flutter.dev/docs/development/packages-and-plugins/androidx-compatibility

For Solving Dex error

Try adding this line In your Project folder > android > app > build.gradle

add the following Line in multiDexEnabled true

inside defaultConfig

Use flutter clean command once it is done then try running your app.

Vicky Salunkhe
  • 9,869
  • 6
  • 42
  • 59
4

Add following line in gradle.properties

android.useAndroidX=true
android.enableJetifier=true

Remove Simple Permission package.

Parmendra kumar
  • 203
  • 2
  • 3
  • 7
2

it's because your app isn't compatible with AndroidX ,

There are 2 solution

1-create a flutter compatible with AndroidX app by using this command in your terminal

flutter create --androidx [project_name]

2-configure your app manually

2

Its not problem with the Image provider its something to do with the latest flutter package. To resolve this issue

  1. Open the Android folder of your your flutter project in Android Studio
  2. Wait for the gradle to build once the task is complete click on Refactor -> Refactor this -> Migrate to AndroidX or press Ctrl+T -> Migrate to AndroidX
  3. Do flutter clean
  4. And boom your good to go

If you want to do manually by twicking the gradle file here is link https://flutter.dev/docs/development/androidx-migration

Happy Hacking

Misha Akopov
  • 12,241
  • 27
  • 68
  • 82
Abhin Pai
  • 332
  • 3
  • 10