问题
I am running into this weird issue where I am getting this error.
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
Weird thing is this happens after I upgrade file_picker
package and persists even if I downgrade in pubspec.yaml again. But when I try run the project from the backup and replace lib folder with the one where this error occurred, it works perfectly. When this error occurs, plugin downgrade, flutter clean doesn't work. Why is this issue happening? When I click on the error link I am redirected to file_picker->intermediate->library_manifest->debug->Android Manifest.xml and the code there looks as below.
<?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>
Any suggestions on what is wrong and how to fix this?
回答1:
I just found out the solution, queries is a new manifest element and require to use a new gralde android plugin.
so change to this version in build.gradle, this worked for me
classpath 'com.android.tools.build:gradle:4.1.0'
Also change gradle-wrapper version to 6.5 as it is required by 4.1.0 plugin
EDIT:
use this if and only if app does not work in release mode, otherwise use above method.
use file_picker version file_picker: 2.0.7
remember without ^ symbol. use android gradle plugin 3.5 only and don't migrate to 4.1.0.
来源:https://stackoverflow.com/questions/64548677/android-resource-linking-failed-flutter