0

我想从我的 android 模拟器中选择一个图像,然后将其上传到云存储。当我打电话时,File image = await ImagePicker.pickImage(source: ImageSource.gallery);我收到如下错误:

MissingPluginException(No implementation found for method requestPermissions on channel flutter.baseflow.com/permissions/methods)

我试图将相机权限放在 AndroidManifest.xml 文件中:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.somethingdwun.dwun">

    <uses-permission android:name="android.permission.CAMERA" />

    <application
        android:name="io.flutter.app.FlutterApplication"
        android:icon="@mipmap/ic_launcher"
        android:label="dwun">
        <activity
            android:name=".MainActivity"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:windowSoftInputMode="adjustResize">
            <!-- This keeps the window background of the activity showing
                 until Flutter renders its first frame. It can be removed if
                 there is no splash screen (such as the default splash screen
                 defined in @style/LaunchTheme). -->
            <meta-data
                android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
                android:value="true" />
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name="com.yalantis.ucrop.UCropActivity"
            android:screenOrientation="portrait"
            android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>
    </application>
</manifest>

谢谢

4

3 回答 3

1

我发现了这个MissingPluginException

无需在 AndroidManifest.xml 文件中添加权限。关闭您的应用程序,进入项目目录并尝试在命令行中运行它:

flutter clean

我认为它会解决你的问题

于 2019-12-12T04:12:05.637 回答
0

您是否将其添加到您的依赖项中?

首先,在 pubspec.yaml 文件中添加 image_picker 作为依赖项。希望它会帮助你

依赖项:image_picker:^0.6.2+3

于 2019-12-12T02:54:38.923 回答
0

有时热重启或热重载不会成功。确保将 image_picker 添加为pubspec.yaml文件中的依赖项

关闭应用程序并执行flutter run命令。

于 2019-12-12T05:34:56.150 回答