Flutter error Execution failed for task ':app:processDebugResources' - flutter

Edit: solved, I went to Android Studio, File -> Invalidate Caches/Restart -> Invalidate and Restart, also did flutter clean for the projects. Now both run as expected. Finally.
I created a sample flutter app doing flutter create and then ran with flutter run. This is odd because a week ago I did the same thing and had no problems. And another weird thing, I created an hour ago another sample app and doing flutter run on that works perfectly fine. Same sample app, same code, but one has errors.
I am using Android API 31, no change since last week. I found 5 posts on this site, some were saying to change gradle build version or something but I wasn't sure what it meant exactly. Both sample apps were created in the same night, no edits. I have restarted my computer but no luck.
Here is the output of flutter run:
Running Gradle task 'assembleDebug'...
Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
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
AAPT: error: failed writing to 'C:\Users\Bob\Documents\coding\recipe\build\app\intermediates\runtime_symbol_list\debug\R.txt': The data is invalid. (13).
* 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 19s
Exception: Gradle task assembleDebug failed with exit code 1```
This is the result.

I went to Android Studio, File -> Invalidate Caches/Restart -> Invalidate and Restart, also did flutter clean for the projects. Now both run as expected. Finally.

Related

Could not GET 'https://google.bintray.com/exoplayer/com/google/android/gms/play-services-ads-identifier/maven-metadata.xml' status code 502 from serve

I updated to latest flutter version 2.10.8 but not able to run the app tried so many solutions but not working
The plugins `flurry, flutter_absolute_path` use a deprecated version of the Android embedding.
To avoid unexpected runtime failures, or future build failures, try to see if these plugins support the Android V2 embedding. Otherwise, consider removing them since a future release of Flutter will remove these deprecated APIs.
If you are plugin author, take a look at the docs for migrating the plugin to the V2 embedding: https://flutter.dev/go/android-plugin-migration.
Launching lib/main.dart on Android SDK built for x86 in debug mode...
Running Gradle task 'assembleDebug'...
Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Could not resolve com.google.android.gms:play-services-ads-identifier:16+.
Required by:
project :app > project :flutter_branch_sdk
> Failed to list versions for com.google.android.gms:play-services-ads-identifier.
> Unable to load Maven meta-data from https://google.bintray.com/exoplayer/com/google/android/gms/play-services-ads-identifier/maven-metadata.xml.
> Could not get resource 'https://google.bintray.com/exoplayer/com/google/android/gms/play-services-ads-identifier/maven-metadata.xml'.
> Could not GET 'https://google.bintray.com/exoplayer/com/google/android/gms/play-services-ads-identifier/maven-metadata.xml'. Received status code 502 from server: Bad Gateway
* 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 35s
[!] Gradle threw an error while downloading artifacts from the network. Retrying to download...
Running Gradle task 'assembleDebug'...

Can build app in debug mode but not in release mode Flutter

I am facing following error in console when running in release mode.
C:\Users\Bilal Saeed\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\google_maps_flutter-2.1.0\android\src\main\java\io\flutter\plugins\googlemaps\Googl
eMapsPlugin.java:19: 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\Bilal Saeed\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\google_maps_flutter-2.1.0\android\src\main\java\io\flutter\plugins\googlemaps\Googl
eMapsPlugin.java:92: error: cannot find symbol
lifecycle = FlutterLifecycleAdapter.getActivityLifecycle(binding);
^
symbol: variable FlutterLifecycleAdapter
location: class GoogleMapsPlugin
Note: C:\Users\Bilal Saeed\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\google_maps_flutter-2.1.0\android\src\main\java\io\flutter\plugins\googlemaps
\Convert.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\Users\Bilal Saeed\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\google_maps_flutter-2.1.0\android\src\main\java\io\flutter\plugins\googlemaps
\TileProviderController.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':google_maps_flutter: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
BUILD FAILED in 3m 14s
Running Gradle task 'assembleRelease'... 195.8s
Gradle task assembleRelease failed with exit code 1
What I have tried so far.
Added this line to gradle.properties.
org.gradle.jvmargs=-Xmx4608m
In Android Studio
File > Invalidate Caches/Restart...
Deleted the complete pub_cache folder.
Restarted my Android Studio.
Ran flutter clean, flutter pub get, flutter upgrade.
Ran flutter pub cache repair command also.
But no solution worked.
What worked for me might help some one else.
1. Delete .gradle file present in android folder of project.
2. Update classpath in project level build.gradle file by hovering over it to the latest version.
3. Upgraded distribution URL in gradle-wrapper.properties
4. Clicked File/Invalidate Caches & restart option.
And it started to release my app once again.

Getting the following error wile running Flutter code on Android Studio. (Windows 10)

Getting the following error wile running Flutter code on Android Studio. (Windows 10).
I am using android-studio-2020.3.1.22-windows, Flutter (Channel stable, 2.2.3, on Microsoft Windows [Version 10.0.19043.1165], locale en-IN).
Launching lib\main.dart on Android SDK built for x86 in debug mode...
Running Gradle task 'assembleDebug'...
Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Error: Cannot run with sound null safety, because the following dependencies
don't support null safety:
- package:open_appstore
For solutions, see https://dart.dev/go/unsound-null-safety
FAILURE: Build failed with an exception.
* Where:
Script 'C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1035
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\src\flutter\bin\flutter.bat'' finished with non-zero exit value 1
* 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 11s
Exception: Gradle task assembleDebug failed with exit code 1
Not able to resolve the issue. But it is working, able to see the output when I run the command
flutter run --no-sound-null-safety
from terminal. What seems to be the issue?
The package you used doesn't support null-safety, use null safety packages.
The error is telling you to remove this package open_appstore. It doesn't support null-safety.
Remove it and it should compile.

How do I solve a configuration problem with audioplayers when using the command flutter build apk?

I have just created an app with flutter and I want to get the apks by splitting per abi. When given the command, there is a problem with configuring the plugin audioplayers.
I thought it could be a problem with using androidX?
Here is the error I get:
ยดยดยด
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':audioplayers:verifyReleaseResources'.
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
Android resource linking failed
C:\Users\vanda_qwkpv9x.gradle\caches\transforms-2\files-2.1\7faf2ad74a0b9932e38d86e684646e95\core-1.0.0\res\values\values.xml:57:5-88:25: AAPT: error: resource android:attr/fontVariationSettings not found.
C:\Users\vanda_qwkpv9x.gradle\caches\transforms-2\files-2.1\7faf2ad74a0b9932e38d86e684646e95\core-1.0.0\res\values\values.xml:57:5-88:25: AAPT: error: resource android:attr/ttcIndex not found.
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 56s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 57.7s
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 audioplayers...
Running Gradle task 'assembleAarRelease'...
Running Gradle task 'assembleAarRelease'... Done 2.0s
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring root project 'audioplayers'.
SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
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 1s
The plugin audioplayers could not be built due to the issue above.
Anyone suggestions?
EDIT: With newer Flutter projects (thus newer Gradle versions), android.enableR8 is deprecated!
I'm not an expert with Android nor Flutter, but after many tests it seems that the issue isn't related to a package your recently installed, but with the size of the build! I was getting errors related to audioplayers, assets_audio_player, multiple Firebase packages and so on.
In android\gradle.properties make sure you don't have android.enableR8 set to false.
Here were my issues and steps for those interested:
I was only getting errors similar to yours only on build, not while using hot reload
Errors were related to audioplayers which led me to think it's just a package issue
Replaced it with assets_audio_player, but the problems continued
Changed the order, but this made the error shift to Firebase. I recently added Craslytics and this made me think it's because I used a newer version compared to the 1-2 months old packages. I thought it was the time to upgrade to 8.x, but that didn't make sense either. Never had such issues with any FB service/
Removed the latest sound packages, build was successful, but after adding more random packages (just to increase the size), the errors came back!
R8 announcement:
R8, the new code shrinker from Google, is available in Android studio 3.3 beta
Android developers know that APK size is an important factor in user engagement. Code shrinking helps reduce the size of your APK by getting rid of unused code and resources as well as making your actual code take less space (also known as minification or obfuscation).

Error: downloads_path_provider in flutter

I m using This package to get download path in android which work well.
By using this Package I get /storage/emulated/0/Download which I want.
Problem: When I ran flutter run --release it throws an error.
Launching lib\main.dart on SM J700F in release mode...
Running Gradle task 'assembleRelease'...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':downloads_path_provider:verifyReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource linking failed
C:\Users\Sandeep Sharma\.gradle\caches\transforms-2\files-2.1\56f020e9c27d6a807cc1a74760f6e28d\core-1.0.0\res\values\values.xml:57:5-88:25: AAPT: error: resource android:attr/fontVa
riationSettings not found.
C:\Users\Sandeep Sharma\.gradle\caches\transforms-2\files-2.1\56f020e9c27d6a807cc1a74760f6e28d\core-1.0.0\res\values\values.xml:57:5-88:25: AAPT: error: resource android:attr/ttcInd
ex not found.
* 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 2m 34s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 158.0s (!)
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 cloud_firestore...
The plugin cloud_firestore could not be built due to the issue above.
Running Gradle task 'assembleAarRelease'...
if This can't be solved then suggest being how to get this path /storage/emulated/0/Download or another way around.
Update: I just saw Repo of Downloads_path_provider which says
This plugin has lots of inconsistencies and should no longer be used. Feel free to fork and tweak it.
what should I use to get this path /storage/emulated/0/Download.
Thanks.
instead use the ext_storage plugin:
ExtStorage.getExternalStoragePublicDirectory(ExtStorage.DIRECTORY_DOWNLOADS);
I had the same issue and worked for me.
You have to use the official package provided by the flutter known as path_provide and use the getDownloadsDirectory() method to get the path.