如何解决FLUTTER:将image_picker作为依赖项添加时,在发行版安装中缺少MissingPlugins
我目前在 Android 中遇到以下问题: flutter share插件以及url_launcher插件在实际的发行版安装中不起作用。 一切在调试(物理设备和仿真器)中都可以正常工作。
此外,当在物理设备上运行发行版(从vscode)时,一切都正常。
但是,一旦我安装了发行版,插件将不再可用。
我花了大约3天的时间测试我的Flutter应用,并能够重现该错误。
我发现了以下内容:
-
物理设备logcat抛出缺少的插件异常
-
删除image_picker插件后,一切正常。
Internet权限已添加到Android.Manifest中。 编译和SDK版本为29。 最低SDK版本为21。
我真的希望有人能给我一些有关如何解决MissingPluginException问题的提示。
一个人可以强迫在发行版中注册插件吗?
- 我已经检查了GeneratedPluginRegistrant.java,并列出了所有内容。
- 我进行了十次清洁工作,并对酒吧缓存进行了十次修复
- 我使用了不同的gradle版本
- 我使用了不同的插件版本
谢谢您的时间!
尝试使用url_launcher或共享插件时引发错误:
E flutter : [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: MissingPluginException(No implementation found for method share on channel plugins.flutter.io/share)
11-11 20:36:28.091 23069 23094 E flutter : #0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:157)
11-11 20:36:28.091 23069 23094 E flutter : <asynchronous suspension>
11-11 20:36:28.091 23069 23094 E flutter :
11-11 20:37:19.084 23069 23094 E flutter : [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: MissingPluginException(No implementation found for method canLaunch on channel plugins.flutter.io/url_launcher)
11-11 20:37:19.084 23069 23094 E flutter : #0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:157)
11-11 20:37:19.084 23069 23094 E flutter : <asynchronous suspension>
11-11 20:37:19.084 23069 23094 E flutter : #1 canLaunch (package:url_launcher/url_launcher.dart:124)
11-11 20:37:19.084 23069 23094 E flutter : <asynchronous suspension>
11-11 20:37:19.084 23069 23094 E flutter : #2 _MyHomePageState._tryLaunchURL (package:atestapp/main.dart:36)
11-11 20:37:19.084 23069 23094 E flutter : <asynchronous suspension>
11-11 20:37:19.084 23069 23094 E flutter : #3 _MyHomePageState.build.<anonymous closure> (package:atestapp/main.dart:65)
11-11 20:37:19.084 23069 23094 E flutter : <asynchronous suspension>
11-11 20:37:19.084 23069 23094 E flutter :
11-11 20:37:20.273 3896 9400 D ClClient: Not sending keepalive. Current connection state=STOPPED
Flutter Doctor -v输出:
[√] Flutter (Channel stable,1.22.3,on Microsoft Windows [Version 10.0.18363.1198],locale de-DE)
• Flutter version 1.22.3 at C:\flutter
• Framework revision 8874f21e79 (13 days ago),2020-10-29 14:14:35 -0700
• Engine revision a1440ca392
• Dart version 2.10.3
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at C:\Android-SDK
• Platform android-29,build-tools 29.0.2
• ANDROID_SDK_ROOT = C:\Android-SDK
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
• All Android licenses accepted.
[!] Android Studio (version 4.1.0)
• Android Studio at C:\Program Files\Android\Android Studio
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
[√] VS Code,64-bit edition (version 1.51.0)
• VS Code at C:\Program Files\Microsoft VS Code
• Flutter extension version 3.16.0
[√] Connected device (1 available)
• Pixel 2 XL (mobile) • 801KPTM1379449 • android-arm64 • Android 11 (API 30)
! Doctor found issues in 1 category.
pubspec.yaml
name: atestapp
description: A new Flutter project.
# The following line prevents the package from being accidentally published to
# pub.dev using `pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots,like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number,respectively.
# In Android,build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS,build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# 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.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
image_picker: ^0.6.7+14
url_launcher: ^5.7.10
share: ^0.6.5+4
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.0
dev_dependencies:
flutter_test:
sdk: flutter
# For information on the generic Dart part of this file,see the
# following page: https://dart.dev/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
# To add assets to your application,add an assets section,like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
# An image asset can refer to one or more resolution-specific "variants",see
# https://flutter.dev/assets-and-images/#resolution-aware.
# For details regarding adding assets from package dependencies,see
# https://flutter.dev/assets-and-images/#from-packages
# To add custom fonts to your application,add a fonts section here,# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name,and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,# see https://flutter.dev/custom-fonts/#from-packages
解决方法
我终于找到了问题!
我测试了不同的gradle插件版本,并且不得不从/android/build.gradle中使用classpath 'com.android.tools.build:gradle:4.0.0'
和classpath 'com.android.tools.build:gradle:4.1.0'
TO classpath 'com.android.tools.build:gradle:3.5.0
降级,同时保持distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
一样。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。