Android resource linking failed Flutter - flutter

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?

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.

Related

Flutter Error when building: Invalid <color> for given resource value

I wanted to change the App icon with the flutter_launcher_icons package but after I did flutter run I get the following error even though I never edited the File mentioned in the error
This is the error:
PS C:\Flutter\appname> flutter run
Launching lib\main.dart on Pixel 5 in debug mode...
C:\Users\jjkla\.gradle\caches\transforms-3\8de94d7eb39fc01aa715c73f850e88dc\transformed\core-1.6.0\res\values\values.xml:5:4: Invalid <color> for given resource value.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.res.ResourceCompilerRunnable
> Resource compilation failed. Check logs 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
BUILD FAILED in 13s
Running Gradle task 'assembleDebug'... 14,3s
Part of the File where it says the color is invalid:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<attr format="reference" name="nestedScrollViewStyle"/>
<color name="androidx_core_ripple_material_light">#1f000000</color>
<color name="androidx_core_secondary_text_default_material_light">#7E000000</color>
<color name="notification_action_color_filter">#ffffffff</color>
<color name="notification_icon_bg_color">#ff9e9e9e</color>
<dimen name="compat_button_inset_horizontal_material">4dp</dimen>
...
I reinstalled Android Studio, did flutter clean, updated Java and run flutter doctor without success. Does anyone had this error before?
Can you remove 2 f from both colours? Because the color hashCode length should be 6.
Your file should like this.
<color name="notification_action_color_filter">#ffffff</color>
<color name="notification_icon_bg_color">#9e9e9e</color>

Exception: Gradle task assembleDebug failed with exit code 1?

my console
> Launching lib\main.dart on AOSP on IA Emulator in debug mode...
Running Gradle task 'assembleDebug'...
E:\Flutter Project\perpet1\android\app\src\debug\AndroidManifest.xml:15:9-22:20 Error:
android:exported needs to be explicitly specified for element <receiver#com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugMainManifest'.
> Manifest merger failed : android:exported needs to be explicitly specified for element <receiver#com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported 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
BUILD FAILED in 16s
Exception: Gradle task assembleDebug failed with exit code 1
my AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.perpet1">
<!-- The INTERNET permission is required for development. Specifically,
the Flutter tool needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver"/>
</manifest>
So, I did flutter_local_notification update.
Then it appeared on the console as follows.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
There is no flutter doctor issue.
(in Android Studio)
First, I apologize that English is not my main language and it can be awkward because it is also my first time posting questions.
Above is the error on my console window.
I searched all day yesterday but couldn't find a solution. I would be truly grateful if someone helped me. TT

i am building zoom clone(flutter) using jitsi meet ,while runing the app on android emulator i am getting these error

1:19 Error:
android:exported needs to be explicitly specified for element <service#org.jitsi.meet.sdk.ConnectionService>. Apps targeting Android 12 and higher are required to specify an explicit value for android:exported when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:processDebugMainManifest'.
Manifest merger failed : android:exported needs to be explicitly specified for element <service#org.jitsi.meet.sdk.ConnectionService>. Apps targeting Android 12 and higher are required to specify an explicit value for android:exported when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported 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
BUILD FAILED in 9s
Running Gradle task 'assembleDebug'... 11.3s
Exception: Gradle task assembleDebug failed with exit code 1
➜ untitled1
have you resolved this yet? if not, paste the below code inside the '<application></application>' of your AndroidManifest.xml
<application>
...
<service
android:name="org.jitsi.meet.sdk.ConnectionService"
android:permission="android.permission.BIND_TELECOM_CONNECTION_SERVICE"
android:exported="true">
<intent-filter>
<action android:name="android.telecom.ConnectionService" />
</intent-filter>
</service>
</application>
Let me know if it works for you.

Flutter - Execution failed for task ':app:multiDexListDebug'

After adding the plugin webview_flutter_plus and after adding this line in android:usesCleartextTraffic="true" in your <project-directory>/android/app/src/main/AndroidManifest.xml under application
and Required Permissions line
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
I am facing the below error. Can anyone help me out to get this fixed?
Error :
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:multiDexListDebug'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Error while merging dex archives:
Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
Type io.flutter.plugins.webviewflutter.WebViewFlutterPlugin is defined multiple times: C:\Users\Admin\Downloads\flow-0.1-master\build\webview_media\intermediates\runtime_library_classes\debug\classes.jar:io/flutter/plugins/webviewflutter/WebViewFlutterPlugin.class, C:\Users\Admin\Downloads\flow-0.1-master\build\webview_flutter\intermediates\runtime_library_classes\debug\classes.jar:io/flutter/plugins/webviewflutter/WebViewFlutterPlugin.class
* 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 1m 47s
Exception: Gradle task assembleDebug failed with exit code 1
If your minSdkVersion is set to 21 or higher, multidex is enabled by default and you do not need the multidex support library.
Below 21 API
android {
defaultConfig {
...
minSdkVersion 15
targetSdkVersion 28
multiDexEnabled true
}
...
}
dependencies {
implementation 'com.android.support:multidex:1.0.3' // add latest dependency
}
Have you tried enabling multiDex in android folder -> app folder -> build.gradle file?
defaultConfig {
multiDexEnabled true
}
this happens because the library you are using uses the same dependences.
in my case,i use package
flutter html : 1.0.0
youtube_player_flutter: ^6.1.0
and both packages use the same dependences, namely webview_flutter so that the error is
io.flutter.plugins.webviewflutter.WebViewFlutterPlugin
Solution
in VSCode Search (Ctrl+Shift + P)
in your error io.flutter.plugins.webviewflutter.WebViewFlutterPlugin search for keywords webview.
Find a library that uses the same dependences, then update to the latest package version.(Work for me)
This solution will keep the library you are using without deleting it.
flutter html : 1.0.0
youtube_player_flutter: ^7.0.0

Android Build Error when using the barcodescanner and qrscanner at the same time

When I use the phonegap-plugin-barcodescanner plugin and the cordova-plugin-qrscanner plugin at the same time in a project, it won't compile for the android plattform. The error it outputs is duplicate permission element in the manifest. Upon checking I saw that this is indeed the case. However manual correction doesn't work as it will be regenerated automatically.
I documented the reproduction scenario further down. It is very simple. Maybe someone has an idea how to solve this issue? Or do you think this is a bug? But where should I open the issue in such a case?
Used version:
Ionic: 3.20.0
cordova: 8.0.0
Steps to reproduce:
Start a new project ionic start permissionissue blank (when it asks if it should integrate with the iOS and Android platform say yes, when it asks to install the ProSDK say no
Change into the project folder: cd permissionissue
Build it: ionic cordova build --release android -> Still everything is fine
Install the first plugin: ionic cordova plugin add phonegap-plugin-barcodescanner
Build it: ionic cordova build --release android -> Still everything is fine
Install the second plugin: ionic cordova plugin add cordova-plugin-qrscanner
Try to build it: ionic cordova build --release android -> Now it breaks
It will show the following error:
> Manifest merger failed with multiple errors, see logs
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or
--debug
option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 4s
23 actionable tasks: 3 executed, 20 up-to-date
(node:12659) UnhandledPromiseRejectionWarning: Error: .../permissionissue/platforms/android/gradlew: Command failed with exit code 1 Error output:
.../permissionissue/platforms/android/app/src/main/AndroidManifest.xml:19:5-90 Error:
Element uses-permission#android.permission.CAMERA at AndroidManifest.xml:19:5-90 duplicated with element declared at AndroidManifest.xml:16:5-65
.../permissionissue/platforms/android/app/src/main/AndroidManifest.xml:20:5-85 Error:
Element uses-feature#android.hardware.camera at AndroidManifest.xml:20:5-85 duplicated with element declared at AndroidManifest.xml:18:5-84
.../permissionissue/platforms/android/app/src/main/AndroidManifest.xml Error:
Validation failed, exiting
FAILURE: Build failed with an exception.
The generated Manifest looks like this:
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.FLASHLIGHT" />
<uses-feature android:name="android.hardware.camera" android:required="true" />
<uses-permission android:name="android.permission.CAMERA" android:required="false" />
<uses-feature android:name="android.hardware.camera" android:required="false" />
<uses-feature android:name="android.hardware.camera.front" android:required="false" />
As you can see the CAMERA is once requested by itself and once with required false.
I had similar issue using cordova-plugin-camera-preview & cordova-plugin-qrscanner
What helped me was:
1. Go to plugins/cordova-plugin-qrscanner/plugin.xml
remove entries within
<config-file target="AndroidManifest.xml" parent="/*">
...
</config-file>
run
ionic cordova platform remove android
run
ionic cordova platform add android
This is how my <platform> section look like, from plugin.xml of cordova-plugin-qrscanner
<platform name="android">
<config-file target="res/xml/config.xml" parent="/*">
<feature name="QRScanner">
<param name="android-package" value="com.bitpay.cordova.qrscanner.QRScanner"/>
</feature>
</config-file>
<config-file target="AndroidManifest.xml" parent="/*">
<!-- <uses-permission android:name="android.permission.CAMERA" android:required="false" />
<uses-feature android:name="android.hardware.camera" android:required="false" />
<uses-feature android:name="android.hardware.camera.front" android:required="false" /> -->
</config-file>
<source-file src="src/android/QRScanner.java" target-dir="src/com/bitpay/cordova/qrscanner"/>
<framework src="src/android/qrscanner.gradle" custom="true" type="gradleReference"/>
</platform>
Worked for me, hope it help you as well.