Flutter_file_picker: Unable to build the application in release mode.

Created on 22 Sep 2020  Β·  12Comments  Β·  Source: miguelpruivo/flutter_file_picker

Describe the bug
This plugin works perfectly when running the application in debug mode. But when I try to build the App I get the following error. I have already tried the troubleshooting steps on Wiki, but unfortunately that didn't work for me.If possible please help me out.

Issue details

  1. Android Platform
  2. version 10.0

Error Log
$ 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

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':keyboard_visibility:verifyReleaseResources'.

    A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
    Android resource linking failed
    /home/aviabird/.gradle/caches/transforms-2/files-2.1/3aaf6e5219b7f981ec263df919098c6f/core-1.1.0/res/values/values.xml:142:5-173:25: AAPT: error: resource android:attr/fontVariationSettings not found.

    /home/aviabird/.gradle/caches/transforms-2/files-2.1/3aaf6e5219b7f981ec263df919098c6f/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 27s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 28.8s
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 agora_rtc_engine...
Running Gradle task 'assembleAarRelease'...
Running Gradle task 'assembleAarRelease'... Done 4.5s
βœ“ Built build/app/outputs/repo.
Building plugin amazon_s3_cognito...
Running Gradle task 'assembleAarRelease'...
Running Gradle task 'assembleAarRelease'... Done 23.7s
βœ“ Built build/app/outputs/repo.
Building plugin audioplayers...
Running Gradle task 'assembleAarRelease'...
Running Gradle task 'assembleAarRelease'... Done 3.4s
βœ“ Built build/app/outputs/repo.
Building plugin camera...
Running Gradle task 'assembleAarRelease'...
Running Gradle task 'assembleAarRelease'... Done 3.4s
βœ“ Built build/app/outputs/repo.
Building plugin contacts_service...
Running Gradle task 'assembleAarRelease'...
Running Gradle task 'assembleAarRelease'... Done 19.8s
βœ“ Built build/app/outputs/repo.
Building plugin file_picker...
Running Gradle task 'assembleAarRelease'...
Running Gradle task 'assembleAarRelease'... Done 5.3s

/home/aviabird/.pub-cache/hosted/pub.dartlang.org/file_picker-2.0.0/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:10: error: cannot find symbol
import androidx.lifecycle.DefaultLifecycleObserver;
^
symbol: class DefaultLifecycleObserver
location: package androidx.lifecycle
/home/aviabird/.pub-cache/hosted/pub.dartlang.org/file_picker-2.0.0/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:20: error: cannot find symbol
import io.flutter.embedding.engine.plugins.lifecycle.FlutterLifecycleAdapter;
^
symbol: class FlutterLifecycleAdapter
location: package io.flutter.embedding.engine.plugins.lifecycle
/home/aviabird/.pub-cache/hosted/pub.dartlang.org/file_picker-2.0.0/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:38: error: cannot find symbol
implements Application.ActivityLifecycleCallbacks, DefaultLifecycleObserver {
^
symbol: class DefaultLifecycleObserver
location: class FilePickerPlugin
/home/aviabird/.pub-cache/hosted/pub.dartlang.org/file_picker-2.0.0/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:45: error: method does not override or implement a method from a supertype
@Override
^
/home/aviabird/.pub-cache/hosted/pub.dartlang.org/file_picker-2.0.0/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:49: error: method does not override or implement a method from a supertype
@Override
^
/home/aviabird/.pub-cache/hosted/pub.dartlang.org/file_picker-2.0.0/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:53: error: method does not override or implement a method from a supertype
@Override
^
/home/aviabird/.pub-cache/hosted/pub.dartlang.org/file_picker-2.0.0/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:57: error: method does not override or implement a method from a supertype
@Override
^
/home/aviabird/.pub-cache/hosted/pub.dartlang.org/file_picker-2.0.0/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:61: error: method does not override or implement a method from a supertype
@Override
^
/home/aviabird/.pub-cache/hosted/pub.dartlang.org/file_picker-2.0.0/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:66: error: method does not override or implement a method from a supertype
@Override
^
/home/aviabird/.pub-cache/hosted/pub.dartlang.org/file_picker-2.0.0/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:277: error: cannot find symbol
this.lifecycle = FlutterLifecycleAdapter.getActivityLifecycle(activityBinding);
^
symbol: variable FlutterLifecycleAdapter
location: class FilePickerPlugin
/home/aviabird/.pub-cache/hosted/pub.dartlang.org/file_picker-2.0.0/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:278: error: incompatible types: FilePickerPlugin.LifeCycleObserver cannot be converted to LifecycleObserver
this.lifecycle.addObserver(this.observer);
^
/home/aviabird/.pub-cache/hosted/pub.dartlang.org/file_picker-2.0.0/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:286: error: incompatible types: FilePickerPlugin.LifeCycleObserver cannot be converted to LifecycleObserver
this.lifecycle.removeObserver(this.observer);
^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
12 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 4s

Flutter Version details
Please, post the output of your flutter doctor -v, preferably, while running the issued device/simulator.

`[βœ“] Flutter (Channel stable, 1.20.4, on Linux, locale en_IN)
β€’ Flutter version 1.20.4 at /home/aviabird/development/flutter
β€’ Framework revision fba99f6cf9 (8 days ago), 2020-09-14 15:32:52 -0700
β€’ Engine revision d1bc06f032
β€’ Dart version 2.9.2

[βœ“] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
β€’ Android SDK at /home/aviabird/Android/Sdk
β€’ Platform android-30, build-tools 30.0.2
β€’ ANDROID_HOME = /home/aviabird/Android/Sdk
β€’ ANDROID_SDK_ROOT = /home/aviabird/Android/Sdk
β€’ Java binary at: /home/aviabird/development/android-studio/jre/bin/java
β€’ Java version OpenJDK Runtime Environment (build
1.8.0_242-release-1644-b3-6222593)
β€’ All Android licenses accepted.

[βœ“] Android Studio (version 4.0)
β€’ Android Studio at /home/aviabird/development/android-studio
β€’ Flutter plugin version 49.0.2
β€’ Dart plugin version 193.7547
β€’ Java version OpenJDK Runtime Environment (build
1.8.0_242-release-1644-b3-6222593)

[!] Android Studio
β€’ Android Studio at /opt/android-studio
βœ— Flutter plugin not installed; this adds Flutter specific functionality.
βœ— Dart plugin not installed; this adds Dart specific functionality.
β€’ Java version OpenJDK Runtime Environment (build
1.8.0_242-release-1644-b3-6222593)

[βœ“] VS Code (version 1.42.1)
β€’ VS Code at /usr/share/code
β€’ Flutter extension version 3.8.1

[βœ“] Connected device (1 available)
β€’ ONEPLUS A5010 (mobile) β€’ a0bb4791 β€’ android-arm64 β€’ Android 10 (API 29)

! Doctor found issues in 1 category.
`

new issue

All 12 comments

@sakina1403 by looking at your logs looks like a caching issue on dependencies resolution. You might be able to easily fix it by removing all caches and cleaning.

@sakina1403 did you managed to fix it?

Hi @miguelpruivo,

me too facing the same issue.,

tried flutter clean that's not help to fix. Any other thoughts?

Hi guys, this is an old issue (you can find a lot of similar issues with this on the closed issues) but for some reason, either updating Flutter, migrating to Android X or just cleaning the project/dependencies made it work. Sometimes it even happens with other plugins.

It seems to be something that I'm yet to understand that conflicts specially for projects started a while ago and that eventually evolved overtime through different Flutter versions.

If you manage to replicate this by running the plugin's example app, then it _could_ be an issue with the plugin itself, otherwise, just something directly related with the project.

Let me know if I can help you!

Thank you!

Tip: try updating gradle version of your project.

Hi @miguelpruivo Thank you for getting back to me.

I have tried cache repair, also tried deleting the cache, even reinstalled flutter. tried all dumb and desperate solutions. It used to work before perfectly so I know it's probably not directly related to this plugin, I have used it in many other projects before too, thank you for creating this.

I am looking for some guidance in the right direction, I will try the points that you have mentioned and let you know if anything helped.

@sakina1403 try creating a project from scratch and see if it works, if so, try breaking it down until you understand what could be the issue. I'm also interested to know what might be causing the issue.

Hi guys, this is an old issue (you can find a lot of similar issues with this on the closed issues) but for some reason, either updating Flutter, migrating to Android X or just cleaning the project/dependencies made it work. Sometimes it even happens with other plugins.

It seems to be something that I'm yet to understand that conflicts specially for projects started a while ago and that eventually evolved overtime through different Flutter versions.

If you manage to replicate this by running the plugin's example app, then it _could_ be an issue with the plugin itself, otherwise, just something directly related with the project.

Let me know if I can help you!

Thank you!

Tip: try updating gradle version of your project.

Yes, you are right., It's a problem with another package. After removing that, everything works great. Thanks!

@webtamizhan good! What was the package in question?

Yes, I am using Clipboard dart package which was the actual problem while build release. Removed the package and used flutter Clipboard Class.

Good to know! @sakina1403 please check if there isn't something similar as you might have added a new dependency to your project that could be causing this.

@miguelpruivo Thanks for your help :) This was caused due to keyboard_visibility package and this link helped me.

Glad to know @sakina1403! :) closing as this doesn’t represent an issue then.

Was this page helpful?
0 / 5 - 0 ratings