0
votes

I made example code for multi_image_picker

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:multi_image_picker/multi_image_picker.dart';

void main() => runApp(new MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => new _MyAppState();
}

class _MyAppState extends State<MyApp> {
  List<Asset> images = List<Asset>();
  String _error = 'No Error Dectected';

  @override
  void initState() {
    super.initState();
  }

  Widget buildGridView() {
    return GridView.count(
      crossAxisCount: 3,
      children: List.generate(images.length, (index) {
        Asset asset = images[index];
        return AssetThumb(
          asset: asset,
          width: 300,
          height: 300,
        );
      }),
    );
  }

  Future<void> loadAssets() async {
    List<Asset> resultList = List<Asset>();
    String error = 'No Error Dectected';

    try {
      resultList = await MultiImagePicker.pickImages(
        maxImages: 300,
        enableCamera: true,
        selectedAssets: images,
        cupertinoOptions: CupertinoOptions(takePhotoIcon: "chat"),
        materialOptions: MaterialOptions(
          actionBarColor: "#abcdef",
          actionBarTitle: "Example App",
          allViewTitle: "All Photos",
          useDetailsView: false,
          selectCircleStrokeColor: "#000000",
        ),
      );
    } on Exception catch (e) {
      error = e.toString();
    }
    if (!mounted) return;

    setState(() {
      images = resultList;
      _error = error;
    });
  }

  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Column(
          children: <Widget>[
            Center(child: Text('Error: $_error')),
            RaisedButton(
              child: Text("Pick images"),
              onPressed: loadAssets,
            ),
            Expanded(
              child: buildGridView(),
            )
          ],
        ),
      ),
    );
  }
}

And after start app on the real device I have this log output


V/BoostFramework(27660): BoostFramework() : mPerf = com.qualcomm.qti.Performance@323e3f1

if I touch center button I have this output

I/Timeline(27660): Timeline: Activity_launch_request time:878329589 intent:Intent { cmp=com.kiryacompany.test003/com.sangcomz.fishbun.ui.album.AlbumActivity }
W/art     (27660): Before Android 4.1, method android.graphics.PorterDuffColorFilter androidx.vectordrawable.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
I/art     (27660): Rejecting re-init on previously-failed class java.lang.Class<androidx.core.view.ViewCompat$2>: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/view/View$OnUnhandledKeyEventListener;
I/art     (27660):   at void androidx.core.view.ViewCompat.setOnApplyWindowInsetsListener(android.view.View, androidx.core.view.OnApplyWindowInsetsListener) (ViewCompat.java:2421)
I/art     (27660):   at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:637)
I/art     (27660):   at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:518)
I/art     (27660):   at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView(int) (AppCompatDelegateImpl.java:466)
I/art     (27660):   at void androidx.appcompat.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:140)
I/art     (27660):   at void com.sangcomz.fishbun.ui.album.AlbumActivity.onCreate(android.os.Bundle) (AlbumActivity.java:75)
I/art     (27660):   at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:6875)
I/art     (27660):   at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1119)
I/art     (27660):   at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2677)
I/art     (27660):   at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2785)
I/art     (27660):   at void android.app.ActivityThread.-wrap12(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
I/art     (27660):   at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1524)
I/art     (27660):   at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:102)
I/art     (27660):   at void android.os.Looper.loop() (Looper.java:163)
I/art     (27660):   at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6239)
I/art     (27660):   at java.lang.Object java.lang.reflect.Method.invoke!(java.lang.Object, java.lang.Object[]) (Method.java:-2)
I/art     (27660):   at void com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run() (ZygoteInit.java:904)
I/art     (27660):   at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:794)
I/art     (27660): Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.View$OnUnhandledKeyEventListener" on path: DexPathList[[zip file "/data/app/com.kiryacompany.test003-1/base.apk"],nativeLibraryDirectories=[/data/app/com.kiryacompany.test003-1/lib/arm64, /data/app/com.kiryacompany.test003-1/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]
I/art     (27660):   at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:56)
I/art     (27660):   at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:380)
I/art     (27660):   at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
I/art     (27660):   at void androidx.core.view.ViewCompat.setOnApplyWindowInsetsListener(android.view.View, androidx.core.view.OnApplyWindowInsetsListener) (ViewCompat.java:2421)
I/art     (27660):   at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:637)
I/art     (27660):   at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:518)
I/art     (27660):   at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView(int) (AppCompatDelegateImpl.java:466)
I/art     (27660):   at void androidx.appcompat.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:140)
I/art     (27660):   at void com.sangcomz.fishbun.ui.album.AlbumActivity.onCreate(android.os.Bundle) (AlbumActivity.java:75)
I/art     (27660):   at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:6875)
I/art     (27660):   at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1119)
I/art     (27660):   at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2677)
I/art     (27660):   at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2785)
I/art     (27660):   at void android.app.ActivityThread.-wrap12(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
I/art     (27660):   at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1524)
I/art     (27660):   at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:102)
I/art     (27660):   at void android.os.Looper.loop() (Looper.java:163)
I/art     (27660):   at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6239)
I/art     (27660):   at java.lang.Object java.lang.reflect.Method.invoke!(java.lang.Object, java.lang.Object[]) (Method.java:-2)
I/art     (27660):   at void com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run() (ZygoteInit.java:904)
I/art     (27660):   at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:794)
I/art     (27660): 
V/BoostFramework(27660): BoostFramework() : mPerf = com.qualcomm.qti.Performance@324ab61
V/BoostFramework(27660): BoostFramework() : mPerf = com.qualcomm.qti.Performance@dab686
I/Timeline(27660): Timeline: Activity_launch_request time:878329874 intent:Intent { act=android.content.pm.action.REQUEST_PERMISSIONS pkg=com.google.android.packageinstaller (has extras) }
E/RecyclerView(27660): No adapter attached; skipping layout

How can I fix it?

Flutter doctor

[√] Flutter (Channel beta, v1.17.0, on Microsoft Windows [Version 10.0.18363.752], locale ru-RU)
• Flutter version 1.17.0 at C:\src\flutter
• Framework revision d3ed9ec945 (6 days ago), 2020-04-06 14:07:34 -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\kiril\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.1)
• VS Code at C:\Users\kiril\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.8.1

[√] Connected device (1 available)
• Redmi 5 • 1d9634957ce5 • android-arm64 • Android 7.1.2 (API 25)

• No issues found!

2

2 Answers

1
votes

Can you check if you have added required permissions in AndroidManifest.xml?

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
0
votes
<application
        android:requestLegacyExternalStorage="true">

</application>

if the camera is not opening add this in manifest under <application tag