Q:

Flutter plugins not working under Android

In my Flutter App, I make usage of many plugins.
However, there are some of them that simply won't work under Android (i.e. under iOS they work perfectly fine).
Inside pubspec.yaml File I have the following list of packages that I intend to use in my Flutter app.
The ones commented-out do not work under Android !
dependencies:
  flutter:
    sdk: flutter
  shared_preferences: ^0.5.2+1
  sqflite: ^1.1.5
  intl: ^0.15.8
  tuple: ^1.0.2
  material_design_icons_flutter: ^3.2.3695
  launch_review: ^2.0.0
  fit_image: ^0.1.2
  datetime_picker_formfield: ^0.1.8
  flutter_screenutil: ^0.5.2
  path_provider: ^1.1.0
  # image_picker: ^0.6.0+8
  # url_launcher: ^5.0.2
  # permission_handler: ^3.1.0
  # flutter_downloader: ^1.1.7
  large_file_copy: ^0.0.1
  flutter_localizations:
    sdk: flutter
  cupertino_icons: ^0.1.2

I work with Android SDK 28
My Flutter project, I create with:
flutter create --org ch.myorg -i swift -a kotlin <my_app_name>

How can I get these packages to work under Android ????
  image_picker: ^0.6.0+8
  url_launcher: ^5.0.2
  permission_handler: ^3.1.0
  flutter_downloader: ^1.1.7

I did the following trials:

typed flutter clean
typed flutter packages get
opened Android Studio to see if it cleans the bugs - but no chance
migrated to AndroidX (but this is the biggest mess you can imagine since corrupting the other packages that worked fine before the migration)
I created a completely new Flutter project and added no code whatsoever (i.e. work with the hello-world app) and keep adding packages to the pubspec.yaml file to see which packages crash the Android version. Then for the first one crashing, I try to step back versions in order to find any package-version that might not crash. But this is like finding a needle in a haystack... No chance either...
I went to get the package-creator's GitHub project and tried their example app (i.e. each package has an example) - but the same issue: Android does not work !
I created a completely new Flutter app and took the main.dart content of a package-provider-example main.dart code (in order to have all the android\local.properties etc. in a correct state given by the flutter create) and then I added the pubspec.yaml content form the package also into the new flutter app in order to get the necessary dependency. But same, thing: Android does not work !! (iOS works always..)
I uninstalled Android Studio and re-installed it. I uninstalled Flutter and Dart and re-installed it. No effect...

I am more than desperate to get this to work since I lost 6 days so far trying to get these Flutter packages to run under Android... :(
Any help highly appreciated.
Here is my flutter doctor -v output:
flutter doctor -v
[✓] Flutter (Channel stable, v1.5.4-hotfix.2, on Mac OS X 10.14.5 18F132, locale
    en-CH)
    • Flutter version 1.5.4-hotfix.2 at /Users/user/Documents/flutter
    • Framework revision 7a4c33425d (4 weeks ago), 2019-04-29 11:05:24 -0700
    • Engine revision 52c7a1e849
    • Dart version 2.3.0 (build 2.3.0-dev.0.5 a1668566e5)

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at /Users/user/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling
      support)
    • Platform android-28, build-tools 28.0.3
    • Java binary at: /Applications/Android
      Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      1.8.0_152-release-1343-b01)
    • All Android licenses accepted.

[✓] iOS toolchain - develop for iOS devices (Xcode 10.2.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 10.2.1, Build version 10E1001
    • ios-deploy 1.9.4
    • CocoaPods version 1.6.1

[✓] Android Studio (version 3.4)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 35.3.1
    • Dart plugin version 183.6270
    • Java version OpenJDK Runtime Environment (build
      1.8.0_152-release-1343-b01)

[✓] VS Code (version 1.34.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.0.2

[✓] Connected device (1 available)
    • Android SDK built for x86 • emulator-5554 • android-x86 • Android 9 (API
      28) (emulator)

• No issues found!

Here is an example of getting one single package to work under Android - my trial is with file_downloader (Link to package definition):
Below you find the cryptic error log when I try with the file_downloader package:
Step 1 : create a completely new Flutter project with flutter create --org com.myorg -i swift -a kotlin testy
Step 2 : fill in the package-dependencies inside the pubsep.yaml file (i.e. taken from the package-example). Here are the dependencies for this package example:
dependencies:
  flutter:
    sdk: flutter
  path_provider: ^0.4.0
  permission_handler: ^3.0.0
  flutter_downloader: ^1.1.7
  cupertino_icons: ^0.1.2

Step 3 : Keep the main.dart as the default "hello world" app (i.e what is there after flutter create...)
Therefore we only changed a few pubspec.yaml dependencies in comparison with a fresh new Flutter create app. And the dependecies is what the package-provider suggests in his/her example !
The "hello world" App works fine under Android & iOS. However, adding a few pubspec.yaml dependencies makes the Android crash (iOS works fine)...
Here is the error log when Android is launched:
* Error running Gradle:
ProcessException: Process "/Users/user/Flutter_applications/01_MyOwn_Flutter_apps/testy/android/gradlew" exited abnormally:
Starting a Gradle Daemon, 5 stopped Daemons could not be reused, use --status for details

FAILURE: Build failed with an exception.

* Where:
Script '/Users/user/Documents/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 200

* What went wrong:
A problem occurred configuring project ':flutter_downloader'.
> Failed to notify project evaluation listener.
   > Could not get unknown property 'android' for project ':flutter_downloader' of type org.gradle.api.Project.
   > Could not find method debugProvided() for arguments [file collection] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

* 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 7s
  Command: /Users/user/Flutter_applications/01_MyOwn_Flutter_apps/testy/android/gradlew app:properties

Exited (sigterm)

Other packages deliver slightly different errors. But it is always something with a gradle-issue or an android-incompatibility. What Android version do I need to install ? Isn't the newest stable one the best option ??  How do I find out which package-versions fit which Android-version ? How can I match the two ??? (and still keep all my other packages running).
After my odyssey, I wonder, isn't Flutter a bit of a mess if it comes to Android dependencies ??? 
Any suggestion on how to deal with these kind of problems are highly appreciated. How do you proceed normally with Flutter packages and Android compatibility ???

Or here another example with image_picker package (coming from Flutter Team here):
Steps 1-3 are the same as above. All I do is creating a hello-world Flutter app and adding the dependencies as stated in the package-example:
Here the image_picker dependencies:
dependencies:
  flutter:
    sdk: flutter
  video_player: 0.5.2
  image_picker: ^0.6.0+8
  cupertino_icons: ^0.1.2

And here the Android Error:
* Error running Gradle:
ProcessException: Process "/Users/user/Flutter_applications/01_MyOwn_Flutter_apps/testy/android/gradlew" exited abnormally:

FAILURE: Build failed with an exception.

* Where:
Script '/Users/user/Documents/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 200

* What went wrong:
A problem occurred configuring project ':image_picker'.
> Failed to notify project evaluation listener.
   > Could not get unknown property 'android' for project ':image_picker' of type org.gradle.api.Project.
   > Could not find method debugProvided() for arguments [file collection] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

* 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
  Command: /Users/user/Flutter_applications/01_MyOwn_Flutter_apps/testy/android/gradlew app:properties

Please review your Gradle project setup in the android/ folder.
Exited (sigterm)

A:

I FINAAALLY FOUND A SOLUTION:
The next three steps show how to get two out of the four remaining dependencies up-n-running.
At the bottom, there is more Android Studio steps to go through (mixed with some prayers and manual steps) to finally get all four buggers up-n-running !!!
Here the flutter cleanup-steps that were needed: (no idea when, why and where it went corrupt in the first place !):
Step 1 : Inside my flutter SDK install folder, I typed into a terminal:
git clean -xfd

git stash save --keep-index

git stash drop

git pull

flutter doctor

Step 2 : Inside my flutter app folder, I did also type in the terminal:
flutter packages pub cache repair

Step 3 : Inside Visual-Studio-Code, I also did a Flutter deinstall and Dart deinstall. And re-installed the two. I restarted Visual-Studio-Code.
Having completed these three steps, I get two out of 4 dependencies back alive and my Android "hello world" app at least compiles (except for the last two buggers). The two buggers still not working under Android are commented-out in the following pubspec.yaml dependency list :
dependencies:
  flutter:
    sdk: flutter
  shared_preferences: ^0.5.2+1
  sqflite: ^1.1.5
  intl: ^0.15.8
  tuple: ^1.0.2
  material_design_icons_flutter: ^3.2.3695
  launch_review: ^2.0.0
  fit_image: ^0.1.2
  datetime_picker_formfield: ^0.1.8
  flutter_screenutil: ^0.5.2
  path_provider: ^1.1.0
  image_picker: ^0.6.0+8
  url_launcher: ^5.0.2
  # permission_handler: ^3.1.0
  # flutter_downloader: ^1.1.7
  large_file_copy: ^0.0.1
  flutter_localizations:
    sdk: flutter
  cupertino_icons: ^0.1.2

For the two dependencies (i.e. permission_handler and flutter_downloader), I now get a new error when trying to build for Android:
* What went wrong:
Execution failed for task ':app:preDebugBuild'.
> Android dependency 'androidx.core:core' has different version for the compile (1.0.0) and runtime (1.0.1) classpath. You should manually set the same version via DependencyResolution

* 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 3s
*******************************************************************************************
The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.
*******************************************************************************************
Gradle task assembleDebug failed with exit code 1
Exited (sigterm)

Now I am back to the need for AndroidX migration, it seems. But I really fear of doing that since it corrupts all the other nicely working packages.
What do you suggest to do here as for the error message ?? How do I get the last two packages to work as well (next to all the other packages) ???

Here is a solution to the last two buggers:
Step A : Open Android Studio
This can best be done inside VSCode by right-clicking the /android folder inside your Flutter project and selecting Open in Android Studio

Step B : Press the Make Project hammer inside Android Studio to cause some Android Studio checkups to run...

Step C : Wait and pray (so that Android Studio makes the magic cleansing) 
It turns out that Android Studio does not really grasp all mistakes as for the package compatibilities. Therefore, I went through all Gradles and checked manually for...
a) newest build.gradle version (i.e. hovering over any grey'isch gradle line by the mouse will show the newest version and you can change manually accordingly)
b) newest Kotlin version (to find out which Kotlin version is the newest one, please go to the SDK-manager inside Android Studio and select Kotlin. This will reveal the newest version. Make sure to integrate this version in every gradle accordingly)
Here is an illustration where and what to change:

And here an illustration on where to change for the newest Kotlin version :

WITH THE ABOVE STEPS 1-3 AND STEPS A-C, I ACHIEVED GETTING ALL THE DEPENCENCY PACKAGES RUNNING UNDER ANDROID. 
I hope that the Flutter Team will be able to make this process somewhat more transparent in the future - and I am sure they will.

