Repository navigation
Unable to run Android app on stable 2.10 if it uses a plugin with an android folder but no Android support #97729
Copy link
Copy link
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: buildBuilding flutter applications with the toolBuilding flutter applications with the toolc: regressionIt was better in the past than it is nowIt was better in the past than it is nowfound in release: 2.10Found to occur in 2.10Found to occur in 2.10has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onplatform-androidAndroid applications specificallyAndroid applications specificallyteam-androidOwned by Android platform teamOwned by Android platform teamtoolAffects the "flutter" command-line tool. See also t: labels.Affects the "flutter" command-line tool. See also t: labels.triaged-androidTriaged by Android platform teamTriaged by Android platform team
Description
Steps to Reproduce
The app can't be built on Android if a plugin is only iOS targetting.
It's the case with apple_map_flutter.
I can't run my app under Android with the new release Flutter: 2.10 because the tool expect all plugins to support both Android and iOS or something like this (i have another project that builds find without apple_map_flutter)
- Create a new project under flutter: 2.10
- Add apple_maps_flutter dependency using
flutter pub add apple_maps_flutter - Build your app on Android device on flutter 2.10 stable/master
Expected results:
The app should be built on Android (and on iOS) even if a plugin is missing for one of the platform, as it was done before flutter: 2.10.
Actual results:
Launching lib/main.dart on moto g 8 power in debug mode...
Running Gradle task 'assembleDebug'...
Plugin project :apple_maps_flutter not found. Please update settings.gradle.
FAILURE: Build failed with an exception.
* Where:
Script '/Users/foxtom/Desktop/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 421
* What went wrong:
A problem occurred evaluating root project 'android'.
> A problem occurred configuring project ':app'.
> Cannot invoke method afterEvaluate() on null object
Logs
[✓] Flutter (Channel stable, 2.10.0, on macOS 12.2 21D49 darwin-x64, locale fr-FR)
• Flutter version 2.10.0 at /Users/foxtom/Desktop/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 5f105a6ca7 (2 days ago), 2022-02-01 14:15:42 -0800
• Engine revision 776efd2034
• Dart version 2.16.0
• DevTools version 2.9.2
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
• Android SDK at /Users/foxtom/Library/Android/sdk
• Platform android-31, build-tools 31.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• CocoaPods version 1.11.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2021.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)
[✓] VS Code (version 1.63.2)
• VS Code at /Users/foxtom/Desktop/Visual Studio Code.app/Contents
• Flutter extension version 3.34.0
[✓] Connected device (3 available)
• moto g 8 power (mobile) • ZY22BNDW2C • android-arm64 • Android 11 (API 30)
• macOS (desktop) • macos • darwin-x64 • macOS 12.2 21D49 darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome 98.0.4758.80
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: buildBuilding flutter applications with the toolBuilding flutter applications with the toolc: regressionIt was better in the past than it is nowIt was better in the past than it is nowfound in release: 2.10Found to occur in 2.10Found to occur in 2.10has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onplatform-androidAndroid applications specificallyAndroid applications specificallyteam-androidOwned by Android platform teamOwned by Android platform teamtoolAffects the "flutter" command-line tool. See also t: labels.Affects the "flutter" command-line tool. See also t: labels.triaged-androidTriaged by Android platform teamTriaged by Android platform team
Activity
maheshj01 commentedon Feb 4, 2022
Hi @Tom3652, Thanks for filing the issue. I was able to reproduce the same behavior the app failed to build when using a plugin not supported for Android. This was reproducible on the latest stable/master and even on
stable 2.8.1. This looks like a duplicate of #46304 (closed). Not sure if this is intended, But I was able to fix this by modifying thesettings.gradlesettings.gradle (after modification)
flutter run stable(2.10)
flutter run (stable 2.8.1)
flutter doctor -v
cc: @blasten
[-]Unable to run app under Android with Flutter 2.10 if a plugin only supports iOS[/-][+]Unable to run Android app on stable 2.10 if the project uses iOS only Plugin[/+]Tom3652 commentedon Feb 4, 2022
Thank you @maheshmnj it's indeed working with your
settings.gradlefile ! :)stuartmorgan-g commentedon Feb 4, 2022
I'm very confused here.
The lines you've added below that should cause this issue, not fix it. It unconditionally adds every plugin, unlike
app_plugin_loader.gradlewhich filters by supported platform.stuartmorgan-g commentedon Feb 4, 2022
@Tom3652 Could you provide the
.flutter-plugins-dependenciesfile for a project that reproduces this?Tom3652 commentedon Feb 4, 2022
Yes sure @stuartmorgan :
I have simply created a new project, added the
apple_map_flutterand build on my android device.[-]Unable to run Android app on stable 2.10 if the project uses iOS only Plugin[/-][+]Unable to run Android app on stable 2.10 if it uses a plugin with an android folder but no Android support[/+]stuartmorgan-g commentedon Feb 4, 2022
Oh, I see. This is the new code to check min SDK versions. It's still using
.flutter-plugins, which is wrong; it should be using.flutter-plugins-dependencies.In most cases it will still work because
flutter_tools/gradle/flutter.gradledoes its own filtering based on the presence of a gradle file in the right place in the plugin, but that is being defeated by the fact thatapple_maps_flutterhas an android/ folder even though it doesn't support Android.We should definitely fix this on our side by updating
flutter_tools/gradle/flutter.gradleto use.flutter-plugins-dependencies, but it can also be fixed by the plugin author. I'll file an issue there.23 remaining items
mdrideout commentedon May 31, 2022
Good point!
GaryQian commentedon Nov 1, 2022
@stuartmorgan What is the status of this bug? Can this be closed?
stuartmorgan-g commentedon Nov 2, 2022
No, it's still a bug. It's trivial for plugin developers to avoid by deleting dead/dummy
android/directories, but we shouldn't fail to build if they don't.Reland: "Fix how Gradle resolves Android plugin" (#137115)
Reland: "Fix how Gradle resolves Android plugin" (flutter#137115)
github-actions commentedon Jan 4, 2024
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.