plus_plugins icon indicating copy to clipboard operation
plus_plugins copied to clipboard

[Bug]: package_info_plus is not reading package info in Linux (using flutter-pi)

Open eximius313 opened this issue 3 years ago • 13 comments

Platform

Linux (using flutter-pi)

Plugin

package_info_plus

Version

1.4.2

Flutter SDK

3.0.1

Steps to reproduce

While package_info_plus works perfectly on the emulator, it does not show anything in Linux (using flutter-pi) although version 1.4.2 claims that it supports Linux

Steps to reproduce:

  1. flutter build bundle
  2. scp -r ./build/flutter_assets/ pi@IP:~

In "development mode": $flutter-pi flutter_assets/ and it shows version: + (so neither version nor buildNumber is read).

In "release mode" $flutter-pi --release flutter_assets/ it throws:

[ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: MissingPluginException(No implementation found for method getAll on channel dev.fluttercommunity.plus/package_info)
#0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:165)
<asynchronous suspension>
#1      MethodChannel.invokeMapMethod (package:flutter/src/services/platform_channel.dart:367)
<asynchronous suspension>
#2      MethodChannelPackageInfo.getAll (package:package_info_plus_platform_interface/method_channel_package_info.dart:13)

Code Sample

void main() async {
  WidgetsBinding bindings = WidgetsFlutterBinding.ensureInitialized();
  
  final PackageInfo packageInfo = await PackageInfo.fromPlatform();
  print("version: ${packageInfo.version}+${packageInfo.buildNumber}");
  runApp(MyApp());
}


### Logs

```shell
[locales] Warning: The system has no configured locale. The default "C" locale may or may not be supported by the app.
[flutter-pi] WARNING: display didn't provide valid physical dimensions. The device-pixel ratio will default to 1.0, which may not be the fitting device-pixel ratio for your display.
==============Locale==============
Flutter locale:
  default: C
  locales: C
===================================
===================================
display mode:
  resolution: 1920 x 1080
  refresh rate: 60Hz
  physical size: 0mm x 0mm
  flutter device pixel ratio: 1.000000
===================================
error: XDG_RUNTIME_DIR not set in the environment.
EGL information:
  version: 1.4
  vendor: "Mesa Project"
  client extensions: "EGL_EXT_device_base EGL_EXT_device_enumeration EGL_EXT_device_query EGL_EXT_platform_base EGL_KHR_client_get_all_proc_addresses EGL_EXT_client_extensions EGL_KHR_debug EGL_EXT_platform_device EGL_EXT_platform_wayland EGL_KHR_platform_wayland EGL_EXT_platform_x11 EGL_KHR_platform_x11 EGL_MESA_platform_gbm EGL_KHR_platform_gbm EGL_MESA_platform_surfaceless"
  display extensions: "EGL_ANDROID_blob_cache EGL_EXT_buffer_age EGL_EXT_image_dma_buf_import EGL_EXT_image_dma_buf_import_modifiers EGL_KHR_cl_event2 EGL_KHR_config_attribs EGL_KHR_create_context EGL_KHR_create_context_no_error EGL_KHR_fence_sync EGL_KHR_get_all_proc_addresses EGL_KHR_gl_colorspace EGL_KHR_gl_renderbuffer_image EGL_KHR_gl_texture_2D_image EGL_KHR_gl_texture_3D_image EGL_KHR_gl_texture_cubemap_image EGL_KHR_image EGL_KHR_image_base EGL_KHR_image_pixmap EGL_KHR_no_config_context EGL_KHR_reusable_sync EGL_KHR_surfaceless_context EGL_EXT_pixel_format_float EGL_KHR_wait_sync EGL_MESA_configless_context EGL_MESA_drm_image EGL_MESA_image_dma_buf_export EGL_MESA_query_driver EGL_WL_bind_wayland_display "
===================================
OpenGL ES information:
  version: "OpenGL ES 3.1 Mesa 20.3.5"
  shading language version: "OpenGL ES GLSL ES 3.10"
  vendor: "Broadcom"
  renderer: "V3D 4.2"
  extensions: "GL_EXT_blend_minmax GL_EXT_multi_draw_arrays GL_EXT_texture_filter_anisotropic GL_EXT_texture_compression_s3tc GL_EXT_texture_compression_dxt1 GL_EXT_texture_format_BGRA8888 GL_OES_compressed_ETC1_RGB8_texture GL_OES_depth24 GL_OES_element_index_uint GL_OES_fbo_render_mipmap GL_OES_mapbuffer GL_OES_rgb8_rgba8 GL_OES_standard_derivatives GL_OES_stencil8 GL_OES_texture_3D GL_OES_texture_float GL_OES_texture_half_float GL_OES_texture_half_float_linear GL_OES_texture_npot GL_OES_vertex_half_float GL_EXT_draw_instanced GL_EXT_texture_sRGB_decode GL_OES_EGL_image GL_OES_depth_texture GL_OES_packed_depth_stencil GL_EXT_texture_type_2_10_10_10_REV GL_OES_get_program_binary GL_APPLE_texture_max_level GL_EXT_discard_framebuffer GL_EXT_read_format_bgra GL_EXT_frag_depth GL_NV_fbo_color_attachments GL_OES_EGL_image_external GL_OES_EGL_sync GL_OES_vertex_array_object GL_ANGLE_pack_reverse_row_order GL_ANGLE_texture_compression_dxt3 GL_ANGLE_texture_compression_dxt5 GL_EXT_occlusion_query_boolean GL_EXT_texture_rg GL_EXT_unpack_subimage GL_NV_draw_buffers GL_NV_read_buffer GL_NV_read_depth GL_NV_read_depth_stencil GL_NV_read_stencil GL_EXT_draw_buffers GL_EXT_map_buffer_range GL_KHR_debug GL_KHR_texture_compression_astc_ldr GL_NV_pixel_buffer_object GL_OES_depth_texture_cube_map GL_OES_required_internalformat GL_OES_surfaceless_context GL_EXT_color_buffer_float GL_EXT_sRGB_write_control GL_EXT_separate_shader_objects GL_EXT_shader_implicit_conversions GL_EXT_shader_integer_mix GL_EXT_base_instance GL_EXT_compressed_ETC1_RGB8_sub_texture GL_EXT_draw_elements_base_vertex GL_EXT_primitive_bounding_box GL_EXT_shader_io_blocks GL_EXT_texture_border_clamp GL_EXT_texture_view GL_KHR_context_flush_control GL_NV_image_formats GL_OES_draw_elements_base_vertex GL_OES_primitive_bounding_box GL_OES_shader_io_blocks GL_OES_texture_border_clamp GL_OES_texture_stencil8 GL_OES_texture_storage_multisample_2d_array GL_OES_texture_view GL_EXT_buffer_storage GL_EXT_float_blend GL_EXT_geometry_point_size GL_EXT_geometry_shader GL_KHR_no_error GL_KHR_texture_compression_astc_sliced_3d GL_OES_EGL_image_external_essl3 GL_OES_geometry_point_size GL_OES_geometry_shader GL_OES_shader_image_atomic GL_EXT_texture_compression_s3tc_srgb GL_MESA_shader_integer_functions GL_KHR_parallel_shader_compile GL_EXT_EGL_image_storage GL_MESA_framebuffer_flip_y GL_EXT_texture_query_lod "
===================================
[flutter-pi] Warning: Could not load libflutter_engine.so from the asset bundle. dlopen: /home/user/flutter_assets/libflutter_engine.so: cannot open shared object file: No such file or directory. Trying to open libflutter_engine.so.release...
[ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: MissingPluginException(No implementation found for method getAll on channel dev.fluttercommunity.plus/package_info)
#0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:165)
<asynchronous suspension>
#1      MethodChannel.invokeMapMethod (package:flutter/src/services/platform_channel.dart:367)
<asynchronous suspension>
#2      MethodChannelPackageInfo.getAll (package:package_info_plus_platform_interface/method_channel_package_info.dart:13)


### Flutter Doctor

```shell
$ flutter doctor -v
[√] Flutter (Channel stable, 3.0.1, on Microsoft Windows [Version 10.0.19044.1865], locale pl-PL)
    • Flutter version 3.0.1 at C:\Users\Kamil\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision fb57da5f94 (3 months ago), 2022-05-19 15:50:29 -0700
    • Engine revision caaafc5604
    • Dart version 2.17.1
    • DevTools version 2.12.2

[√] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at C:\Users\User\AppData\Local\Android\sdk
    • Platform android-31, build-tools 31.0.0
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[X] Visual Studio - develop for Windows
    X Visual Studio not installed; this is necessary for Windows development.
      Download at https://visualstudio.microsoft.com/downloads/.
      Please install the "Desktop development with C++" workload, including all of its default components

[√] Android Studio (version 2020.3)
    • Android Studio at C:\Program Files\Android\Android Studio
    • 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.10+0-b96-7249189)

[√] VS Code (version 1.69.2)
    • VS Code at C:\Users\User\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.44.0

[√] Connected device (3 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.19044.1865]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 103.0.5060.134
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 103.0.1264.49

[√] HTTP Host Availability
    • All required HTTP hosts are available

eximius313 avatar Aug 04 '22 11:08 eximius313

It looks like it's related to this method: https://github.com/fluttercommunity/plus_plugins/blob/main/packages/package_info_plus/package_info_plus_platform_interface/lib/method_channel_package_info.dart

It seems that debug mode recognizes it runs on linux and sets PackageInfoPlatform.instance to linux, but release mode doesn't and it defaults to MethodChannelPackageInfo which causes the MissingPluginException

can you please support the flutter-pi platform in both debug and release modes?

eximius313 avatar Aug 18 '22 17:08 eximius313

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 15 days

github-actions[bot] avatar Dec 28 '22 00:12 github-actions[bot]

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 15 days

github-actions[bot] avatar Mar 29 '23 00:03 github-actions[bot]

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 15 days

Issue is still there

eximius313 avatar Mar 29 '23 15:03 eximius313

Hi @eximius313, the problem here is that you are using flutter-pi which ships a non-standard embedder. This package does works in linux, but only supports the official flutter embedder. Supporting third party embedders like flutter-pi also require access to that hardware in order to test etc. My advice would be to encourage you to contribute to solve this issue. I don't know if the solution lies in the flutter-pi embedder communicating its platform in a way that this package recognizes as linux, or changing the inner workings of this package to also recognize flutter-pi, without the actual hardware is hard to test.

PS: I'm not a mantainer of this package but I have contributed in the past.

fabiancrx avatar Apr 21 '23 17:04 fabiancrx

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 15 days

github-actions[bot] avatar Jul 21 '23 00:07 github-actions[bot]

@fabiancrx, could you please provide me with any tips on how I could start? Especially how can I check if flutter-pi embedder communicates itself as Linux and/or how to enable this package to recognize flutter-pi embedder?

eximius313 avatar Jul 30 '23 12:07 eximius313

@eximius313 I would not know how to make it work without tinkering with flutter-pi, but I'd start looking to:

  • Test that it works as intended with a standard linux application (just create a sample app and test it works)
  • Then look at the package code and see how it gets the package information
  • Look at how the linux embedder provides that information and try to replicate it on the flutter-pi side.

fabiancrx avatar Jul 31 '23 14:07 fabiancrx

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 15 days

github-actions[bot] avatar Nov 10 '23 00:11 github-actions[bot]

I can confirm this is an issue when using the Yocto project + flutter-wayland-client, as well, but it doesn't appear to be due to the use of a custom embedder (at least in my implementation).

In my implementation, I am have the following function to to get the package info, which explicitly registers the plugin for Linux using PackageInfoPlusLinuxPlugin.registerWith();:

  /// Get the package information.
  Future<PackageInfo> get packageInfo async {
    if (Platform.isLinux) {
      // Register the Linux plugin.
      //
      // Note: this is required to get the package info on embedded Linux. If this
      // is not explicitly called, the package info will attempt to go through
      // the default MethodChannel, which will fail.
      PackageInfoPlusLinuxPlugin.registerWith();
    }

    // Note: there is no need to hold onto the package info, as it is
    // cached by the package_info_plus plugin.
    final PackageInfo info = await PackageInfo.fromPlatform();
    return info;
  }

However, this causes another issue. The Flutter app is being built AOT (flutter build bundle), which does not appear to generate the version.json that the PackageInfoPlusLinuxPlugin is looking for.

I've tested my app locally on Linux, as well. When using the flutter build linux command, I get the following build/flutter_assets contents:

build/flutter_assets
├── AssetManifest.bin
├── AssetManifest.json
├── FontManifest.json
├── fonts
│   └── MaterialIcons-Regular.otf
├── NOTICES.Z
├── shaders
│   └── ink_sparkle.frag
└── version.json

However, when using the flutter build bundle command, I only get the following contents:

build/flutter_assets
├── AssetManifest.bin
├── AssetManifest.json
├── FontManifest.json
├── fonts
│   └── MaterialIcons-Regular.otf
├── isolate_snapshot_data
├── kernel_blob.bin
├── NOTICES.Z
├── shaders
│   └── ink_sparkle.frag
└── vm_snapshot_data

TLDL; should there be another flag or argument specified when using flutter build bundle to generate the version.json file PackageInfoPlusLinuxPlugin is dependent on?

lapumb-spindance avatar Jan 31 '24 16:01 lapumb-spindance

@lapumb-spindance, thank you for this analyis! Quick question - when you use flutter build linux (so that version.json is present in the bundle) does PackageInfoPlusLinuxPlugin work out-of-the-box, or you had to modify its code?

eximius313 avatar Jan 31 '24 17:01 eximius313

Quick question - when you use flutter build linux (so that version.json is present in the bundle) does PackageInfoPlusLinuxPlugin work out-of-the-box, or you had to modify its code?

@eximius313 Yes, it works out of the box when testing locally on Ubuntu.

lapumb-spindance avatar Jan 31 '24 17:01 lapumb-spindance