Skip to content

Generated Flutter Module Files Do Not Use AndroidX #28805

Closed

Description

@rayliverified

Flutter generated files still target SDK 27 and use the non AndroidX version of libraries which conflicts with projects that target SDK 28 and use AndroidX.

I've previously opened an issue about this at Add Flutter to Existing App Fails, Flutter Tools Generates Incorrect Files #22090

It's been 5 months and 2 major version releases later so I would like to ask about plans to update the generated files. The problem is that the generated files overwrite my fixes which means I have to make the same fixes EVERY TIME just to build my project.

maxthonsnap20190303114745

maxthonsnap20190303114935

maxthonsnap20190303115406

maxthonsnap20190303115536

Are there plans to update Flutter to target SDK 28 and use AndroidX?

Activity

  1. jonahwilliams commented on Mar 3, 2019

    @jonahwilliams
    Contributor
  2. matthew-carroll commented on Mar 3, 2019

    @matthew-carroll
    Contributor

    @jonahwilliams @gspencergoog @dnfield @jason-simmons Do any of you know the right group of people to assemble to make a decision about SDK versions and included libs like AndroidX? This question applies both to a Flutter project, as well as the Android embedding, itself.

  3. jiechic commented on Mar 4, 2019

    @jiechic

    the same problem on use flutter module for an exits project
    i want to use flutter but now is shelve

  4. neiljaywarner commented on Mar 5, 2019

    @neiljaywarner

    @searchy2 @jiechic what is the output of flutter-doctor please? I just did file-new-project in intellij with Flutter (Channel stable, v1.2.1) and I get CompiledSDK 28 target SDK 28

    I also get the same desired/good behaviour (target 28) with add2app .android directories recently created wit flutter 1.2.1

    cc @matthew-carroll

    although i would agree communication about it is very important please, e.g. https://github.com/flutter/flutter/wiki/Changelog and an entry on flutter.dev FAQ for Android developers or even more since the play store requirement is so urgent (august timeline) every year - so charting this item very carefully would be greatly appreciated.

    "the other guys" have done poorly in this area so it would be great if flutter would do excellent in this area

  5. rayliverified commented on Mar 5, 2019

    @rayliverified
    Author

    I'll create a new project from scratch and give it a try. Flutter has been giving me a lot of problems lately with Git and not committing the right files in .gitignore. Fingers crossed starting a new project will generate the correct file sdk targets.

  6. jiechic commented on Mar 6, 2019

    @jiechic
  7. rayliverified commented on Mar 10, 2019

    @rayliverified
    Author

    Can verify that creating a brand new Android project and adding a new Flutter module does result in incompatible generated files with AndroidX.

  8. neiljaywarner commented on Mar 10, 2019

    @neiljaywarner

    Would it be wise to update title? If Android x is the issue but api levels fine?
    ...

  9. rayliverified commented on Mar 10, 2019

    @rayliverified
    Author

    Sure, what title do you think is more accurate?

  10. neiljaywarner commented on Mar 10, 2019

    @neiljaywarner

    Just maybe please take out "target so 27 and" if they no longer apply

  11. added
    platform-androidAndroid applications specifically
    t: gradle"flutter build" and "flutter run" on Android
    a: existing-appsIntegration with existing apps via the add-to-app flow
    on Mar 10, 2019
  12. added this to the milestone on Mar 10, 2019
  13. dnfield commented on Mar 10, 2019

    @dnfield
    Contributor

    Android X is a bit thorny right now partly because of plugins. In the ecosystem, some plugins are migrated to Android X, others are not. Processes that we'd hope would assist with migrating automatically projects aren't quite working here. We're investigating this to try to figure out how to make the migration as painless as possible - but it's not quite there yet.

    If you need this today, you'd have to migrate the template yourself, and then it's possible that you will have trouble using some plugins that have not yet migrated to Android X. The dependency interactions get kind of messy and TBH I'm not 100% clear on which configurations do and don't work at this point.

    This is definitely on our radar, but I don't have a good notion right now for when we'll have it resolved.

    /cc @mklim

  14. 12 remaining items

  15. josh-burton commented on Apr 12, 2019

    @josh-burton
    Contributor

    I think the issue there is that there are still quite a few plugins that haven't updated to AndroidX yet.

    Switching to AndroidX in the template would break compatibility.

    Google build Jetifier for this exact reason - to rewrite the class files of dependencies to use AndroidX. The best fix here would be to get Jetifier working with the Flutter module.

  16. noordawod commented on Apr 13, 2019

    @noordawod
    Contributor

    Understood. So why not prepare a separate branch to be compatible with the upcoming AndroidX? That should be an easy task. Hell, I would submit a PR if the Flutter team would accept that as a viable route.

  17. josh-burton commented on Apr 14, 2019

    @josh-burton
    Contributor

    I've created a PR (above) that adds support for AndroidX. It adds a new flag to the module section of a pubspec.yaml file which controls whether the generated files use AndroidX.

    flutter:
      uses-material-design: true
    
      module:
        androidX: true
        androidPackage:
        iosBundleIdentifier:
    
  18. jiechic commented on Apr 16, 2019

    @jiechic

    it's some wrong on PR build
    have any update for after?

  19. rayliverified commented on Jun 2, 2019

    @rayliverified
    Author

    Going to test this in Add 2 App and see if the issue is fixed. 🤞

  20. blvckcoded commented on Jun 7, 2019

    @blvckcoded

    Any luck on this working now? @searchy2

    I have an existing android app with target and compile SDK version = 28. The project has been migrated to AndroidX.

    Ran flutter channel master (to get the PR merge fix by @athornz , flutter upgrade

    then followed documentation here: https://github.com/flutter/flutter/wiki/Add-Flutter-to-existing-apps

    A) ran flutter create --androidx -t module my_flutter <-- added the --androidx flag.
    This generates the flutter module and all other files within the project.

    B) Updated my settings.gradle

    C) Added the flutter module as an implementation dependency to my gradle

    However, the pubspec.yaml file does not have this flag added: androidX: true. The generated java Flutter classes still use the old android support libraries.

    Am I missing something here?

  21. josh-burton commented on Jun 7, 2019

    @josh-burton
    Contributor

    @omid-io I've just created a small PR to fix that, but you can add the androidX flag manually and run flutter packages get and the generated files will be updated to androidX.

  22. blvckcoded commented on Jun 7, 2019

    @blvckcoded

    thanks @athornz, You Da Man! 👍 I'll try it out!

  23. rayliverified commented on Oct 20, 2019

    @rayliverified
    Author

    Keeping this issue open because there's still issues with converting an existing project to AndroidX.
    MaxthonSnap20191020150809
    AndroidX compatibility is still not enabled by default which means that new projects that are created needs to be converted to AndroidX. Unfortunately, the conversion process doesn't always work. When can AndroidX be enabled by default?

  24. blasten commented on Nov 4, 2019

    @blasten

    AndroidX is the default now.

  25. github-actions commented on Aug 14, 2021

    @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.

  26. locked as resolved and limited conversation to collaborators on Aug 14, 2021
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

    a: existing-appsIntegration with existing apps via the add-to-app flowplatform-androidAndroid applications specificallyt: gradle"flutter build" and "flutter run" on AndroidtoolAffects the "flutter" command-line tool. See also t: labels.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions