简体   繁体   中英

trouble when updating webview_flutter plugin to latest version (0.3.6)

I'm trying to upgrade my version of the flutter_webview plugin to the most recent one.

Currently I'm on v0.2.0 and everything works. After updating it in pubspec.yaml to v0.3.6 and running flutter run I get this:

Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
D8: Program type already present: android.support.v4.os.ResultReceiver$MyResultReceiver


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

I then updated my build.gradle file, added a line in the defaultConfig section of build.gradle, like so:

multiDexEnabled true

After doing that, I get this:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
com.android.build.api.transform.TransformException: Error while generating the main dex list.

Next up, I went into my build.gradle file and updated my gradle version from 3.2.1 to 3.3.2. After doing so I got this:

Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
D8: Program type already present: android.support.v4.app.INotificationSideChannel$Stub$Proxy

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
 com.android.build.api.transform.TransformException: Error while generating the main dex list:
  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.app.INotificationSideChannel$Stub$Proxy

I went into gradle.properties and added two lines:

android.useAndroidX=true
android.enableJetifier=true

..and as a result got a ton of messages like this:

Resolving dependencies...                                           3.9s
c:\src\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_custom_tabs-0.4.0\android\src\main\java\com\github\droibit\flutter\plugins\customtabs\CustomTabsPlugin.java:7: error: package android.support.annotation does not exist
import android.support.annotation.NonNull;
                                 ^
c:\src\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_custom_tabs-0.4.0\android\src\main\java\com\github\droibit\flutter\plugins\customtabs\CustomTabsPlugin.java:8: error: cannot find symbol
import android.support.customtabs.CustomTabsIntent;

As you can probably tell, I'm not an expert on gradle and am basically flopping around at this point, reading stack overflow posts and trying to find some magic combination that works. Would anyone have an idea of an approach I can try to fix the original issue?

If it helps, I opened my project in Android Studio and tried to upgrade to AndroidX by choosing Refactor-->Migrate to AndroidX, and was told I wasn't using AndroidX.

[Edit] here are the contents of my pubspec.yaml file:

# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1

environment:
  sdk: ">=2.1.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  webfeed: ^0.4.2
  http: 0.12.0
  flutter_bloc: 0.9.1
  equatable: ^0.2.0
  flutter_html_view: ^0.5.11
  webview_flutter: ^0.2.0
  html2md: ^0.2.1

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^0.1.2

dev_dependencies:
  flutter_test:
    sdk: flutter


# For information on the generic Dart part of this file, see the
# following page: https://www.dartlang.org/tools/pub/pubspec

# The following section is specific to Flutter.
flutter:

  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true

Ok, I got past this error. What appears to be happening is a conflict with flutter_html_view . If I remove that package (and all uses of it) from my app, things work again. I also updated a few other dependencies to their latest versions, and as of this moment my pubspec.yaml dependecies section looks like:

dependencies:
  flutter:
    sdk: flutter
  webfeed: ^0.4.2
  http: 0.12.0
  flutter_bloc: 0.13.0
  #equatable: ^0.2.0
  #flutter_html_view: ^0.5.11
  webview_flutter: ^0.3.6
  html2md: ^0.2.1

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^0.1.2 

I would love to know how to analyze these kinds of dependency issues in the future, because my 'solution' to this involved upgrading all my dependencies, then removing the reference to (and code using) flutter_html_view -- I got lucky, if having to figure out a replacement for flutter_html_view is considered lucky.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM