picker在构建中引发异常

picker在构建中引发异常

本文介绍了image_picker在构建中引发异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力解决image_picker的问题两天了.从昨天中午开始,当时我尝试调试应用程序.据我所记得,那时我没有做任何更改,它可以很好地进行调试.它抛出了意外元素< queries>.出现在< manifest> 错误中,就像今天下面的错误日志一样,它启动了Jetfier来解决不兼容问题.Jetfier昨天抛出的错误类似于未找到 SDK位置.在local.properties或使用ANDROID_SDK_ROOT环境变量中定义位置.但是SDK的位置是在local.properties中定义的,我还创建了 ANDROID_SDK_ROOT env.SDK位置添加变量,但错误保持不变.

I am wrestling problems with image_picker for two days now. It started yesterday noon when I tried to debug my application. It would debug fine before and as far as I remember I didn't change anything in that time. It throwed unexpected element <queries> found in <manifest>. error and just like the error log from today below it started Jetfier to solve the incompatibility. The error Jetfier throwed yesterday was something like SDK location not found. Define location in local.properties or with an ANDROID_SDK_ROOT environment variable. But SDK location was defined in local.properties and I also created the ANDROID_SDK_ROOT env. variable with the SDK location but the error stayed the same.

今天,我完全清除了flutter文件夹,然后重新安装了它.之后,我在device-info上遇到了一些问题,但最终它得到了解决.现在,我被困在这里,无论如何都没有任何进展.如果我删除了 AndroidManifest.xml 中的< queries> ,则在尝试运行该程序时将其再次放置在该位置,这不是解决方案.

Today I cleared the flutter folder completely and I reinstalled it. After that I had some problems with device-info but eventually it was resolved. Now I am stuck here and I am making no progress whatsoever. If I remove <queries> in AndroidManifest.xml, it is put there again when try to run the program so that's not a solution.

我在 pubspec.yaml 中将其称为 file_picker:^ 2.0.10 (在依赖项下),并且尝试了 pub get pub缓存修复 pub clean (按不同顺序).如果我删除 file_picker 及其在项目中的所有使用,则其余应用程序都可以正常运行.我在另一个项目中尝试过 file_picker ,这比起其他项目要简单得多,而且在那里也引发了相同的异常.

I call it in pubspec.yaml as file_picker: ^2.0.10 under dependencies and I tried pub get, pub cache repair, pub clean in different orders. If I remove the file_picker and all it's uses in the project, rest of the application runs just fine. I tried file_picker in another project, something a lot more basic and it also threw the same exception there.

下面是错误代码.如果您需要更多详细信息,请告诉我.

Below is the error code. If you need anymore details let me know.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > Android resource linking failed
     C:\Users\ASUS\AndroidStudioProjects\flutterdb\intern1\build\file_picker\intermediates\library_manifest\debug\AndroidManifest.xml:9:5-15:15: AAPT: error: unexpected element <queries> found in <manifest>.


* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BU�LD FAILED in 21s
The built failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetfier to solve the incompatibility.
Building plugin file_picker...
Running Gradle task 'assembleAarRelease'...

C:\Users\ASUS\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\file_picker-2.0.10\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:10: error: cannot find symbol
import androidx.lifecycle.DefaultLifecycleObserver;
                         ^
  symbol:   class DefaultLifecycleObserver
  location: package androidx.lifecycle
C:\Users\ASUS\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\file_picker-2.0.10\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:20: error: cannot find symbol
import io.flutter.embedding.engine.plugins.lifecycle.FlutterLifecycleAdapter;
                                                    ^
  symbol:   class FlutterLifecycleAdapter
  location: package io.flutter.embedding.engine.plugins.lifecycle
C:\Users\ASUS\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\file_picker-2.0.10\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:38: error: cannot find symbol
            implements Application.ActivityLifecycleCallbacks, DefaultLifecycleObserver {
                                                               ^
  symbol:   class DefaultLifecycleObserver
  location: class FilePickerPlugin
C:\Users\ASUS\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\file_picker-2.0.10\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:45: error: method does not override or implement a method from a supertype
        @Override
        ^
C:\Users\ASUS\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\file_picker-2.0.10\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:49: error: method does not override or implement a method from a supertype
        @Override
        ^
C:\Users\ASUS\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\file_picker-2.0.10\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:53: error: method does not override or implement a method from a supertype
        @Override
        ^
C:\Users\ASUS\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\file_picker-2.0.10\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:57: error: method does not override or implement a method from a supertype
        @Override
        ^
C:\Users\ASUS\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\file_picker-2.0.10\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:61: error: method does not override or implement a method from a supertype
        @Override
        ^
C:\Users\ASUS\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\file_picker-2.0.10\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:66: error: method does not override or implement a method from a supertype
        @Override
        ^
C:\Users\ASUS\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\file_picker-2.0.10\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:277: error: cannot find symbol
            this.lifecycle = FlutterLifecycleAdapter.getActivityLifecycle(activityBinding);
                             ^
  symbol:   variable FlutterLifecycleAdapter
  location: class FilePickerPlugin
C:\Users\ASUS\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\file_picker-2.0.10\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:278: error: incompatible types: FilePickerPlugin.LifeCycleObserver cannot be converted to LifecycleObserver
            this.lifecycle.addObserver(this.observer);
                                           ^
C:\Users\ASUS\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\file_picker-2.0.10\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:286: error: incompatible types: FilePickerPlugin.LifeCycleObserver cannot be converted to LifecycleObserver
        this.lifecycle.removeObserver(this.observer);
                                          ^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
12 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileReleaseJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUİLD FAILED in 3s

Exception: The plugin file_picker could not be built due to the issue above.

推荐答案

这是因为标记是随Android 11及更高版本(SDK 30+)的新程序包可见性选项一起引入的.因此,您需要使用包含此更改的版本更新build.gradle.以下是受支持的gradle选项的列表.

This is because tag was introduced with new package visibility options for Android 11 and upwards (SDK 30+). Because of that, you need to update your build.gradle with a version that includes this changes. Below is a list of supported gradle options.

"3.3.3","3.4.3","3.5.4","3.6.4","4.0.1"

也不要忘记在gradle-wrapper.properties中更新您的ditributionUrl.例如,对于gradle 4.0.1 ,您应该具有:

Don't forget to update your ditributionUrl in your gradle-wrapper.properties as well. For example, for gradle 4.0.1, you should have:

distributionUrl = https://services.gradle.org/distributions/gradle-6.1.1-all.zip

distributionUrl=https://services.gradle.org/distributions/gradle-6.1.1-all.zip

参考:: https://github.com/miguelpruivo/flutter_file_picker/wiki/Troubleshooting#android

这篇关于image_picker在构建中引发异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 21:38