plus_plugins icon indicating copy to clipboard operation
plus_plugins copied to clipboard

[Bug]: Device Info Plus not building anymore

Open FilledStacks opened this issue 1 year ago • 14 comments

Platform

Android

Plugin

device_info_plus

Version

^3.2.3

Flutter SDK

3.0.5

Steps to reproduce

Try to run the app after doing flutter pub upgrade

I get the example.

../../../../src/flutter/.pub-cache/hosted/pub.dartlang.org/device_info_plus_windows-2.1.1/lib/src/device_info_plus_windows.dart:24:35: Error: Required named parameter 'userName' must be provided.
    final data = WindowsDeviceInfo(
                                  ^
../../../../src/flutter/.pub-cache/hosted/pub.dartlang.org/device_info_plus_platform_interface-2.4.0/lib/model/windows_device_info.dart:12:3: Context: Found this candidate, but the arguments don't match.
  WindowsDeviceInfo({
  ^^^^^^^^^^^^^^^^^

Code Sample

No response

Logs

../../../../src/flutter/.pub-cache/hosted/pub.dartlang.org/device_info_plus_windows-2.1.1/lib/src/device_info_plus_windows.dart:24:35: Error: Required named parameter 'userName' must be provided.
    final data = WindowsDeviceInfo(
                                  ^
../../../../src/flutter/.pub-cache/hosted/pub.dartlang.org/device_info_plus_platform_interface-2.4.0/lib/model/windows_device_info.dart:12:3: Context: Found this candidate, but the arguments don't match.
  WindowsDeviceInfo({
  ^^^^^^^^^^^^^^^^^

Flutter Doctor

[✓] Flutter (Channel stable, 3.0.5, on macOS 12.3.1 21E258 darwin-arm, locale en-ZA)
    • Flutter version 3.0.5 at /Users/danemackier/src/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision f1875d570e (4 weeks ago), 2022-07-13 11:24:16 -0700
    • Engine revision e85ea0e79c
    • Dart version 2.17.6
    • DevTools version 2.12.2

[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
    • Android SDK at /Users/danemackier/Library/Android/sdk
    • Platform android-32, build-tools 32.1.0-rc1
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.4.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.3

[✓] 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-7772763)

[✓] VS Code (version 1.70.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.46.0

[✓] Connected device (3 available)
    • SM G960F (mobile) • 2223cc1a36057ece • android-arm64  • Android 10 (API 29)
    • macOS (desktop)   • macos            • darwin-arm64   • macOS 12.3.1 21E258 darwin-arm
    • Chrome (web)      • chrome           • web-javascript • Google Chrome 103.0.5060.134

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

FilledStacks avatar Aug 08 '22 07:08 FilledStacks

Stuck on same

image

GauravCalidig avatar Aug 08 '22 07:08 GauravCalidig

Anyone have a workaround yet? I'm trying to do dependency overrides but nothing is making it pass.

If you find a version that works please post, I have an urgent build to get out.

FilledStacks avatar Aug 08 '22 07:08 FilledStacks

If it's urgent, As a quick workaround you can comment the code giving error. if you are not building a windows app it should work fine @FilledStacks image

GauravCalidig avatar Aug 08 '22 07:08 GauravCalidig

If it's urgent, As a quick workaround you can comment the code giving error. if you are not building a windows app it should work fine @FilledStacks image

Thanks. This works locally. Not when I try and make a release to QA through our CI pipeline. I'll remove the package for now and add it back when this is fixed.

Thanks for the response.

FilledStacks avatar Aug 08 '22 07:08 FilledStacks

same problem

sara010 avatar Aug 08 '22 07:08 sara010

I temporary added overrides to pubspec.yaml, seems to work pretty well :)

dependency_overrides:
  device_info_plus: '4.0.0'
  device_info_plus_platform_interface: '2.3.0+1'

ryzizub avatar Aug 08 '22 08:08 ryzizub

Since we specify the version of device_info_plus directly, I just added this image

xrandy00 avatar Aug 08 '22 08:08 xrandy00

Edit file device_info_plus_windows/lib/src/device_info_plus_windows.dart like this

 @override
  Future<WindowsDeviceInfo> windowsInfo() {
    return Future.value(null);
  }

now, i have avoid it temporarily.

ixre avatar Aug 08 '22 09:08 ixre

We had the same problem. After upgrading to ^4.0.2 it seems to be fixed. Tests as well as local debug building works again

M123-dev avatar Aug 08 '22 09:08 M123-dev

Could you provide exact steps to reproduce the issue?

If I do the following, I can compile the app without issues:

  • Create a flutter project
  • add the device_info_plus dependency with flutter pub add device_info_plus
  • Run the project on Android

All of that works.

miquelbeltran avatar Aug 10 '22 05:08 miquelbeltran

In my case, i do not use device_info_plus itself, but it is a dependency for native_pdf_viewer which i import into my app (i use the lastest stable version of native_pdf_viewer).

Running flutter Pub upgrade did not change anything in my case. Azure pipeline still fails with the same error.

Stachuu87 avatar Aug 10 '22 05:08 Stachuu87

Thanks @Stachuu87 that helps.

I think the problem is that device_info_plus_platform_interface had a breaking change that was not provided inside a major version change. So apps depending on older versions of device_info_plus will break.

I will see if I can reproduce this issue and find a solution that doesn't break old clients.

miquelbeltran avatar Aug 10 '22 05:08 miquelbeltran

I have reverted the breaking change in device_info_plus_platform_interface and republished under:

device_info_plus_platform_interface    2.5.0
device_info_plus_windows               3.0.3
device_info_plus                       4.0.3

Please let me know if you still have the same issue

miquelbeltran avatar Aug 10 '22 05:08 miquelbeltran

I have reverted the breaking change in device_info_plus_platform_interface and republished under:


device_info_plus_platform_interface    2.5.0

device_info_plus_windows               3.0.3

device_info_plus                       4.0.3

Please let me know if you still have the same issue

It seems to work just fine for me. Thanks for such a quick response.

Stachuu87 avatar Aug 10 '22 07:08 Stachuu87

I have reverted the breaking change in device_info_plus_platform_interface and republished under:

device_info_plus_platform_interface    2.5.0
device_info_plus_windows               3.0.3
device_info_plus                       4.0.3

Please let me know if you still have the same issue

@miquelbeltran It doesn't work in my case. It always gives error (Null check operator used on a null value). This is the code:

class Device extends GetxController {
  static final DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin();

  Future<Map<String, dynamic>> getDevice() async {
    Map<String, dynamic>? map;
    try {
      if (Platform.isAndroid) {
        map = _readAndroidBuildData(await deviceInfoPlugin.androidInfo);
      } else if (Platform.isIOS) {
        map = _readIosDeviceInfo(await deviceInfoPlugin.iosInfo);
      }
    } on PlatformException catch (e) {
      map = {
        "title": "Dart Package Failure",
        "message": e.toString(),
        "error": "Current dart package (device_info_plus) failed to get data.",
      };
      Get.offAll(() => AppError(title: map!['title'], message: map['message'], error: map['error']));
    }
    return map!;
  }

  Map<String, dynamic> _readAndroidBuildData(AndroidDeviceInfo build) {
    return <String, dynamic>{
      'version.securityPatch': build.version.securityPatch,
      'version.sdkInt': build.version.sdkInt,
      'version.release': build.version.release,
      'version.previewSdkInt': build.version.previewSdkInt,
      'version.incremental': build.version.incremental,
      'version.codename': build.version.codename,
      'version.baseOS': build.version.baseOS,
      'board': build.board,
      'bootloader': build.bootloader,
      'brand': build.brand,
      'device': build.device,
      'display': build.display,
      'fingerprint': build.fingerprint,
      'hardware': build.hardware,
      'host': build.host,
      'id': build.id,
      'manufacturer': build.manufacturer,
      'model': build.model,
      'product': build.product,
      'supported32BitAbis': build.supported32BitAbis,
      'supported64BitAbis': build.supported64BitAbis,
      'supportedAbis': build.supportedAbis,
      'tags': build.tags,
      'type': build.type,
      'isPhysicalDevice': build.isPhysicalDevice,
      'systemFeatures': build.systemFeatures,
    };
  }

  Map<String, dynamic> _readIosDeviceInfo(IosDeviceInfo data) {
    return <String, dynamic>{
      'name': data.name,
      'systemName': data.systemName,
      'systemVersion': data.systemVersion,
      'model': data.model,
      'localizedModel': data.localizedModel,
      'identifierForVendor': data.identifierForVendor,
      'isPhysicalDevice': data.isPhysicalDevice,
      'utsname.sysname:': data.utsname.sysname,
      'utsname.nodename:': data.utsname.nodename,
      'utsname.release:': data.utsname.release,
      'utsname.version:': data.utsname.version,
      'utsname.machine:': data.utsname.machine,
    };
  }
}

This is the pubspec.yaml:

dependencies:
  device_info_plus: 4.0.3
dependency_overrides:
  device_info_plus: 4.0.3
  device_info_plus_platform_interface: 2.5.0

SS - Device Info Plus 4 0 3 on 2022-08-13 181934

Is there something wrong with github? Or dart pub.dev? This happens since today. It used to be okay. I replaced it with device_info_plus: 3.2.4 to 4.0.3, but it still gives same error as above.

If you see the image, you can know that the function really get the device data on the left stack, exactly on variable device. This behavior is very strange. You can get the value of device, but it gives error (Null check operator used on a null value). I meant, I had removed "andoidId" when it got error. But, it still returned same error. I never changed any code inside this function. Why does it give that error? I never even replaced the variables.

This is the stack value:

#0 Cloud.checkDevice.<anonymous closure> (package:sim_had/library/controller/service/firebase.dart:517:15)
#1 Cloud.checkDevice.<anonymous closure> (package:sim_had/library/controller/service/firebase.dart:513:36)
#2  _rootRunUnary (dart:async/zone.dart:1434:47)
#3  _CustomZone.runUnary (dart:async/zone.dart:1335:19)
<asynchronous suspension>
#4 Cloud.checkDevice (package:sim_had/library/controller/service/firebase.dart:513:7)
<asynchronous suspension>
#5 Cloud.signInWithGoogle.<anonymous closure> (package:sim_had/library/controller/service/firebase.dart:91:13)
<asynchronous suspension>
#6 Cloud.signInWithGoogle (package:sim_had/library/controller/service/firebase.dart:88:9)
<asynchronous suspension>
#7 SignIn.build.<anonymous closure> (package:sim_had/menu/signin.dart:35:17)
<asynchronous suspension>

Update: Sorry, the package is working up now. Since the error just appeared, I changed the variable and forgot that I had to copy data response from checkDevice to another late Map variable. So, sorry. I used the latest one: 4.1.0. No problem at all.

Thank you Flutter team.

gOzaru avatar Aug 13 '22 10:08 gOzaru

Thank you Flutter team.

No worries!

Just to be clear, we are NOT part of the Flutter Team/Google/etc. and we are not sponsored by them in any way (or at least, I am not, lol). These plugins are run by independent volunteers on our free time, so we need both help and patience from the rest of the community to be able to do so.

Since this issue seems to be solved, I am closing the ticket now. Please for any new issues check the existing open tickers or open a new ticket.

miquelbeltran avatar Aug 14 '22 08:08 miquelbeltran