Suraj S Jain
Suraj S Jain

Reputation: 535

Flutter build apk not working on android studio

I am able to run the app on my phone in debug mode. But when I go to generate a .apk by selecting Build>Flutter>Build APK on Android Studio, it shows the following error:

/home/suraj/Softwares-and-tools/flutter/bin/flutter --no-color build apk
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 ':path_provider: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

     /home/suraj/.gradle/caches/transforms-2/files-2.1/a9db740b60dc36334c2480530f66f4a2/core-1.1.0/res/values/values.xml:142:5-173:25: AAPT: error: resource android:attr/fontVariationSettings not found.



     /home/suraj/.gradle/caches/transforms-2/files-2.1/a9db740b60dc36334c2480530f66f4a2/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 29s
Running Gradle task 'assembleRelease'...                           29.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 flutter_plugin_android_lifecycle...
Running Gradle task 'assembleAarRelease'...                         0.7s


FAILURE: Build failed with an exception.

* What went wrong:
Task 'assembleAarRelease' not found in root project 'flutter_plugin_android_lifecycle'.

* Try:
Run gradlew tasks to get a list of available tasks. 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 0s

The plugin flutter_plugin_android_lifecycle could not be built due to the issue above.
Process finished with exit code 1

I also tried running the app on my phone using Run>Flutter run 'main.dart' in release mode but that does not work either. Running in release mode used to work before, but then I'm not sure of what went wrong.

Please Help

Upvotes: 0

Views: 2185

Answers (2)

Ravi Singh Lodhi
Ravi Singh Lodhi

Reputation: 2783

Try using the command:

flutter clean

Then, try to build apk. If that still doesn't work, try Invalidate caches/restart Android Studio.

Upvotes: 1

Abdullah Jirjees
Abdullah Jirjees

Reputation: 71

The error here because your App is big in size so either you reduce the app size or you use "app bundles" to generate the apk, then you will have your app.
Good Luck

Upvotes: 0

Related Questions