Flutter:找不到providerinstaller的本地模块描述符类

时间:2020-09-21 12:34:20

标签: android-studio flutter

我一直在尝试开发可与Firebase配合使用的应用程序,但我不是编码专家。

实际上,我的应用在仿真器上运行良好,但是3-5秒后,我收到一条错误消息,如下所示:

W/DynamiteModule(11855): Local module descriptor class for providerinstaller not found.
I/DynamiteModule(11855): Considering local module providerinstaller:0 and remote module providerinstaller:0
W/ProviderInstaller(11855): Failed to load providerinstaller module: No acceptable module found. Local version is 0 and remote version is 0.
W/DynamiteModule(11855): Local module descriptor class for providerinstaller not found.
I/DynamiteModule(11855): Considering local module providerinstaller:0 and remote module providerinstaller:0
W/ProviderInstaller(11855): Failed to load providerinstaller module: No acceptable module found. Local version is 0 and remote version is 0.

您可以在下面看到我的依赖项:

依赖项:

  flutter:
    sdk: flutter
  cloud_firestore: ^0.14.0+2
  image: ^2.0.7
  animator: 0.1.4
  image_picker: ^0.6.7+7
  google_sign_in: ^4.5.3
  timeago: 2.0.17
  cached_network_image:
  firebase_auth: ^0.18.0+1
  geolocator: 5.0.1
  uuid: ^2.0.0
  cupertino_icons: ^0.1.2
  path_provider: ^1.6.16
  firebase_messaging: ^7.0.0
  firebase_storage: ^4.0.0
  firebase_core: ^0.5.0
  flutter_svg: ^0.19.0

当我尝试使用相机上传图像时,除了上面的providerinstaller问题外,下面还有其他错误:

E/flutter (11855): [ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: NoSuchMethodError: The getter 'path' was called on null.
E/flutter (11855): Receiver: null
E/flutter (11855): Tried calling: path
E/flutter (11855): #0      Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
E/flutter (11855): #1      _UploadPageState.pickImageFromGallery (package:buddiesgram/pages/UploadPage.dart:37:38)
E/flutter (11855): <asynchronous suspension>
E/flutter (11855): #2      _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:992:19)
E/flutter (11855): #3      _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:1098:38)
E/flutter (11855): #4      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:184:24)
E/flutter (11855): #5      TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:524:11)
E/flutter (11855): #6      BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:284:5)
E/flutter (11855): #7      BaseTapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:219:7)
E/flutter (11855): #8      PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:477:9)
E/flutter (11855): #9      PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:78:12)
E/flutter (11855): #10     PointerRouter._dispatchEventToRoutes.<anonymous closure> (package:flutter/src/gestures/pointer_router.dart:124:9)
E/flutter (11855): #11     _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:377:8)
E/flutter (11855): #12     PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:122:18)
E/flutter (11855): #13     PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:108:7)
E/flutter (11855): #14     GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:220:19)
E/flutter (11855): #15     GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:200:22)
E/flutter (11855): #16     GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:158:7)
E/flutter (11855): #17     GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:104:7)
E/flutter (11855): #18     GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:88:7)
E/flutter (11855): #19     _rootRunUnary (dart:async/zone.dart:1206:13)
E/flutter (11855): #20     _CustomZone.runUnary (dart:async/zone.dart:1100:19)
E/flutter (11855): #21     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1005:7)
E/flutter (11855): #22     _invoke1 (dart:ui/hooks.dart:267:10)
E/flutter (11855): #23     _dispatchPointerDataPacket (dart:ui/hooks.dart:176:5)
E/flutter (11855): 

您可以在下面看到我的上传页面代码:

import 'dart:io';
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';

class UploadPage extends StatefulWidget {
  @override
  _UploadPageState createState() => _UploadPageState();
}

class _UploadPageState extends State<UploadPage> {

  PickedFile file;

  captureImageWithCamera() async {
    Navigator.pop(context);
    final picker = ImagePicker();
    PickedFile imageFile = await picker.getImage(
      source: ImageSource.camera,
      maxHeight: 680,
      maxWidth: 970,
    );
    imageFile = PickedFile(imageFile.path);
    setState(() {
      this.file = imageFile;
    });
  }

  pickImageFromGallery() async {

    Navigator.pop(context);
    final picker = ImagePicker();
    PickedFile imageFile = await picker.getImage(
      source: ImageSource.gallery,
      maxHeight: 680,
      maxWidth: 970,
    );
    imageFile = PickedFile(imageFile.path);
    setState(() {
      this.file = imageFile;
    });
  }

  takeImage(mContext){
    return showDialog(
        context: mContext,
        builder: (context){
          return SimpleDialog(
            title: Text("New Post", style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold),),
            children: [
              SimpleDialogOption(
                child: Text("Capture image with camera", style: TextStyle(color: Colors.white),),
                onPressed: captureImageWithCamera,
              ),
              SimpleDialogOption(
                child: Text("Select image from gallery", style: TextStyle(color: Colors.white),),
                onPressed: pickImageFromGallery,
              ),
              SimpleDialogOption(
                child: Text("Cancel", style: TextStyle(color: Colors.white),),
                onPressed: () => Navigator.pop(context),
              ),

            ],
          );
        }
    );
  }

  displayUploadScreen(){
    return Container(
      color: Theme.of(context).accentColor.withOpacity(0.5),
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Icon(Icons.add_a_photo, color: Colors.grey,size: 200.0,),
          Padding(
            padding: EdgeInsets.only(top: 20.0),
            child: RaisedButton(
              shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(9.0),),
              child: Text("Upload Image", style: TextStyle(color: Colors.white, fontSize: 20.0),),
              color: Colors.green,
              onPressed: () => takeImage(context),
            ),
          ),
        ],
      ),
    );
  }


  @override
  Widget build(BuildContext context) {
    return displayUploadScreen();
  }
}

如果您想查看我的代码或其他文件,我想与您分享。你能指导我吗?

谢谢。

关于, 埃金。

3 个答案:

答案 0 :(得分:0)

我不知道您在哪里访问了Firestore软件包,但就我而言,我试图更新数据,但实际上是在删除并创建一个新的文件,该文件没有我需要在代码中访问的数据。因此,我唯一的建议是确保您不会意外删除数据或尝试访问不存在或由于某种未知原因而不会拥有的数据,然后转到firestore数据库并确保您的数据是所需的。我已经看到答案,说您需要在模拟器中更新Google服务,所以也许这是您的情况,但是如果您转到设置中的google play服务应用并看到停用状态,那不是我的意思,这意味着您的模拟器已经更新,并且它将说更新您的Google Play服务。

答案 1 :(得分:0)

当我的应用程序在模拟器中启动时,我也遇到了同样的错误,当我点击添加新数据按钮时也是如此。实际上我的问题正是在 Flutter 中向 Firebase Firestore 添加新数据。

我更新了 Google Play 服务,它对我有用。

要更新 Google Play 服务,请执行以下操作:

文件 > 设置 > 外观和行为 > 系统设置 > Android SDK > SDK 工具,然后选择 Google Play 服务并更新。

希望它有效。

答案 2 :(得分:0)

2021 年 7 月更新:

对于为什么会出现这些警告,没有明确的答案,但可以遵循一些步骤。

  1. 确保在所有三个 AndroidManifest.xml 文件(即 debug/main/profile)中都定义了 <uses-permission android:name="android.permission.INTERNET"/>

对于某些人来说,在主 AndroidManifest 文件中包含 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 也有帮助。

  1. 有时过时的 google play 服务也会导致这些警告,因此请更新 google play 服务,这主要发生在模拟器的情况下。

  2. 如果您在旧设备上运行您的应用程序,请让用户启用 multi-dex。

要启用多dex支持,请在

中添加以下代码

app/build.gradle 文件

defaultConfig {
        applicationId "com.example.flutter_test_firebase"
        minSdkVersion 16
        targetSdkVersion 30
        multiDexEnabled true  //<= add this line
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

并在同一个文件中添加以下依赖项

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation("com.android.support:multidex:1.0.3") // for multi-dex
}

还要确保您使用的是最新的 firebase 插件。