我有一个特定的flutter项目,在添加的某些软件包上有错误,如下所示:
image_picker 软件包问题-运行 ImagePicker.pickImage 时:
Unhandled Exception: MissingPluginException(No implementation found for method pickImage on channel plugins.flutter.io/image_picker)
关于 url_launcher 软件包的问题-运行 canLaunch(url)时:
Unhandled Exception: MissingPluginException(No implementation found for method canLaunch on channel plugins.flutter.io/url_launcher)
关于格子包裹的问题:
Unhandled Exception: PlatformException(error, java.lang.IllegalStateException: Trying to create a platform view of unregistered type: plugins.flutter.io/webview
注意:
扑打医生-v
[√] Flutter (Channel master, v1.16.4-pre.69, on Microsoft Windows [Version 10.0.18362.720], locale en-US)
• Flutter version 1.16.4-pre.69 at C:\Flutter\flutter
• Framework revision 19e7db585d (5 days ago), 2020-04-01 11:16:01 -0700
• Engine revision c9506cb8e9
• Dart version 2.8.0 (build 2.8.0-dev.18.0 eea9717938)
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at C:\Users\mikay\AppData\Local\Android\sdk
• Platform android-29, build-tools 29.0.3
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
• All Android licenses accepted.
[√] Android Studio (version 3.6)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 44.0.2
• Dart plugin version 192.7761
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
[√] VS Code (version 1.43.2)
• VS Code at C:\Users\mikay\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.8.1
[√] Connected device (1 available)
• Samsung Galaxy S8 • 192.168.175.101:5555 • android-x86 • Android 9 (API 28)
• No issues found!
pubspec.yaml
version: 1.0.0+1
environment:
sdk: '>=2.6.0 <3.0.0'
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.3
relative_scale: ^1.0.5
rxdart: ^0.23.1
flutter_signin_button: ^1.0.0
dio: ^3.0.9
pretty_dio_logger: ^1.1.1
firebase_core: ^0.4.4+3
firebase_auth: ^0.15.5+3
cloud_firestore: ^0.13.4+2
firebase_messaging: ^6.0.13
flutter_facebook_login: ^3.0.0
shared_preferences: ^0.5.6+3
flushbar: ^1.10.0
url_launcher: ^5.4.2
intl: ^0.16.1
flutter_advanced_networkimage: ^0.7.0
image_picker: ^0.6.4
decimal: ^0.3.0
plaid: ^1.0.2
webview_flutter: ^0.3.19+9
dev_dependencies:
flutter_test:
sdk: flutter
build.gradle(app)
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 28
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.app.example"
minSdkVersion 20
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.google.firebase:firebase-analytics:17.2.3'
implementation 'com.android.support:multidex:1.0.3'
}
build.gradle(项目级)
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.3'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
答案 0 :(得分:1)
找到了解决方案。原因是我添加了 flutter_facebook_login ,并且没有执行其附加设置,即在 AndroidManifest.xml 上添加了以下代码:
<meta-data android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id"/>
<activity android:name="com.facebook.FacebookActivity"
android:configChanges=
"keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="@string/app_name" />
<activity
android:name="com.facebook.CustomTabActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="@string/fb_login_protocol_scheme" />
</intent-filter>
</activity>
因此,它搞乱了所有启动外部视图的包,例如相机,文件管理器,网络视图等。