Flutter build error - Android resource linking failed. even set compileSdkVersion 28 - flutter

Please help, I'm facing problem when building realease apk file as below. I have tried searching but found only to set compileSdkVersion 28 in build.gradle file, but unlucky for my case. Any body has suggestion?
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':flutter_appavailability:verifyReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> 1 exception was raised by workers:
com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
/Users/adsavin/.gradle/caches/transforms-2/files-2.1/855694052351881cfd5b05bbd4ccb2f3/core-1.0.1/res/values/values.xml:57:5-88:25: AAPT: error: resource android:attr/fontVariationSettings not found.
/Users/adsavin/.gradle/caches/transforms-2/files-2.1/855694052351881cfd5b05bbd4ccb2f3/core-1.0.1/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 1m 58s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 122.4s (!)
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 connectivity...
Running Gradle task 'assembleAarRelease'...
Running Gradle task 'assembleAarRelease'... Done 4.6s
✓ Built build/app/outputs/repo.
Building plugin connectivity_macos...
Running Gradle task 'assembleAarRelease'...
Running Gradle task 'assembleAarRelease'... Done 5.3s
✓ Built build/app/outputs/repo.
Building plugin firebase_auth...
Running Gradle task 'assembleAarRelease'...
Running Gradle task 'assembleAarRelease'... Done 4.8s
✓ Built build/app/outputs/repo.
Building plugin firebase_auth_web...
Running Gradle task 'assembleAarRelease'...
Running Gradle task 'assembleAarRelease'... Done 4.5s
✓ Built build/app/outputs/repo.
Building plugin firebase_core...
The plugin firebase_core could not be built due to the issue above.
Running Gradle task 'assembleAarRelease'... ```

Please migrate your app in android x and if it's already done then please
check your plugin version compatible with android x
https://flutter.dev/docs/development/androidx-migration

Related

Build works on local but fails on codemagic | Execution failed for task ':app:stripDebugDebugSymbols'

I'm trying to implement a continuous deployment system to build my app and deploy to Google Play using codemagic. Doing a build works fine locally but fails remotely on codemagic.
Error summary:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:stripDebugDebugSymbols'.
> 1 exception was raised by workers:
org.gradle.process.internal.ExecException: A problem occurred starting process 'command '/usr/local/share/android-sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-strip''
Complete log:
== Building for Android ==
> flutter build appbundle --debug
Running "flutter pub get" in My_Project... 1,655ms
💪 Building with sound null safety 💪
Running Gradle task 'bundleDebug'...
[flutter_background_geolocation] Purging debug resources in release build
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /Users/builder/programs/flutter_2_5_3/.pub-cache/hosted/pub.dartlang.org/geocoding-2.0.1/android/src/main/java/com/baseflow/geocoding/GeocodingPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:stripDebugDebugSymbols'.
> 1 exception was raised by workers:
org.gradle.process.internal.ExecException: A problem occurred starting process 'command '/usr/local/share/android-sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-strip''
* 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 19s
Running Gradle task 'bundleDebug'... 141.1s
Gradle task bundleDebug failed with exit code 1
Build failed :|
Failed to build for Android
Current configuration on codemagic:
Flutter channel: stable
Mode: debug
Build for: Android
to fix this you need to upgrade Gradle version in android/gradle/wrapper/gradle-wrapper.properties to 6.7.1 or commit gradle wrapper to your repository if you don't have this file.
Additional to that you also might need to upgrade Android Gradle plugin in andriod/build.gradle
- classpath 'com.android.tools.build:gradle:3.5.4'
+ classpath 'com.android.tools.build:gradle:4.2.0'
WITHOUT GRADLE UPGRADE
if for some reasons you can't upgrade Gradle version you can freeze previous NDK version.
For that you can specify ndkVersion "22.1.7171670" in your build.gradle and make sure you use Java 1.8 since there is an issue with using latest Java versions.
In Codemagic you can specify Java version in environment section in your codemagic.yaml like this
workflows:
workflow-name:
environment:
ndk: r22b
java: 1.8

Failed to build apk for flutter apps

I am trying to build my apps in android.. when I run in debug mode, it seems ok and runs well, but when I try to flutter build apk there are error like this
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 55.6s
The build failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using
Jetifier to solve the incompatibility.
Building plugin camera...
Running Gradle task 'assembleAarRelease'...
Running Gradle task 'assembleAarRelease'... Done 1,867ms
✓ Built build/app/outputs/repo.
Building plugin disk_space...
Running Gradle task 'assembleAarRelease'...
Running Gradle task 'assembleAarRelease'... Done 2,303ms
✓ Built build/app/outputs/repo.
Building plugin firebase_ml_vision...
Running Gradle task 'assembleAarRelease'...
Running Gradle task 'assembleAarRelease'... Done 1,132ms
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
-----------
* What went wrong:
Could not resolve all files for configuration ':releaseCompileClasspath'.
> Could not resolve android.arch.lifecycle:runtime:1.1.1.
Required by:
project :
> Cannot find a version of 'android.arch.lifecycle:runtime' that satisfies the version constraints:
Dependency path 'io.flutter.plugins.firebasemlvision:firebase_ml_vision:1.0' --> 'android.arch.lifecycle:runtime:1.1.1'
is there something that I should add for configuration?

Error in making release apk or run the app in release mode

FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':thumbnails:verifyReleaseResources'.
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
1 exception was raised by workers:
com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
C:\Users\asus.gradle\caches\transforms-2\files-2.1\fdd1d924d9d4aeba2785fceb0b790aec\core-1.1.0\res\values\values.xml:142:5-173:25: AAPT: error: resource android:attr/fontVariationSettings not found.
C:\Users\asus\.gradle\caches\transforms-2\files-2.1\fdd1d924d9d4aeba2785fceb0b790aec\core-1.1.0\res\values\values.xml:142:5-173: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 44s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 46.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'...
It is possible that the "thumbnails" package which you are using was not upgraded to AndroidX, while others are.
I recommend following this answer. This is taken from the issues page of this package.
https://github.com/asapJ/Flutter_Thumbnails/issues/8

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.

Flutter - Execution failed for task ':unique_identifier:verifyReleaseResources'

I get this when I do 'flutter run --release'
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':unique_identifier:verifyReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource linking failed
C:\Users\USER\.gradle\caches\transforms-2\files-2.1\df6cf23cc51da578d8b158de17d0c9cb\core-1.0.0\res\values\values.xml:57:5-88:25: AAPT: error: resource android:attr/fontVariationSettings not found.
C:\Users\USER\.gradle\caches\transforms-2\files-2.1\df6cf23cc51da578d8b158de17d0c9cb\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 19s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 19.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 camera...
Running Gradle task 'assembleAarRelease'...
Running Gradle task 'assembleAarRelease'... Done 1.7s
√ Built build\app\outputs\repo.
Building plugin cloud_firestore...
The plugin cloud_firestore could not be built due to the issue above.
When I do flutter run --debug I don't get this issue,
Any idea how to solve it?
I tried down grading cloud_firestore to 0.12.11 and 0.12.10+2 but it didn't help
I tried:
minSdkVersion 29
targetSdkVersion 29
it didn't help
I checked the file: C:\Users\USER\.gradle\caches\transforms-2\files-2.1\df6cf23cc51da578d8b158de17d0c9cb\core-1.0.0\res\values\values.xml and indeed the 2 mentioned items are missing, I try to add them manually but it is deleted when I run flutter run --release
Solution:
After I did flutter run --release --verbose, I realize that unique_identifier was refering to the package unique_identifier that I have in my YAML file but not actually uses in the project.
So I removed unique_identifier and the build passed.
The message about cloud_firestore confused me, and is not really related.