Describe the bug
Using Flutter, and the project does not build anymore after upgrading to 1.22.2.
Issue details
Error Log
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource linking failed
/home/user/projects/soulapp/build/file_picker/intermediates/library_manifest/debug/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 42s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 44.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 12.6s
/home/user/programs/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-2.0.10/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/user/programs/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-2.0.10/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/user/programs/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-2.0.10/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/user/programs/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-2.0.10/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/user/programs/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-2.0.10/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/user/programs/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-2.0.10/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/user/programs/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-2.0.10/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/user/programs/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-2.0.10/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/user/programs/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-2.0.10/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/user/programs/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-2.0.10/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/user/programs/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-2.0.10/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/user/programs/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-2.0.10/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 0s
Exception: The plugin file_picker could not be built due to the issue above.
Flutter Version details
[âś“] Flutter (Channel stable, 1.22.2, on Linux, locale en_US.UTF-8)
• Flutter version 1.22.2 at /home/user/programs/flutter
• Framework revision 84f3d28555 (7 days ago), 2020-10-15 16:26:19 -0700
• Engine revision b8752bbfff
• Dart version 2.10.2
[âś“] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /home/user/programs/sdk
• Platform android-29, build-tools 29.0.2
• ANDROID_HOME = /home/user/programs/sdk
• Java binary at: /home/user/programs/android-studio/jre/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
• All Android licenses accepted.
[âś“] Android Studio (version 3.5)
• Android Studio at /home/user/programs/android-studio
• Flutter plugin version 44.0.1
• Dart plugin version 191.8593
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
[âś“] VS Code (version 1.50.1)
• VS Code at /usr/share/code
• Flutter extension version 3.15.1
[âś“] Connected device (1 available)
• Android SDK built for x86 (mobile) • emulator-5554 • android-x86 • Android 10 (API 29) (emulator)
• No issues found!
Additional context
Used to work before, but stopped after the update. I tried flutter clean as well, did not help.
Hi @callingmybluff, this is one of the most known “non-issue” that randomly happens for some yet to find reason but it’s likely related with cached dependencies or gradle conflicts.
Good news is that cleaning and building should be enough, other than that, check these steps and see if it works for you.
Make sure you’re on the latest plugin version as well.
Also if nothing works, try updating your project’s gradle version to version 4.0.1.
Keep me posted and let me know if it worked for you.
Also if nothing works, try updating your project’s gradle version to version 4.0.1.
Keep me posted and let me know if it worked for you.
I have the same problem, and it was resolved here.
@crdornelles so changing the gradle version was the definitive fix for you?
@miguelpruivo I'm using gradle version 5.6.2 and still having the same issue. I have also tried flutter clean several times and
I'm using flutter version 1.22.2. It was working fine before the update.
@crdornelles so changing the gradle version was the definitive fix for you?
No. It's compile, but does not work in devices. Just on debug.
This issue is in file_picker versions 2.0.9 onwards because file_picker 2.0.8+1 is working fine, but the pubspec.yaml file always fetches the latest version of this package irrespective of the version specified.
@ishvar99 2.0.9 introduces android 11 support hence you’ll need a compatible gradle version as mentioned in the changelog.
Regarding your version question, it’s not the plugin that decides which version is picked but pub get instead. Using carrot ^ operator will always fetch the latest minor versions. If you want specifically the 2.0.8 you must use it without the ^.
file_picker: 2.0.8+1
Thanks.
@miguelpruivo Thanks a lot, changing the version does the trick for me.
I don't think gradle is the problem:
#Fri Jun 23 08:50:38 CEST 2017
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
Also
...
file_picker: ^2.0.10
...
And I still get the same error (updated the main thread to include it):
The built failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetfier to solve the
incompatibility.
Do you know what worked? Downgrading to 2.0.8+1
What if you use gradle 4.0.1 with
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
This will always be hard to handle as this is a coin with two sides: on one, people will be using later android versions and need the plugin to be updated accordingly or else will find build issues, on other, older versions will experience the same if the plugin is updated.
I must prior the first as people will eventually update as well.
I do confirm it worked with that and latest version of file_picker.
For future users:
gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
app/android/build.gradle
dependencies {
classpath 'com.android.tools.build:gradle:4.0.1'
...
And finally file_picker: ^2.0.10 in pubspec.yaml
Thanks for your help!
Even that the ticket is already closed, I would like to bring a discussion here:
Based on the SEMVER definition:
Given a version number MAJOR.MINOR.PATCH, increment the:
- MAJOR version when you make incompatible API changes,
- MINOR version when you add functionality in a backwards compatible manner, and
- PATCH version when you make backwards compatible bug fixes.
Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.
If the change is about including a new functionality that is backwards compatible, it should be a MINOR, not a PATCH.
If you need to change your gradle file to make it continue working, this means that it's a MAJOR change.
That's exactly why the pub get uses the ^ symbol to get only for MINOR changes: you "guarantee" that it will not break any current behavior. Which is totally not the case.
@Cussa that’s correct, and you can see all of those practices that have been rigid followed in my changelog since early days. However, didn’t know that such change wouldn’t be backwards compatible and that such would require explicitly gradle upgrade — that conclusion was only reached with further investigation regarding this issue.
Sorry for any inconvenience.
Most helpful comment
@ishvar99 2.0.9 introduces android 11 support hence you’ll need a compatible gradle version as mentioned in the changelog.
Regarding your version question, it’s not the plugin that decides which version is picked but pub get instead. Using carrot
^operator will always fetch the latest minor versions. If you want specifically the 2.0.8 you must use it without the^.Thanks.