1

I'm new to flutter and android development. I have a problem when building apk file with flutter build apk command and it shows error like this

C:\src\flutter_projects\beresin>flutter 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#configu

        e-abi-split
Running Gradle task 'assembleRelease'...


FAILURE: Build failed with an exception.



* What went wrong:

Execution failed for task ':adhara_socket_io:verifyReleaseResources'.

> A failure occurred while executing com.android.build.gradle.internal.tasks.Wo
kers$ActionFacade

   > Android resource linking failed

     C:\Users\BERESIN\.gradle\caches\transforms-2\files-2.1\0a271e99b6771ad4a84
18244d532fb7\core-1.0.0\res\values\values.xml:57:5-88:25: AAPT: error: resource
android:attr/fontVariationSettings not found.



     C:\Users\BERESIN\.gradle\caches\transforms-2\files-2.1\0a271e99b6771ad4a84
18244d532fb7\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 28s
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 adhara_socket_io...
Running Gradle task 'assembleAarRelease'...                         1.8s
√ Built build\app\outputs\repo.
Building plugin flutter_plugin_android_lifecycle...
Running Gradle task 'assembleAarRelease'...                         1.3s


FAILURE: Build failed with an exception.

* Where:
Build file 'C:\src\flutters\.pub-cache\hosted\pub.dartlang.org\flutter_plugin_a
droid_lifecycle-1.0.6\android\build.gradle' line: 22

* What went wrong:
A problem occurred evaluating root project 'flutter_plugin_android_lifecycle'.
> Failed to apply plugin [id 'com.android.library']
   > Minimum supported Gradle version is 5.4.1. Current version is 4.10.2. If u
ing the gradle wrapper, try editing the distributionUrl in C:\src\flutters\.pub
cache\hosted\pub.dartlang.org\flutter_plugin_android_lifecycle-1.0.6\android\gr
dle\wrapper\gradle-wrapper.properties to gradle-5.4.1-all.zip

* 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 plugin flutter_plugin_android_lifecycle could not be built due to the issue
above.

after a long time searching for solution on google, I've found an answer to solve that. I changed the gradle's distributionUrl on flutter_plugin_android_lifecycle package in .pub-cache folder to 5.4.1 as suggested, but it leads to another error like this.

C:\src\flutter_projects\beresin>flutter 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#configur

        e-abi-split
Running Gradle task 'assembleRelease'...


FAILURE: Build failed with an exception.



* What went wrong:

Execution failed for task ':adhara_socket_io:verifyReleaseResources'.

> A failure occurred while executing com.android.build.gradle.internal.tasks.Wor
kers$ActionFacade

   > Android resource linking failed

     C:\Users\BERESIN\.gradle\caches\transforms-2\files-2.1\0a271e99b6771ad4a843
18244d532fb7\core-1.0.0\res\values\values.xml:57:5-88:25: AAPT: error: resource
android:attr/fontVariationSettings not found.



     C:\Users\BERESIN\.gradle\caches\transforms-2\files-2.1\0a271e99b6771ad4a843
18244d532fb7\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 15s
Running Gradle task 'assembleRelease'...                           16.3s
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 adhara_socket_io...
Running Gradle task 'assembleAarRelease'...                         1.6s
√ Built build\app\outputs\repo.
Building plugin flutter_plugin_android_lifecycle...
Running Gradle task 'assembleAarRelease'...                        32.1s
Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reus
ed, use --status for details
> Task :assembleAarRelease UP-TO-DATE
> Task :preBuild UP-TO-DATE
> Task :preReleaseBuild UP-TO-DATE
> Task :compileReleaseAidl NO-SOURCE
> Task :compileReleaseRenderscript NO-SOURCE
> Task :checkReleaseManifest
> Task :generateReleaseBuildConfig
> Task :generateReleaseResValues
> Task :generateReleaseResources
> Task :packageReleaseResources
> Task :mergeReleaseShaders
> Task :compileReleaseShaders
> Task :generateReleaseAssets
> Task :packageReleaseAssets
> Task :packageReleaseRenderscript NO-SOURCE
> Task :parseReleaseLibraryResources
> Task :processReleaseJavaRes NO-SOURCE
> Task :mergeReleaseJniLibFolders
> Task :processReleaseManifest
> Task :prepareLintJarForPublish
> Task :javaPreCompileRelease
> Task :mergeReleaseNativeLibs
> Task :stripReleaseDebugSymbols
> Task :transformNativeLibsWithSyncJniLibsForRelease
> Task :generateReleaseRFile

> Task :compileReleaseJavaWithJavac FAILED
17 actionable tasks: 17 executed

C:\src\flutters\.pub-cache\hosted\pub.dartlang.org\flutter_plugin_android_lifecy
cle-1.0.6\android\src\main\java\io\flutter\embedding\engine\plugins\lifecycle\Fl
utterLifecycleAdapter.java:8: error: package androidx.lifecycle does not exist
import androidx.lifecycle.Lifecycle;
                         ^
C:\src\flutters\.pub-cache\hosted\pub.dartlang.org\flutter_plugin_android_lifecy
cle-1.0.6\android\src\main\java\io\flutter\embedding\engine\plugins\lifecycle\Fl
utterLifecycleAdapter.java:22: error: cannot find symbol
  public static Lifecycle getActivityLifecycle(
                ^
  symbol:   class Lifecycle
  location: class FlutterLifecycleAdapter
2 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':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 31s

The plugin flutter_plugin_android_lifecycle could not be built due to the issue
above.

in my pubspec.yaml file, I only installed 2 new packages in dependencies:

adhara_socket_io: ^0.4.1
google_maps_flutter: ^0.5.25+3

and here's my flutter doctor output

C:\src\flutter_projects\beresin>flutter doctor -v
[√] Flutter (Channel stable, v1.12.13+hotfix.7, on Microsoft Windows [Version
    6.1.7601], locale en-US)
    • Flutter version 1.12.13+hotfix.7 at C:\src\flutters
    • Framework revision 9f5ff2306b (3 months ago), 2020-01-26 22:38:26 -0800
    • Engine revision a67792536c
    • Dart version 2.7.0

[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)

    • Android SDK at C:\Users\BERESIN\AppData\Local\Android\Sdk
    • Android NDK location not configured (optional; useful for native profiling

      support)
    • Platform android-29, build-tools 28.0.3
    • ANDROID_HOME = C:\Users\BERESIN\AppData\Local\Android\Sdk
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build
      1.8.0_212-release-1586-b04)
    • All Android licenses accepted.

[√] Android Studio (version 3.6)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 45.1.1
    • Dart plugin version 192.7761
    • Java version OpenJDK Runtime Environment (build
      1.8.0_212-release-1586-b04)

[√] VS Code (version 1.44.1)
    • VS Code at C:\Users\BERESIN\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.9.1

[√] Connected device (1 available)
    • Mi A2 Lite • 04ab7a9f0405 • android-arm64 • Android 9 (API 28)

• No issues found!

any answer will be appreciated

1 Answer 1

1

So, after some hours... I noticed the adhara_socket_io package causes the problem, then I decided to find other library to handle socket.io connections and tried every single package on pub.dev. there's a package that similar named socket_io_flutter but looks more up-to-date. So I tried to build it but I got the same error.

then I found a question with similar error here Execution failed for task ':flutter_twitter:verifyReleaseResources'

I changed the package's build.gradle file compileSdkVersion to 28, and changed the gradle classpath to classpath 'com.android.tools.build:gradle:3.5.3'

and it works. I learned that every library aren't using the same version of build tool, some of that are left unmaintained.

Correct me if I wrong. If there's better explanation please post it here, so beginners like me can learn more about this.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.