Parmendra kumar
Parmendra kumar

Reputation: 223

Flutter, Getting build error on image_picker: ^0.6.0+9

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.

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

Upvotes: 1

Views: 11600

Answers (4)

Abhin Pai
Abhin Pai

Reputation: 492

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

Upvotes: 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

Upvotes: 2

Vicky Salunkhe
Vicky Salunkhe

Reputation: 11025

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.

Upvotes: 9

Parmendra kumar
Parmendra kumar

Reputation: 223

Add following line in gradle.properties

android.useAndroidX=true
android.enableJetifier=true

Remove Simple Permission package.

Upvotes: 4

Related Questions