Hi.
To validate that the error only happens because of file picker and not plugin conflict I made an empty flutter project and added the plugin as the only dependency.
dependencies:
file_picker: 2.0.11
flutter:
sdk: flutter
Flutter doctor result:
[鈭歖 Flutter (Channel stable, 1.22.2, on Microsoft Windows [Version 10.0.19041.572], locale en-US)
[鈭歖 Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[!] Android Studio (version 4.1.0)
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
[鈭歖 VS Code (version 1.50.1)
[鈭歖 Connected device (1 available)
! Doctor found issues in 1 category.
Sorry, I know that this was discussed before in another thread and I've tried all the solutions there but non has worked so shamefully I had to create another issue regarding that.
Things I've tried:
flutter cleanflutter pub cache repaircompileSdkVersion & targetSdkVersion from 29 to 28gradle-5.6.2-all.zip to gradle-6.6.1-all.zip.gradle folder from user home to avoid cacheI'm able to build and test using emulators and a real phone, but it fails upon running flutter build apk --split-per-abi command with this log:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource linking failed
C:\Users\alier\AndroidStudioProjects\flutter_app2\build\file_picker\intermediates\library_manifest\release\AndroidManifest.xml:9:5-15:15: AAPT: error: unexpected element <queries> found in <manifest>.
* 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 5s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 5.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 file_picker...
Running Gradle task 'assembleAarRelease'...
Running Gradle task 'assembleAarRelease'... Done 1.4s
C:\flutter\.pub-cache\hosted\pub.dartlang.org\file_picker-2.0.11\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
C:\flutter\.pub-cache\hosted\pub.dartlang.org\file_picker-2.0.11\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
C:\flutter\.pub-cache\hosted\pub.dartlang.org\file_picker-2.0.11\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
C:\flutter\.pub-cache\hosted\pub.dartlang.org\file_picker-2.0.11\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
^
C:\flutter\.pub-cache\hosted\pub.dartlang.org\file_picker-2.0.11\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
^
C:\flutter\.pub-cache\hosted\pub.dartlang.org\file_picker-2.0.11\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
^
C:\flutter\.pub-cache\hosted\pub.dartlang.org\file_picker-2.0.11\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
^
C:\flutter\.pub-cache\hosted\pub.dartlang.org\file_picker-2.0.11\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
^
C:\flutter\.pub-cache\hosted\pub.dartlang.org\file_picker-2.0.11\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
^
C:\flutter\.pub-cache\hosted\pub.dartlang.org\file_picker-2.0.11\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
C:\flutter\.pub-cache\hosted\pub.dartlang.org\file_picker-2.0.11\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);
^
C:\flutter\.pub-cache\hosted\pub.dartlang.org\file_picker-2.0.11\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 1s
The plugin file_picker could not be built due to the issue above.
Here's the output for flutter build apk --split-per-abi -v:
verbose flutter build apk.txt
Hi, if you search on this repo for issues regarding DefaultLifecycleObserver you鈥檒l find a lot of information. This isn鈥檛 the only plugin where the issue happens but mostly every other plugin that implements it sometimes has this build conflict issues related with it. I鈥檓 yet to find what鈥檚 the culprit as no one seems to know, so far.
I suggest you to make sure that your project is fully compatible with Android X (this is required) and try cleaning, updating and removing caches. Check other鈥檚 solutions as well as what I鈥檝e posted regarding this on the troubleshooting page.
Sorry for any inconvenience.
@alidhkh I have the same issue.Is it resolved? How is it resolved?
@miguelpruivo Hey, thanks for your hard work helping users 馃檹.
I tried most of the solutions in those older issues but unfortunately non worked.
I am using Android Studio 4.1 and upon creating a new Flutter project I always make sure to have "Use androidx.* artifacts" marked on. Also I've tried opening android directory and migrating to androidx using Android Studio which didn't have any changes because the project was already androidX I guess.
@debugksir I haven't been able to resolve it yet :(
I'm going to remove everything related to Android and then start fresh, I hope this is something to do with my current SDKs. I'll update this thread about the result.
How to fix, I also have the same issue.
@alidhkh hum not really! There are projects where AS tells you there isn鈥檛 nothing to do and they aren鈥檛 actually fully migrated to Android X.
Check here the manual steps and see if there鈥檚 anything missing.
@alidhkh hum not really! There are projects where AS tells you there isn鈥檛 nothing to do and they aren鈥檛 actually fully migrated to Android X.
Check here the manual steps and see if there鈥檚 anything missing.
@alidhkh yes, follow this step, fixed the error. @miguelpruivo thanks very much
I tried uninstalling and starting a fresh installation but didn't help at all :( feeling desperate...
@miguelpruivo Every project I start with Android Studio 4.1 has these lines in gradle.properties:
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
android.enableR8=true
This was the third time that I went through the manual for migrating to AndroidX. Did everything it has written. I don't know what to do to debug this
@alidhkh what gradle version are you using. Check your build.gradle and your gradle.properties file.
@miguelpruivo Using Android Studio 4.1 or manually using flutter create command both the same:
android/build.gradle:
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
gradle-wrapper.properties:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
@alidhkh try gradle 4.0.1 and replace your properties with:
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
@miguelpruivo Thank you, now it works with targetSdkVersion 29.
But I can't use flutter build apk --split-per-abi which I think is not related to FilePicker. I contributed to this thread about the case:
https://github.com/flutter/flutter/issues/64510#issuecomment-719651812
Thanks for your wonderful time and patience 馃檹.
This working:
flutter build apk --target-platform android-arm,android-arm64,android-x64
But this not working:
flutter build apk --target-platform android-arm,android-arm64,android-x64 --split-per-abi
I tried everything here but didn't work so I opened the android folder in Android Studio and eventually it updated the gradle itself I had to wait for some minutes for it to complete the task. Everything works fine now.
Most helpful comment
@alidhkh try gradle 4.0.1 and replace your properties with: