Skip to content

[device_info] null safety version crashes for apps that opt into null safety #76194

Closed
flutter/plugins
#3609
@MaikuB

Description

@MaikuB

Steps to Reproduce

  1. Update example app for device_info plugin to opt into null safety by changing the SDK constraints
  2. Run app on Android and app crashes

Note: I have fork with these changes that can reproduce the issue at https://github.com/MaikuB/plugins/tree/null_safety_device_info_crash/packages/device_info/device_info. Another observation is that going to the directory of the example app to run the integration test by running the following command

flutter drive \
  --driver=test_driver/integration_test.dart \
  --target=integration_test/device_info_test.dart

does not indicate failure. In fact, all tests are reported to have passed.

Expected results:

Able to receive info on the device

Actual results:

App crashes, it looks like platform channel is receiving null values from the native side

Logs
[ +707 ms] I/flutter ( 6978): type 'Null' is not a subtype of type 'String'
[        ] I/flutter ( 6978): #0      new List.from (dart:core-patch/array_patch.dart:40:5)
[        ] I/flutter ( 6978): #1      AndroidDeviceInfo._fromList (package:device_info_platform_interface/model/android_device_info.dart:144:12)
[        ] I/flutter ( 6978): #2      AndroidDeviceInfo.fromMap (package:device_info_platform_interface/model/android_device_info.dart:137:23)
[        ] I/flutter ( 6978): #3      MethodChannelDeviceInfo.androidInfo (package:device_info_platform_interface/method_channel/method_channel_device_info.dart:16:30)
[        ] I/flutter ( 6978): <asynchronous suspension>
[        ] I/flutter ( 6978): #4      DeviceInfoPlugin.androidInfo (package:device_info/device_info.dart:25:11)
[        ] I/flutter ( 6978): <asynchronous suspension>
[        ] I/flutter ( 6978): #5      _MyAppState.initPlatformState (package:device_info_example/main.dart:43:44)
[✓] Flutter (Channel beta, 1.26.0-17.6.pre, on macOS 11.2.1 20D74 darwin-x64,
    locale en-AU)
    • Flutter version 1.26.0-17.6.pre at /Users/michaelbui/flutter
    • Framework revision a29104a69b (17 hours ago), 2021-02-16 09:26:56 -0800
    • Engine revision 21fa8bb99e
    • Dart version 2.12.0 (build 2.12.0-259.12.beta)

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /Users/michaelbui/Library/Android/sdk
    • Platform android-30, build-tools 30.0.2
    • Java binary at: /Applications/Android
      Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.4, Build version 12D4e
    • CocoaPods version 1.10.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.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
      1.8.0_242-release-1644-b3-6915495)

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

[✓] Connected device (2 available)
    • sdk gphone x86 (mobile) • emulator-5554 • android-x86    • Android 11 (API
      30) (emulator)
    • Chrome (web)            • chrome        • web-javascript • Google Chrome
      88.0.4324.182

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work lista: null-safetySupport for Dart's null safety featurec: crashStack traces logged to the consolefound in release: 1.26Found to occur in 1.26has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: device_infoPlugin to access device informationpackageflutter/packages repository. See also p: labels.r: fixedIssue is closed as already fixed in a newer version

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions