I am facing issue with making APK in flutter from vs code.
Command which I use to make APK.
flutter build apk --split-per-abi
I tried most of solutions like check AndroidX compatibility, Flutter Clean, pub get , pub update etc.
Still I am getting below error in vs code as well android studio,
Please someone help me in this process, where I am missing something.
Running Gradle task 'assembleRelease'...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':speech_recognition: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/company/.gradle/caches/transforms-2/files-2.1/fc785d3673ca7ec4009108d2721750b3/core-1.1.0/res/values/values.xml:142:5-173:25: AAPT: error: resource android:attr/fontStyle not found.
/Users/company/.gradle/caches/transforms-2/files-2.1/fc785d3673ca7ec4009108d2721750b3/core-1.1.0/res/values/values.xml:142:5-173:25: AAPT: error: resource android:attr/font not found.
/Users/company/.gradle/caches/transforms-2/files-2.1/fc785d3673ca7ec4009108d2721750b3/core-1.1.0/res/values/values.xml:142:5-173:25: AAPT: error: resource android:attr/fontWeight not found.
/Users/company/.gradle/caches/transforms-2/files-2.1/fc785d3673ca7ec4009108d2721750b3/core-1.1.0/res/values/values.xml:142:5-173:25: AAPT: error: resource android:attr/fontVariationSettings not found.
/Users/company/.gradle/caches/transforms-2/files-2.1/fc785d3673ca7ec4009108d2721750b3/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 2m 49s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 170.8s (!)
The built failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetfier to solve the incompatibility.
✏️ Creating `android/settings_aar.gradle`...
[!] Flutter tried to create the file `android/settings_aar.gradle`, but failed.
To manually update `settings.gradle`, follow these steps:
1. Copy `settings.gradle` as `settings_aar.gradle`
2. Remove the following code from `settings_aar.gradle`:
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
def properties = new Properties()
assert localPropertiesFile.exists()
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
Please create the file and run this command again.
For Debug APK :
flutter build apk
For Release APK :
flutter build apk --release
For App Bundle :
flutter build appbundle
Related
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':screen:verifyReleaseResources'.
java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
/Users/mitto/Projects/Solutech/apps/solutech-sat/build/screen/intermediates/res/merged/release/values/values.xml:168: error: resource android:attr/fontStyle not found.
/Users/mitto/Projects/Solutech/apps/solutech-sat/build/screen/intermediates/res/merged/release/values/values.xml:169: error: resource android:attr/font not found.
/Users/mitto/Projects/Solutech/apps/solutech-sat/build/screen/intermediates/res/merged/release/values/values.xml:170: error: resource android:attr/fontWeight not found.
/Users/mitto/Projects/Solutech/apps/solutech-sat/build/screen/intermediates/res/merged/release/values/values.xml:171: error: resource android:attr/fontVariationSettings not found.
/Users/mitto/Projects/Solutech/apps/solutech-sat/build/screen/intermediates/res/merged/release/values/values.xml:172: error: resource android:attr/ttcIndex not found.
error: failed linking references.
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 7m 3s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 425.8s (!)
Gradle task assembleRelease failed with exit code 1
mitto#Titos-MacBook-Pro solutech-sat % flutter build apk --release
You are building a fat APK that includes binaries for android-arm, android-arm64, android-x64.
If you are deploying the app to the Play Store, it's recommended to use app bundles or split the APK to reduce the APK size.
To generate an app bundle, run:
flutter build appbundle --target-platform android-arm,android-arm64,android-x64
Learn more on: https://developer.android.com/guide/app-bundle
To split the APKs per ABI, run:
flutter build apk --target-platform android-arm,android-arm64,android-x64 --split-per-abi
Learn more on: https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split
Running Gradle task 'assembleRelease'... Removed unused resources: Binary resource data reduced from 1194KB to 1134KB: Removed 5%
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':screen:verifyReleaseResources'.
java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
/Users/mitto/Projects/Solutech/apps/solutech-sat/build/screen/intermediates/res/merged/release/values/values.xml:168: error: resource android:attr/fontStyle not found.
/Users/mitto/Projects/Solutech/apps/solutech-sat/build/screen/intermediates/res/merged/release/values/values.xml:169: error: resource android:attr/font not found.
/Users/mitto/Projec
You need to generate bundles instead of apk.
flutter build appbundle
check this doc : https://docs.flutter.dev/deployment/android#build-an-app-bundle
C:\src\flutter\bin\flutter.bat – no-color build apk
Waiting for another flutter command to release the startup lock...
You are building a fat APK that includes binaries for android-arm, android-ARM64, android-x64.
If you are deploying the app to the Play Store, it's recommended to use app bundles or split the APK to reduce the APK size.
To generate an app bundle, run:
flutter build appbundle – target-platform android-arm, android-ARM64, android-x64
Learn more on: https://developer.android.com/guide/app-bundle
To split the APKs per ABI, run:
flutter build apk – target-platform android-arm, android-ARM64, android-x64 – split-per-abi
Learn more on: https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split
Running Gradle task 'assembleRelease'...
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app: mergeReleaseResources'.
Multiple task action failures occurred:
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource compilation failed
C:\Users\mysel\AndroidStudioProjects\Chatting-app-with-firebase\android\app\src\main\res\mipmap-hdpi\ic_launcher.png: AAPT: error: failed to read PNG signature: file does not start with PNG signature.
C:\Users\mysel\AndroidStudioProjects\Chatting-app-with-firebase\android\app\src\main\res\mipmap-hdpi\ic_launcher.png: AAPT: error: file failed to compile.
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource compilation failed
C:\Users\mysel\AndroidStudioProjects\Chatting-app-with-Firebase\Android\app\src\main\res\mipmap-xxhdpi\ic_launcher.png: AAPT: error: failed to read PNG signature: file does not start with PNG signature.
C:\Users\mysel\AndroidStudioProjects\Chatting-app-with-firebase\android\app\src\main\res\mipmap-xxhdpi\ic_launcher.png: AAPT: error: file failed to compile.
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource compilation failed
C:\Users\mysel\AndroidStudioProjects\Chatting-app-with-firebase\android\app\src\main\res\mipmap-xxxhdpi\ic_launcher.png: AAPT: error: failed to read PNG signature: file does not start with PNG signature.
C:\Users\mysel\AndroidStudioProjects\Chatting-app-with-firebase\android\app\src\main\res\mipmap-xxxhdpi\ic_launcher.png: AAPT: error: file failed to compile.
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource compilation failed
C:\Users\mysel\AndroidStudioProjects\Chatting-app-with-Firebase\Android\app\src\main\res\mipmap-mdpi\ic_launcher.png: AAPT: error: failed to read PNG signature: file does not start with PNG signature.
C:\Users\mysel\AndroidStudioProjects\Chatting-app-with-firebase\android\app\src\main\res\mipmap-mdpi\ic_launcher.png: AAPT: error: file failed to compile.
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 16s
Running Gradle task 'assembleRelease'... 80.3s
The built failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetfier to solve the incompatibility.
✏️ Creating android\settings_aar.gradle...
[!] Flutter tried to create the file android\settings_aar.gradle, but failed.
To manually update settings.gradle, follow these steps:
Copy settings.gradle as settings_aar.gradle
Remove the following code from settings_aar.gradle:
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
def properties = new Properties()
assert localPropertiesFile.exists()
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
Please create the file and run this command again.
Process finished with exit code 1
Tried changing daemon in build.properties file, tried Invalidate cache/restart but nothing seems to work
I'm using Torch plugin with Camera plugin for back flash. It works fine with iOS, but not with Android. When I tried to Create release build for Android it gives me errors.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':torch:verifyReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource linking failed
/Users/apple/.gradle/caches/transforms-2/files-2.1/790c8a51d6267afe36c98b9a0bc454cb/core-1.0.0/res/values/values.xml:57:5-88:25: AAPT: error: resource android:attr/fontVariationSettings not found.
/Users/apple/.gradle/caches/transforms-2/files-2.1/790c8a51d6267afe36c98b9a0bc454cb/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 2m 13s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 134.5s (!)
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 app_review...
Running Gradle task 'assembleAarRelease'...
Running Gradle task 'assembleAarRelease'... Done 0.0s
Sending crash report to Google.
Crash report sent (report ID: 97f69452e4767517)
Oops; flutter has exited unexpectedly.
I'm trying to set up firebase for both android and ios. I've tried using different versions in pubspec.yaml, but i'm still getting errors like this. Thanks for the help in advance.
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\13363\.gradle\caches\transforms-2\files-2.1\354fc33358371181aa1b0a8e262a9145\jetified-play-services-auth-16.0.1\res\drawable-watch-v20\common_google_signin_btn_text_dark_normal.xml:9: AAPT: error: resource drawable/googleg_standard_color_18 (aka com.example.catbox:drawable/googleg_standard_color_18) not found.
C:\Users\13363\.gradle\caches\transforms-2\files-2.1\354fc33358371181aa1b0a8e262a9145\jetified-play-services-auth-16.0.1\res\drawable-watch-v20\common_google_signin_btn_text_disabled.xml:16: AAPT: error: resource drawable/googleg_disabled_color_18 (aka com.example.catbox:drawable/googleg_disabled_color_18) not found.
C:\Users\13363\.gradle\caches\transforms-2\files-2.1\354fc33358371181aa1b0a8e262a9145\jetified-play-services-auth-16.0.1\res\drawable-watch-v20\common_google_signin_btn_text_light_normal.xml:9: AAPT: error: resource drawable/googleg_standard_color_18 (aka com.example.catbox:drawable/googleg_standard_color_18) 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 21s
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...
Running Gradle task 'assembleAarRelease'...
Finished with error: The plugin cloud_firestore could not be built due to the issue above.
Migrating to AndroidX includes new attributes fontVariationSettings and ttcIndex. I've tried migrating a project (a Flutter plugin), but get the error below when doing the gradle build. Many users have had the same gradle error as me, but unlike them, I've already
upgraded my compileSdkVersion to 28 in my build.gradle
added android.useAndroidX=true and android.enableJetifier=true in gradle.properties
reset the gradle cache through Android Studio (Invalidate Caches/Restart)
My console output:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugResources'.
> Android resource linking failed
/Users/davidmccoy/.gradle/caches/transforms-1/files-1.1/core-1.0.0-beta01.aar/f004b9e22a129b2d333d02089203fb0d/res/values/values.xml:89:5-125:25: AAPT: error: resource android:attr/fontVariationSettings not found.
/Users/davidmccoy/.gradle/caches/transforms-1/files-1.1/core-1.0.0-beta01.aar/f004b9e22a129b2d333d02089203fb0d/res/values/values.xml:89:5-125:25: AAPT: error: resource android:attr/ttcIndex not found.
error: failed linking references.
* 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 1s
*******************************************************************************************
The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.
See https://flutter.dev/docs/development/packages-and-plugins/androidx-compatibility for more information on the problem and how to fix it.
*******************************************************************************************
Gradle task assembleDebug failed with exit code 1
Turns out I had another Android project that I had included in my Flutter application that had not yet been upgraded to AndroidX. So I upgraded that project, and the problem was solved.