我遇到了这个奇怪的问题,我收到了这个错误。
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\live\project_backup\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
BUILD FAILED in 15s
Run Code Online (Sandbox Code Playgroud)
奇怪的是,这发生在我升级file_picker包之后,即使我再次在 pubspec.yaml 中降级,这种情况仍然存在。但是当我尝试从备份运行项目并将 lib 文件夹替换为发生此错误的文件夹时,它运行良好。发生此错误时,插件降级、flutter clean 不起作用。为什么会出现这个问题?当我点击错误链接时,我被重定向到 file_picker->intermediate->library_manifest->debug->Android Manifest.xml,那里的代码如下所示。
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mr.flutter.plugin.filepicker" >
<uses-sdk android:minSdkVersion="16" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<queries>
<intent>
<action android:name="android.intent.action.GET_CONTENT" />
<data android:mimeType="*/*" />
</intent>
</queries>
Run Code Online (Sandbox Code Playgroud)
关于出了什么问题以及如何解决这个问题的任何建议?
我刚刚找到了解决方案,查询是一个新的清单元素,需要使用新的 grade android 插件。
所以在build.gradle中更改为这个版本,这对我有用
classpath 'com.android.tools.build:gradle:4.1.0'
Run Code Online (Sandbox Code Playgroud)
还要将 gradle-wrapper 版本更改为 6.5,因为 4.1.0 插件需要它
编辑:
当且仅当应用程序在发布模式下不起作用时才使用此方法,否则使用上述方法。
使用 file_picker 版本file_picker: 2.0.7记住没有 ^ 符号。仅使用 android gradle 插件 3.5,不要迁移到 4.1.0。