当前位置: 首页 > 知识库问答 >
问题:

“multi_image_picker”颤动问题

林礼骞
2023-03-14

我为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(),
            )
          ],
        ),
      ),
    );
  }
}

在真实设备上启动应用程序后,我有这个日志输出


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

如果我触摸中心按钮,我就会有这个输出。

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

我该怎么修?

颤动医生

[√] Flutter(Channel beta,v1.17.0,在Microsoft Windows[版本10.0.18363.752]上,语言环境ru ru)
•Flutter版本1.17.0位于C:\src\Flutter
;框架版本d3ed9ec945(6天前),2020-04-06 14:07:34-0700
?引擎版本c9506cb8e9
·Dart版本2.8.0(内部版本2.8.0-dev.18.0 eea9717938)

[√] Android工具链-为Android设备开发(Android SDK版本29 . 0 . 3)< br > Android SDK位于C:\ Users \ kiril \ AppData \ Local \ Android \ SDK < br >平台android-29,build-tools 29 . 0 . 3 < br > Java二进制文件位于C:\ Program Files \ Android \ Android Studio \ JRE \ bin \ Java < br > Java版本OpenJDK运行时环境(build 1 . 8 . 0 _ 212-release-1586-b04)

[√] Android Studio(版本3.6)

Android Studio位于C:\ Program Files \ Android \ Android Studio

•Flutter插件版本44.0.2

• 飞镖插件版本 192.7761

Java版本OpenJDK运行时环境(内部版本1 . 8 . 0 _ 212-版本1586-b04)

[√]VS代码(版本1.43.1)
VS代码在C:\用户\kiril\AppData\本地\程序\微软VS代码Flutter扩展版本3.8.1

[√] 已连接设备 (1 个可用)
• 红米 5 • 1d9634957ce5 • Android-臂64 • Android 7.1.2 (API 25)

没有发现问题!

共有2个答案

程城
2023-03-14
<application
        android:requestLegacyExternalStorage="true">

</application>

如果相机无法打开,请将此添加到清单中的

刁瀚昂
2023-03-14

你能检查你是否在Android智能.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" />
 类似资料:
  • 我试图从TXT文件中读取数据,但出现了一些问题。有一个密码 这是代码从官方documentation.also我试图改变路径到我的文件在文件(")喜欢(资产/file.txt)但仍然没有工作。我得到这个错误后启动程序 我知道我需要在pbuspec添加资产。yaml文件,我做到了。当我从服务中使用rootBundle时也是如此。dart,读取此文件。txt,一切正常,我可以从中读取数据。

  • 正在启动lib\main。IA Emulator上AOSP上的dart处于调试模式。。。正在运行Gradle任务“assembleDebug”。。。警告:插件路径_provider_android需要android SDK版本31。警告:插件共享的_首选项_android需要android SDK版本31。一个或多个插件需要更高的Android SDK版本。通过将以下内容添加到D:\App Dev

  • 这只有在我添加了足够多的依赖项时才会发生,这可能是预期的。我已经按照说明(https://developer.Android.com/studio/build/multidex.html)在Android项目文件中启用了multidex并添加了multidex依赖项,但不确定如何处理Flutter应用程序的“为multidex配置您的应用程序”中的第2步,甚至不确定是否遗漏了该步骤。 > 从工具栏

  • 我下载了android studio的flutter,并在尝试在虚拟设备上运行myapp时出现此错误。在我将Kotlin用于Android Studio之前,一切都会很好。我尝试删除和重新下载flutter和Android Studio。 这是我得到的错误

  • 我无法在尝试设置平台后修复颤振问题,问题如下所示: https://i.stack.imgur.com/uddfn.png

  • 在谷歌Play上部署我的Flitter应用程序后,它在启动时崩溃。它为2台设备(Google Test devices on Play)工作,并为其他设备提供以下错误。 问题:java.lang.不满意LinkError:dalvik.system.PathClassLoader[DexPathList[[[zip file"/data/app/abc.pota.tallxy-1/base.apk