The built failed likely due to AndroidX incompatibilities in a plugin,for plugin Workmanager in Flutter - flutter

I wanted to run a background process in flutter.I used the code in https://pub.dev/packages/workmanager#-example-tab- and added the dependency required in pubspec.yaml file.
But I am getting "The built failed likely due to AndroidX incompatibilities in a plugin".The detail of the which I am sharing in the screenshot below(2 images):
I tried checking my gradle.properties file as suggested in some posts.But useAndroidX,enableJetifier were set "true".The details of gradle.properties is below:
android.useAndroidX=true
android.enableJetifier=true
This is my flutter doctor -v details:
The flutter build --verbose

I recently got this error, while using cloud_firestore plugin.
Since, Starting from Flutter v1.12.13, new projects created with flutter use AndroidX by default, therefore that didn't solve my problem.
After several times doing Pub get with any versions of plugin,
I figured all you have to do is:
• Go to android/app/build.gradle of your Flutter project, and
• Set minSdkVersion 21
Now, on running flutter build apk, the error should go away.

you just need to migrate to AndroidX maybe
https://flutter.dev/docs/development/androidx-migration
refer this link, please

Related

The argument type 'PointerEvent' can't be assigned to the parameter type 'PointerDownEvent'

Recently I've updated to flutter 2.5 and the newest androids studio, and tried to compile my flutter project to android device. Android studio throws me the error below. If I write flutter run in a terminal there is no problem compiling to android device.
Guess this must be related to android studio. I tried downgrade to an earlier android studio version, but the problem persists.
I'm not sure what plugin this is, it doesn't seem like any I use in my project.
Edit: If I downgrade flutter from 2.5 to 2.0 my project compiles again. So the problem is within flutter 2.5
Launching lib/main.dart on Android SDK built for x86 in debug mode...
Running Gradle task 'assembleDebug'...
../plugins/flutter/.pub-cache/hosted/pub.dartlang.org/photo_view-0.11.1/lib/src/core/photo_view_gesture_detector.dart:106:29: Error: The argument type 'PointerEvent' can't be assigned to the parameter type 'PointerDownEvent'.
- 'PointerEvent' is from 'package:flutter/src/gestures/events.dart' ('../plugins/flutter/packages/flutter/lib/src/gestures/events.dart').
- 'PointerDownEvent' is from 'package:flutter/src/gestures/events.dart' ('../plugins/flutter/packages/flutter/lib/src/gestures/events.dart').
super.addAllowedPointer(event);
There was an API change in version 2.5 of flutter and several packages must update accordingly.
Your logs show that the exact package which contains the error is photo_view.
Luckily enough the package has just been updated to fix this, so just update its version in your pubspec.yaml:
photo_view: ^0.12.0
UPDATE
If you don't have the package directly in your pubspec
You have two options
1 It's probably a transient dependency, you can run flutter pub deps
to list the installed packages and its dependencies and try to update the one that uses photo_view (if it does have an update)
2 Add a dependency override to your pubspec.yaml, this will effectively override the version of the package being used
dependency_overrides:
photo_view: ^0.12.0
Add this just before your dev_dependencies
from your debug code
('../plugins/flutter/packages/flutter/lib/src/gestures/events.dart').
you open the file or click if there are link clickable
Search for this:
void addAllowedPointer(PointerEvent event) {
and replace with this:
void addAllowedPointer(PointerDownEvent event) {
Here is the reference link
https://flutter.dev/docs/release/breaking-changes/gesture-recognizer-add-allowed-pointer
This problem arises due to the GestureRecognizer Cleanup -
Here is the documentation if you are intrested in the migration code
But in case you just want to build your flutter app without any migrations following are couple of solutions to that problem
You can update photo_view dependency in your pubspec.yaml file to
photo_view :^0.12.0
If you do not want to update your dependency due to any reason you can opt for this temporary fix . In the pubspec.yaml file add the following custom photo_view with better gesture recognition in dependency_overrides.
dependency_overrides:
photo_view:
git: git://github.com/robertodoering/photo_view.git

Flutter stable version 1.20.1 build failed issue

I update the Flutter latest stable version 1.20.1 when I click the run button on an already existing project it shows me this error:
Could not resolve the package 'characters' in 'package: characters/characters.dart'.
But when I create a new project and try to run it works.
Following the Github issue below, it is a common issue after upgrading to a different Flutter Version
Could not resolve package characters
In my case, I resolved the issue with flutter clean.

Flutter Gradle build with error exception

i just setup my android studio and vs code and flutter SDK installed but any time i try running the project i get this Gradle error, i cant figure out what the problem is please help me out.
After running the flutter doctor everything seems to be okay.
the problem might be caused by many factors so lets try some solutions
after each one rebuild your app if the error message changed or the problem solved please keep us informed
run these commands one by one
flutter channel stable
flutter upgrade --force
flutter pub cache repair
cd your app folder
flutter clean
edit app/build.gradle in your host app such as it includes the local repo
like in here
repositories {
maven {
url 'https://storage.googleapis.com/download.flutter.io'
}
}
use VPN and rebuild your app

Flutter build release AndroidX incompatibilities

When I run the project on emulator or a real device it runs perfect.
but when I try to build a release with
flutter build apk --release
or
flutter build appbundle
it gives me this error
*******************************************************************************************
The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.
See URL for more information on the problem and how to fix it.
*******************************************************************************************
Gradle task assembleRelease failed with exit code 1
although I tried this
I had a similar error and put the following lines in gradle.properties file in /android folder of my project.
android.enableJetifier=true
android.useAndroidX=true
But according to comments section, main problem is not the AndroidX warning but a problem in assembleBuild task of Gradle regarding a library.
Looks like the question is not about AndroidX.

Error after add plugin simple_permissions on pubspec.yaml

I tried using the simple_permissions plugin and then I got an error to migrate to androidX even though I had migrated to androidX and after I deleted android.Jetifier at gradle.property I didn't get any more errors and the plugin was successfully used. Why did it happen? Will my project get a problem in the future? Thanks!
Make sure that all your packages in the pubspec.yaml are of the latest version. Then open the android project of your flutter app with android studio, select Refactor->Migrate to Androidx. Wait until android studio finishes migrating your project, rebuild your project. Hope it helps!