Reputation: 223
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.
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
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
Reputation: 492
Its not problem with the Image provider its something to do with the latest flutter package. To resolve this issue
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
Reputation: 699
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
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
Reputation: 223
Add following line in gradle.properties
android.useAndroidX=true
android.enableJetifier=true
Remove Simple Permission package.
Upvotes: 4