7

after adding

location: ^1.4.1

to my dependencies in pubspec.yaml:

dependencies:
  flutter:
    sdk: flutter

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^0.1.2
  rxdart: ^0.20.0
  http: ^0.12.0
  date_format: ^1.0.5
  intl: ^0.15.7
  fluttertoast: ^2.2.3
  location: ^1.4.1

I do Packages get, and everything is fine, but when I try to build it, the app crashes with a message:

Launching lib\main.dart on Lenovo K33a48 in debug mode... Initializing gradle... Resolving dependencies... Gradle task 'assembleDebug'... D8: Program type already present: android.support.v4.app.INotificationSideChannel

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: "Here goes the list of all jar archives" Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes. Program type already present: android.support.v4.app.INotificationSideChannel

  • 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 18s Finished with error: Gradle task assembleDebug failed with exit code 1

My targetSdk is 28. I use Android Studio 3.2.1 Help would be very much appreciated!

miloss
  • 1,708
  • 1
  • 21
  • 18
  • 1
    https://stackoverflow.com/questions/49886597/multidex-issue-with-flutter – Günter Zöchbauer Jan 12 '19 at 13:40
  • https://stackoverflow.com/questions/50524672/build-fails-with-program-type-already-present-android-arch-core-util-function – Günter Zöchbauer Jan 12 '19 at 13:41
  • 1
    Thank you @GünterZöchbauer, I've learnt how to access android dependency tree based on the first link, but enforcing all the suggested resolution strategies by the compiler was not enough to solve the problem. At the end I got strange error. I've noticed that location plugin 1.4.1 by Lyokone, used together with fluttertoast plugin 2.2.3 caused this issue. It's only after updating fluttertoast to most recent version 2.2.6 (this version is published yesterday), the issue was resolved. Weirdly, the issue was present only on pc computers, not on macbook pros. – miloss Jan 14 '19 at 21:41
  • @miloss did u solve that issue. I see the same problem. – Ride Sun Mar 16 '19 at 01:21
  • No @RideSun , I wasn't able to solve it that way. Plugin update solved the problem. – miloss Mar 19 '19 at 13:55

2 Answers2

0

this happens because the library you are using uses the same dependences.

SOLUTION 1

  1. in VSCode Search (Ctrl+Shift + P)
  2. in your error android.support.v4.app.INotificationSideChannel. search for keywords Notification/Side/Channel. pick one.
  3. If there are the same dependences, it means that there are duplicate libraries.
  4. Solution: Delete one of the libraries you are using

SOLUTION 2 (Recommended)

  1. in VSCode Search (Ctrl+Shift + P)
  2. in your error android.support.v4.app.INotificationSideChannel. search for keywords Notification/Side/Channel. pick one.
  3. Find a library that uses the same dependences, then update to the latest package version.
  4. This solution will keep the library you are using without deleting it
-1

I'm unable to replicate the behavior you've reported. The issue seems to have been resolved by a plugin update as you've mentioned in the comments. Running flutter clean should solve most conflicts caused in the dependencies cache.

Omatt
  • 8,564
  • 2
  • 42
  • 144