miguelpruivo / flutter_file_picker

File picker plugin for Flutter, compatible with mobile (iOS & Android), Web, Desktop (Mac, Linux, Windows) platforms with Flutter Go support.
MIT License
1.33k stars 658 forks source link

Unable to build the application in release mode. #403

Closed sakinaboriwala closed 4 years ago

sakinaboriwala commented 4 years ago

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.

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.

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. `

miguelpruivo commented 4 years ago

@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.

miguelpruivo commented 4 years ago

@sakina1403 did you managed to fix it?

webtamizhan commented 4 years ago

Hi @miguelpruivo,

me too facing the same issue.,

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

miguelpruivo commented 4 years ago

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.

sakinaboriwala commented 4 years ago

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.

miguelpruivo commented 4 years ago

@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.

webtamizhan commented 4 years ago

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!

miguelpruivo commented 4 years ago

@webtamizhan good! What was the package in question?

webtamizhan commented 4 years ago

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

miguelpruivo commented 4 years ago

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.

sakinaboriwala commented 4 years ago

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

miguelpruivo commented 4 years ago

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