我正在尝试将我的flutter_webview插件版本升级到最新版本。
当前,我正在使用v0.2.0,一切正常。在pubspec.yaml中将其更新到v0.3.6并运行flutter run之后,我得到了这一点:
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
然后我更新了build.gradle文件,在build.gradle的defaultConfig部分中添加了一行,如下所示:
multiDexEnabled true
这样做之后,我得到了:
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.
接下来,我进入了build.gradle文件,并将gradle版本从3.2.1更新到了3.3.2。这样做之后,我得到了:
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
我进入gradle.properties并添加了两行:
android.useAndroidX=true
android.enableJetifier=true
..结果收到了大量这样的消息:
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;
您可能会说,我不是gradle方面的专家,基本上到此为止,我会四处闲逛,阅读堆栈溢出文章,并尝试找到可行的魔术组合。有人会想到我可以尝试解决原始问题的方法吗?
如果有帮助,我在Android Studio中打开了我的项目,并尝试通过选择“重构”->“迁移到AndroidX”来升级到AndroidX,并被告知我没有使用AndroidX。
[编辑]这是我的pubspec.yaml文件的内容:
# 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
答案 0 :(得分:0)
好的,我克服了这个错误。似乎正在发生与flutter_html_view
的冲突。如果我从我的应用中删除了该软件包(及其所有使用),一切都会恢复。我还将其他一些依赖项更新到了最新版本,到目前为止,我的pubspec.yaml依赖项部分如下:
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
我很想知道将来如何分析这类依赖关系问题,因为对此的“解决方案”涉及升级我的所有依赖关系,然后删除对flutter_html_view
的引用(并使用以下代码进行引用)-我很幸运,如果必须找出flutter_html_view的替代品是幸运的。