Skip to content

Unable to run Android app on stable 2.10 if it uses a plugin with an android folder but no Android support #97729

Description

@Tom3652

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)

  1. Create a new project under flutter: 2.10
  2. Add apple_maps_flutter dependency using flutter pub add apple_maps_flutter
  3. 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!

Activity

  1. maheshj01 commented on Feb 4, 2022

    @maheshj01
    Member

    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 the settings.gradle

    settings.gradle (after modification)
    include ':app'
    
    def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
    def properties = new Properties()
    
    assert localPropertiesFile.exists()
    localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
    
    def flutterSdkPath = properties.getProperty("flutter.sdk")
    assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
    apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
    
    def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
    
    // Fixed by adding the lines below
    
    def plugins = new Properties()
    def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
    if (pluginsFile.exists()) {
        pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
    }
    
    plugins.each { name, path ->
        def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
        include ":$name"
        project(":$name").projectDir = pluginDirectory
    }
    flutter run stable(2.10)
    Launching lib[/main.dart]() on Redmi K20 Pro in debug mode...
    lib/main.dart:1
    Plugin project :apple_maps_flutter not found. Please update settings.gradle.
    
    FAILURE: Build failed with an exception.
    
    * Where:
    Script '[/Users/mahesh/Documents/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
    
    * 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 21s
    Exception: Gradle task assembleDebug failed with exit code 1
    Exited (sigterm)
    
    flutter run (stable 2.8.1)
    mahesh@Maheshs-MacBook-Air-M1 sample % flutter run     
    Launching lib/main.dart on Redmi K20 Pro in debug mode...
    Plugin project :apple_maps_flutter not found. Please update settings.gradle.
    Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
    Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
    Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
    Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
    Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
    Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
    Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
    Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
    Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
    Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
    e: /Users/mahesh/Desktop/sample/android/app/src/main/kotlin/com/example/sample/MainActivity.kt: (3, 19): Unresolved reference: embedding
    e: /Users/mahesh/Desktop/sample/android/app/src/main/kotlin/com/example/sample/MainActivity.kt: (5, 21): Unresolved reference: FlutterActivity
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':app:compileDebugKotlin'.
    > Compilation error. See log for more 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 35s
    Running Gradle task 'assembleDebug'...                             37.2s
    Exception: Gradle task assembleDebug failed with exit code 1
    flutter doctor -v
    [✓] Flutter (Channel stable, 2.10.0, on macOS 12.1 21C52 darwin-arm, locale en-GB)
        • Flutter version 2.10.0 at /Users/mahesh/Documents/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/mahesh/Library/Android/sdk
        • Platform android-31, build-tools 31.0.0
        • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
        • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • CocoaPods version 1.10.2
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 4.2)
        • 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.8+10-b944.6916264)
    
    [✓] IntelliJ IDEA Community Edition (version 2021.2.1)
        • IntelliJ at /Applications/IntelliJ IDEA CE.app
        • Flutter plugin version 60.1.4
        • Dart plugin version 212.5080.8
    
    [✓] VS Code (version 1.63.2)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.34.0
    
    [✓] Connected device (3 available)
        • Redmi K20 Pro (mobile) • 192.168.1.2:5555 • android-arm64  • Android 11 (API 30)
        • macOS (desktop)        • macos            • darwin-arm64   • macOS 12.1 21C52 darwin-arm
        • Chrome (web)           • chrome           • web-javascript • Google Chrome 98.0.4758.80
    
    [✓] HTTP Host Availability
        • All required HTTP hosts are available
    
    • No issues found!
    
    [✓] Flutter (Channel master, 2.10.0-1.0.pre.371, on macOS 12.1 21C52 darwin-arm, locale en-GB)
        • Flutter version 2.10.0-1.0.pre.371 at /Users/mahesh/Documents/flutter_master
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision d1285eef1b (2 days ago), 2022-02-02 00:50:20 -0500
        • Engine revision 5bbdb7a6f7
        • Dart version 2.17.0 (build 2.17.0-74.0.dev)
        • DevTools version 2.10.0
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
        • Android SDK at /Users/mahesh/Library/Android/sdk
        • Platform android-31, build-tools 31.0.0
        • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
        • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • CocoaPods version 1.10.2
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 4.2)
        • 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.8+10-b944.6916264)
    
    [✓] IntelliJ IDEA Community Edition (version 2021.2.1)
        • IntelliJ at /Applications/IntelliJ IDEA CE.app
        • Flutter plugin version 60.1.4
        • Dart plugin version 212.5080.8
    
    [✓] VS Code (version 1.63.2)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.34.0
    
    [✓] Connected device (3 available)
        • Redmi K20 Pro (mobile) • 192.168.1.2:5555 • android-arm64  • Android 11 (API 30)
        • macOS (desktop)        • macos            • darwin-arm64   • macOS 12.1 21C52 darwin-arm
        • Chrome (web)           • chrome           • web-javascript • Google Chrome 98.0.4758.80
    
    [✓] HTTP Host Availability
        • All required HTTP hosts are available
    
    • No issues found!
    

    cc: @blasten

  2. added
    a: buildBuilding flutter applications with the tool
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    platform-androidAndroid applications specifically
    toolAffects the "flutter" command-line tool. See also t: labels.
    and removed
    in triagePresently being triaged by the triage team
    on Feb 4, 2022
  3. changed the title [-]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[/+] on Feb 4, 2022
  4. Tom3652 commented on Feb 4, 2022

    @Tom3652
    Author

    Thank you @maheshmnj it's indeed working with your settings.gradle file ! :)

  5. stuartmorgan-g commented on Feb 4, 2022

    @stuartmorgan-g
    Contributor

    I'm very confused here.

    // Fixed by adding the lines below
    

    The lines you've added below that should cause this issue, not fix it. It unconditionally adds every plugin, unlike app_plugin_loader.gradle which filters by supported platform.

  6. stuartmorgan-g commented on Feb 4, 2022

    @stuartmorgan-g
    Contributor

    @Tom3652 Could you provide the .flutter-plugins-dependencies file for a project that reproduces this?

  7. Tom3652 commented on Feb 4, 2022

    @Tom3652
    Author

    Yes sure @stuartmorgan :

    {"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"apple_maps_flutter","path":"/Users/foxtom/Desktop/flutter/.pub-cache/hosted/pub.dartlang.org/apple_maps_flutter-1.0.1/","dependencies":[]}],"android":[],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"apple_maps_flutter","dependencies":[]}],"date_created":"2022-02-04 17:01:44.328220","version":"2.10.0"}%  
    

    I have simply created a new project, added the apple_map_flutter and build on my android device.

  8. changed the title [-]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[/+] on Feb 4, 2022
  9. stuartmorgan-g commented on Feb 4, 2022

    @stuartmorgan-g
    Contributor

    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.gradle does 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 that apple_maps_flutter has an android/ folder even though it doesn't support Android.

    We should definitely fix this on our side by updating flutter_tools/gradle/flutter.gradle to use .flutter-plugins-dependencies, but it can also be fixed by the plugin author. I'll file an issue there.

  10. 23 remaining items

  11. mdrideout commented on May 31, 2022

    @mdrideout

    Good point!

  12. GaryQian commented on Nov 1, 2022

    @GaryQian
    Contributor

    @stuartmorgan What is the status of this bug? Can this be closed?

  13. stuartmorgan-g commented on Nov 2, 2022

    @stuartmorgan-g
    Contributor

    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.

  14. added a commit that references this issue on Dec 21, 2023
    f5ac225
  15. added a commit that references this issue on Dec 28, 2023
    164cf74
  16. github-actions commented on Jan 4, 2024

    @github-actions

    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 -v and a minimal reproduction of the issue.

  17. locked as resolved and limited conversation to collaborators on Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: buildBuilding flutter applications with the toolc: regressionIt was better in the past than it is nowfound in release: 2.10Found to occur in 2.10has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-androidAndroid applications specificallyteam-androidOwned by Android platform teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-androidTriaged by Android platform team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions