最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Why is my Android project requiring external library after updating the external Flutter module? - Stack Overflow

programmeradmin1浏览0评论

We have an Android project that integrates a Flutter module externally. This setup was working fine previously.

Recently, we updated the Flutter module to a newer version which includes some changes, and now the Android project fails to build unless we explicitly add the following dependency in our build.gradle file:

implementation 'com.google.android.exoplayer:exoplayer:2.18.7'

This is strange because the integration method (adding Flutter module externally) hasn't changed, and we haven't updated any native Android code ourselves.

The project structure looks like this:

/android_project
  ├── app/
  ├── flutter_module/  ← added as an external module

We are integrating the Flutter module using build.gradle:

repositories {
    maven {
        url '../flutter_modules'
    }
    maven {
        url "$storageUrl/download.flutter.io"
    }
}

pubspec.yaml

name: teams_module
description: A flutter module for Teams integration


version: 2.5.0

environment:
  sdk: '>=2.12.0 <3.0.0'

dependencies:
  cupertino_icons: 1.0.5
  flutter:
    sdk: flutter
  flutter_localizations:
    sdk: flutter
  intl: ^0.17.0

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  dio: ^4.0.6
  quiver: ^3.1.0
  dio_http_cache: ^0.3.0
  flutter_html: ^2.2.1
  bloc_provider: ^0.8.0
  photo_view: ^0.14.0
  # Because teams_module depends on path_provider >=2.0.5 which requires SDK version >=2.14.0 <3.0.0, version solving failed.
  path_provider: ^2.0.11
  flutter_adaptive_cards: ^0.2.0-nullsafety.0
  back_button_interceptor: 6.0.0
  provider: ^6.0.3
  # Because teams_module depends on url_launcher >=6.0.11 which requires SDK version >=2.14.0 <3.0.0, version solving failed.
  url_launcher: ^6.1.3
  flutter_widget_from_html_core: ^0.8.5+3
  after_layout: ^1.2.0
  shared_preferences: ^2.0.15
  separated_column: ^2.0.0
  loadmore: ^2.0.1
  string_validator: ^0.3.0
  # Because every version of flutter_test from sdk depends on path 1.8.1 and teams_module depends on path ^1.8.2, flutter_test from sdk is forbidden.
  path: ^1.8.1
  permission_handler: 10.4.3
  async: ^2.8.2
  file_picker: 5.2.10
  flutter_statusbarcolor_ns: 0.4.0
  image_picker: 0.8.4+11
  video_player: 2.4.5
  video_thumbnail: 0.5.3
  flutter_cache_manager: 3.3.0
  chewie: 1.3.3
  progress_dialog_null_safe: 1.0.7
  tuple: 2.0.0

# flutter_html and flutter_adaptive_cards are using different versions of chewie in their inner dependencies.
# flutter_driver and flutter_adaptive_cards are also using different versions of intl.
# To prevent the conflict, I force app to use unified version to let build success.
dependency_overrides:
  chewie: 1.3.3
  intl: 0.17.0
  uuid: 3.0.6
  # ! provider 2.0.1+1 (6.0.1 available)
  provider: 6.0.3
  http: 0.13.4
  async: 2.8.2
  # Because dio_http_cache >=0.3.0 depends on json_serializable ^4.1.4 which depends on analyzer >=0.41.2 <2.0.0, dio_http_cache >=0.3.0 requires analyzer >=0.41.2 <2.0.0.
 #  And because mockito >=5.0.16 depends on analyzer ^2.1.0, dio_http_cache >=0.3.0 is incompatible with mockito >=5.0.16.
  # I use 1.7.0 cuz I want to promise dio_http_cache much more than mockito.
  analyzer: 4.1.0
  # Because analyzer >=1.7.0 <1.7.1 depends on meta ^1.4.0 and every version of flutter_driver from sdk depends on meta 1.3.0, analyzer >=1.7.0 <1.7.1 is incompatible with flutter_driver from sdk.
  meta: ^1.8.0
  video_player: 2.4.5
  flutter_svg: 1.1.0
  fwfh_text_style: 2.22.8+1
  file: 6.1.3

dev_dependencies:
  flutter_driver:
    sdk: flutter
  flutter_test:
    sdk: flutter
  test: ^1.21.0
  mockito: ^5.2.0
  plugin_platform_interface: ^2.1.2
  # Because teams_module depends on flutter_test from sdk which depends on fake_async 1.3.0, fake_async 1.3.0 is required.
  fake_async: 1.3.1
  mocktail: ^0.3.0

# For information on the generic Dart part of this file, see the
# following page: /tools/pub/pubspec

flutter:
  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true

  # To add Flutter specific assets to your application, add an assets section, 
  # like this:
  # assets:
  #  - images/a_dot_burr.jpeg
  #  - images/a_dot_ham.jpeg
  # FIXME(anyone): Create a config folder and put the files in there.
  assets:
    - lib/host_config
    - assets/file/
    - assets/[email protected]
    - assets/double_ring_loading_io.gif
    - assets/speaker_notes_border.png
    - assets/2.0x/speaker_notes_border.png
    - assets/3.0x/speaker_notes_border.png
  # An image asset can refer to one or more resolution-specific "variants", see
  # /assets-and-images/#resolution-aware.

  # For details regarding adding assets from package dependencies, see
  # /assets-and-images/#from-packages

  # To add Flutter specific custom fonts to your application, add a fonts
  # section here, in this "flutter" section. Each entry in this list should
  # have a "family" key with the font family name, and a "fonts" key with a
  # list giving the asset and other descriptors for the font. For
  # example:
  # fonts:
  #   - family: Schyler
  #     fonts:
  #       - asset: fonts/Schyler-Regular.ttf
  #       - asset: fonts/Schyler-Italic.ttf
  #         style: italic
  #   - family: Trajan Pro
  #     fonts:
  #       - asset: fonts/TrajanPro.ttf
  #       - asset: fonts/TrajanPro_Bold.ttf
  #         weight: 700
  #
  # For details regarding fonts from package dependencies,
  # see /custom-fonts/#from-packages


  # This section identifies your Flutter project as a module meant for
  # embedding in a native host app.  These identifiers should _not_ ordinarily
  # be changed after generation - they are used to ensure that the tooling can
  # maintain consistency when adding or modifying assets and plugins.
  # They also do not have any bearing on your native host application's
  # identifiers, which may be completely independent or the same as these.
  module:
    androidX: true
    androidPackage: ********.teams_module
    iosBundleIdentifier: *********.teamsModule

We suspect that something in the new Flutter module is indirectly causing this dependency requirement. But we’re not sure why this is now required, especially since the native Android code hasn’t been touched.

Questions:

  1. What could cause the Android project to suddenly require com.google.android.exoplayer after updating the Flutter module?
  2. Could this be coming from a Flutter plugin or package that was added or updated?

We have an Android project that integrates a Flutter module externally. This setup was working fine previously.

Recently, we updated the Flutter module to a newer version which includes some changes, and now the Android project fails to build unless we explicitly add the following dependency in our build.gradle file:

implementation 'com.google.android.exoplayer:exoplayer:2.18.7'

This is strange because the integration method (adding Flutter module externally) hasn't changed, and we haven't updated any native Android code ourselves.

The project structure looks like this:

/android_project
  ├── app/
  ├── flutter_module/  ← added as an external module

We are integrating the Flutter module using build.gradle:

repositories {
    maven {
        url '../flutter_modules'
    }
    maven {
        url "$storageUrl/download.flutter.io"
    }
}

pubspec.yaml

name: teams_module
description: A flutter module for Teams integration


version: 2.5.0

environment:
  sdk: '>=2.12.0 <3.0.0'

dependencies:
  cupertino_icons: 1.0.5
  flutter:
    sdk: flutter
  flutter_localizations:
    sdk: flutter
  intl: ^0.17.0

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  dio: ^4.0.6
  quiver: ^3.1.0
  dio_http_cache: ^0.3.0
  flutter_html: ^2.2.1
  bloc_provider: ^0.8.0
  photo_view: ^0.14.0
  # Because teams_module depends on path_provider >=2.0.5 which requires SDK version >=2.14.0 <3.0.0, version solving failed.
  path_provider: ^2.0.11
  flutter_adaptive_cards: ^0.2.0-nullsafety.0
  back_button_interceptor: 6.0.0
  provider: ^6.0.3
  # Because teams_module depends on url_launcher >=6.0.11 which requires SDK version >=2.14.0 <3.0.0, version solving failed.
  url_launcher: ^6.1.3
  flutter_widget_from_html_core: ^0.8.5+3
  after_layout: ^1.2.0
  shared_preferences: ^2.0.15
  separated_column: ^2.0.0
  loadmore: ^2.0.1
  string_validator: ^0.3.0
  # Because every version of flutter_test from sdk depends on path 1.8.1 and teams_module depends on path ^1.8.2, flutter_test from sdk is forbidden.
  path: ^1.8.1
  permission_handler: 10.4.3
  async: ^2.8.2
  file_picker: 5.2.10
  flutter_statusbarcolor_ns: 0.4.0
  image_picker: 0.8.4+11
  video_player: 2.4.5
  video_thumbnail: 0.5.3
  flutter_cache_manager: 3.3.0
  chewie: 1.3.3
  progress_dialog_null_safe: 1.0.7
  tuple: 2.0.0

# flutter_html and flutter_adaptive_cards are using different versions of chewie in their inner dependencies.
# flutter_driver and flutter_adaptive_cards are also using different versions of intl.
# To prevent the conflict, I force app to use unified version to let build success.
dependency_overrides:
  chewie: 1.3.3
  intl: 0.17.0
  uuid: 3.0.6
  # ! provider 2.0.1+1 (6.0.1 available)
  provider: 6.0.3
  http: 0.13.4
  async: 2.8.2
  # Because dio_http_cache >=0.3.0 depends on json_serializable ^4.1.4 which depends on analyzer >=0.41.2 <2.0.0, dio_http_cache >=0.3.0 requires analyzer >=0.41.2 <2.0.0.
 #  And because mockito >=5.0.16 depends on analyzer ^2.1.0, dio_http_cache >=0.3.0 is incompatible with mockito >=5.0.16.
  # I use 1.7.0 cuz I want to promise dio_http_cache much more than mockito.
  analyzer: 4.1.0
  # Because analyzer >=1.7.0 <1.7.1 depends on meta ^1.4.0 and every version of flutter_driver from sdk depends on meta 1.3.0, analyzer >=1.7.0 <1.7.1 is incompatible with flutter_driver from sdk.
  meta: ^1.8.0
  video_player: 2.4.5
  flutter_svg: 1.1.0
  fwfh_text_style: 2.22.8+1
  file: 6.1.3

dev_dependencies:
  flutter_driver:
    sdk: flutter
  flutter_test:
    sdk: flutter
  test: ^1.21.0
  mockito: ^5.2.0
  plugin_platform_interface: ^2.1.2
  # Because teams_module depends on flutter_test from sdk which depends on fake_async 1.3.0, fake_async 1.3.0 is required.
  fake_async: 1.3.1
  mocktail: ^0.3.0

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

flutter:
  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true

  # To add Flutter specific assets to your application, add an assets section, 
  # like this:
  # assets:
  #  - images/a_dot_burr.jpeg
  #  - images/a_dot_ham.jpeg
  # FIXME(anyone): Create a config folder and put the files in there.
  assets:
    - lib/host_config
    - assets/file/
    - assets/[email protected]
    - assets/double_ring_loading_io.gif
    - assets/speaker_notes_border.png
    - assets/2.0x/speaker_notes_border.png
    - assets/3.0x/speaker_notes_border.png
  # An image asset can refer to one or more resolution-specific "variants", see
  # https://flutter.dev/assets-and-images/#resolution-aware.

  # For details regarding adding assets from package dependencies, see
  # https://flutter.dev/assets-and-images/#from-packages

  # To add Flutter specific custom fonts to your application, add a fonts
  # section here, in this "flutter" section. Each entry in this list should
  # have a "family" key with the font family name, and a "fonts" key with a
  # list giving the asset and other descriptors for the font. For
  # example:
  # fonts:
  #   - family: Schyler
  #     fonts:
  #       - asset: fonts/Schyler-Regular.ttf
  #       - asset: fonts/Schyler-Italic.ttf
  #         style: italic
  #   - family: Trajan Pro
  #     fonts:
  #       - asset: fonts/TrajanPro.ttf
  #       - asset: fonts/TrajanPro_Bold.ttf
  #         weight: 700
  #
  # For details regarding fonts from package dependencies,
  # see https://flutter.dev/custom-fonts/#from-packages


  # This section identifies your Flutter project as a module meant for
  # embedding in a native host app.  These identifiers should _not_ ordinarily
  # be changed after generation - they are used to ensure that the tooling can
  # maintain consistency when adding or modifying assets and plugins.
  # They also do not have any bearing on your native host application's
  # identifiers, which may be completely independent or the same as these.
  module:
    androidX: true
    androidPackage: ********.teams_module
    iosBundleIdentifier: *********.teamsModule

We suspect that something in the new Flutter module is indirectly causing this dependency requirement. But we’re not sure why this is now required, especially since the native Android code hasn’t been touched.

Questions:

  1. What could cause the Android project to suddenly require com.google.android.exoplayer after updating the Flutter module?
  2. Could this be coming from a Flutter plugin or package that was added or updated?
Share Improve this question asked Mar 31 at 4:29 Rajitha PereraRajitha Perera 1,6415 gold badges27 silver badges45 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

I did some investigation about this.

After updating the Flutter SDK, I think that the video_player plugin (which uses ExoPlayer) started requiring us to manually declare the ExoPlayer dependency:

implementation 'com.google.android.exoplayer:exoplayer:2.18.7'

BTW they didn’t mention this requirement clearly in the change log.So this might be tied to internal changes in how dependencies are handled.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论