Skip to content

[Bug] [Battery_Plus]: PlatformException - Parameter specified as non-null is null #1119

@Anas35

Description

@Anas35

Platform

Android 11

Plugin

Battery_plus

Version

2.2.0

Flutter SDK

3.3.3

Steps to reproduce

  1. Clone battery_plus
  2. Run Example code

Error logs:

Failed to open event stream
E/EventChannel#dev.fluttercommunity.plus/charging( 5479): java.lang.NullPointerException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkNotNullParameter, parameter arguments
E/EventChannel#dev.fluttercommunity.plus/charging( 5479): at dev.fluttercommunity.plus.battery.BatteryPlusPlugin.onListen(BatteryPlusPlugin.kt)
E/EventChannel#dev.fluttercommunity.plus/charging( 5479): at io.flutter.plugin.common.EventChannel$IncomingStreamRequestHandler.onListen(EventChannel.java:218)
E/EventChannel#dev.fluttercommunity.plus/charging( 5479): at io.flutter.plugin.common.EventChannel$IncomingStreamRequestHandler.onMessage(EventChannel.java:197)
E/EventChannel#dev.fluttercommunity.plus/charging( 5479): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
E/EventChannel#dev.fluttercommunity.plus/charging( 5479): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
E/EventChannel#dev.fluttercommunity.plus/charging( 5479): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(D8$$SyntheticClass)
E/EventChannel#dev.fluttercommunity.plus/charging( 5479): at android.os.Handler.handleCallback(Handler.java:751)
E/EventChannel#dev.fluttercommunity.plus/charging( 5479): at android.os.Handler.dispatchMessage(Handler.java:95)
E/EventChannel#dev.fluttercommunity.plus/charging( 5479): at android.os.Looper.loop(Looper.java:154)
E/EventChannel#dev.fluttercommunity.plus/charging( 5479): at android.app.ActivityThread.main(ActivityThread.java:6077)
E/EventChannel#dev.fluttercommunity.plus/charging( 5479): at java.lang.reflect.Method.invoke(Native Method)
E/EventChannel#dev.fluttercommunity.plus/charging( 5479): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
E/EventChannel#dev.fluttercommunity.plus/charging( 5479): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)

════════ Exception caught by services library ══════════════════════════════════
The following PlatformException was thrown while activating platform stream on channel dev.fluttercommunity.plus/charging:
PlatformException(error, Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkNotNullParameter, parameter arguments, null, null)

When the exception was thrown, this was the stack
#0 StandardMethodCodec.decodeEnvelope
package:flutter/…/services/message_codecs.dart:653
#1 MethodChannel._invokeMethod
package:flutter/…/services/platform_channel.dart:296

#2 EventChannel.receiveBroadcastStream.
package:flutter/…/services/platform_channel.dart:637

Code Sample

No response

Logs

[ +792 ms] √  Built build\app\outputs\flutter-apk\app-debug.apk.
[   +3 ms] executing: C:\Users\moham\AppData\Local\Android\sdk\build-tools\33.0.0\aapt dump xmltree
C:\Users\moham\source\plus_plugins\packages\battery_plus\battery_plus\example\build\app\outputs\flutter-apk\app.apk
AndroidManifest.xml
[  +64 ms] Exit code 0 from: C:\Users\moham\AppData\Local\Android\sdk\build-tools\33.0.0\aapt dump xmltree
C:\Users\moham\source\plus_plugins\packages\battery_plus\battery_plus\example\build\app\outputs\flutter-apk\app.apk
AndroidManifest.xml
[   +1 ms] N: android=http://schemas.android.com/apk/res/android
             E: manifest (line=2)
               A: android:versionCode(0x0101021b)=(type 0x10)0x1
               A: android:versionName(0x0101021c)="1.0" (Raw: "1.0")
               A: android:compileSdkVersion(0x01010572)=(type 0x10)0x21
               A: android:compileSdkVersionCodename(0x01010573)="13" (Raw: "13")
               A: package="io.flutter.plugins.batteryexample.example" (Raw: "io.flutter.plugins.batteryexample.example")
               A: platformBuildVersionCode=(type 0x10)0x21
               A: platformBuildVersionName=(type 0x10)0xd
               E: uses-sdk (line=7)
                 A: android:minSdkVersion(0x0101020c)=(type 0x10)0x10
                 A: android:targetSdkVersion(0x01010270)=(type 0x10)0x21
               E: uses-permission (line=14)
                 A: android:name(0x01010003)="android.permission.INTERNET" (Raw: "android.permission.INTERNET")
               E: application (line=22)
                 A: android:label(0x01010001)="example" (Raw: "example")
                 A: android:icon(0x01010002)=@0x7f080000
                 A: android:name(0x01010003)="android.app.Application" (Raw: "android.app.Application")
                 A: android:debuggable(0x0101000f)=(type 0x12)0xffffffff
                 A: android:appComponentFactory(0x0101057a)="androidx.core.app.CoreComponentFactory" (Raw:
                 "androidx.core.app.CoreComponentFactory")
                 E: activity (line=28)
                   A: android:theme(0x01010000)=@0x7f0a0000
                   A: android:name(0x01010003)="io.flutter.plugins.batteryexample.example.MainActivity" (Raw:
                   "io.flutter.plugins.batteryexample.example.MainActivity")
                   A: android:exported(0x01010010)=(type 0x12)0xffffffff
                   A: android:launchMode(0x0101001d)=(type 0x10)0x1
                   A: android:configChanges(0x0101001f)=(type 0x11)0x40003fb4
                   A: android:windowSoftInputMode(0x0101022b)=(type 0x11)0x10
                   A: android:hardwareAccelerated(0x010102d3)=(type 0x12)0xffffffff
                   E: meta-data (line=43)
                     A: android:name(0x01010003)="io.flutter.embedding.android.NormalTheme" (Raw:
                     "io.flutter.embedding.android.NormalTheme")
                     A: android:resource(0x01010025)=@0x7f0a0001
                   E: meta-data (line=53)
                     A: android:name(0x01010003)="io.flutter.embedding.android.SplashScreenDrawable" (Raw:
                     "io.flutter.embedding.android.SplashScreenDrawable")
                     A: android:resource(0x01010025)=@0x7f040000
                   E: intent-filter (line=57)
                     E: action (line=58)
                       A: android:name(0x01010003)="android.intent.action.MAIN" (Raw: "android.intent.action.MAIN")
                     E: category (line=60)
                       A: android:name(0x01010003)="android.intent.category.LAUNCHER" (Raw: "android.intent.category.LAUNCHER")      
                 E: meta-data (line=67)
                   A: android:name(0x01010003)="flutterEmbedding" (Raw: "flutterEmbedding")
                   A: android:value(0x01010024)=(type 0x10)0x2
                 E: uses-library (line=71)
                   A: android:name(0x01010003)="androidx.window.extensions" (Raw: "androidx.window.extensions")
                   A: android:required(0x0101028e)=(type 0x12)0x0
                 E: uses-library (line=74)
                   A: android:name(0x01010003)="androidx.window.sidecar" (Raw: "androidx.window.sidecar")
                   A: android:required(0x0101028e)=(type 0x12)0x0
[  +12 ms] Stopping app 'app.apk' on sdk gphone x86.
[   +1 ms] executing: C:\Users\moham\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 shell am force-stop
io.flutter.plugins.batteryexample.example
[ +112 ms] executing: C:\Users\moham\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 shell pm list packages
io.flutter.plugins.batteryexample.example
[  +87 ms] package:io.flutter.plugins.batteryexample.example
[   +1 ms] executing: C:\Users\moham\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 shell cat
/data/local/tmp/sky.io.flutter.plugins.batteryexample.example.sha1
[  +79 ms] 16ef0887c7ac79273cb76881b0a1907c32b1de67
[   +1 ms] Installing APK.
[   +1 ms] Installing build\app\outputs\flutter-apk\app.apk...
[        ] executing: C:\Users\moham\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 install -t -r
C:\Users\moham\source\plus_plugins\packages\battery_plus\battery_plus\example\build\app\outputs\flutter-apk\app.apk
[+1024 ms] Performing Streamed Install
                    Success
[   +2 ms] Installing build\app\outputs\flutter-apk\app.apk... (completed in 1,025ms)
[   +2 ms] executing: C:\Users\moham\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 shell echo -n
00e11534375c16fe0a167bdac309f1ad49523397 > /data/local/tmp/sky.io.flutter.plugins.batteryexample.example.sha1
[ +217 ms] executing: C:\Users\moham\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 shell -x logcat -v time -t 1
[ +173 ms] --------- beginning of main
                    09-30 22:01:23.571 I/Finsky  (20882): [2] qhv.n(8): Invalidating cached PackageState for
                    io.flutter.plugins.batteryexample.example
[  +11 ms] executing: C:\Users\moham\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 shell am start -a
android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x20000000 --ez enable-dart-profiling true --ez enable-checked-modetrue --ez verify-entry-points true io.flutter.plugins.batteryexample.example/io.flutter.plugins.batteryexample.example.MainActivity  
[ +781 ms] Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x20000000
cmp=io.flutter.plugins.batteryexample.example/.MainActivity (has extras) }
[   +2 ms] Waiting for observatory port to be available...
[+3090 ms] W/FlutterActivityAndFragmentDelegate(21504): A splash screen was provided to Flutter, but this is deprecated. See
flutter.dev/go/android-splash-migration for migration steps.
[ +133 ms] Observatory URL on device: http://127.0.0.1:44267/cNppplxf1lM=/
[   +2 ms] executing: C:\Users\moham\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 forward tcp:0 tcp:44267
[ +104 ms] 57845
[   +1 ms] Forwarded host port 57845 to device port 44267 for Observatory
[   +9 ms] Caching compiled dill
[  +71 ms] Connecting to service protocol: http://127.0.0.1:57845/cNppplxf1lM=/
[ +917 ms] Launching a Dart Developer Service (DDS) instance at http://127.0.0.1:0, connecting to VM service at
http://127.0.0.1:57845/cNppplxf1lM=/.
[ +287 ms] DDS is listening at http://127.0.0.1:57848/GtbUOfQeQwo=/.
[ +100 ms] Successfully connected to service protocol: http://127.0.0.1:57845/cNppplxf1lM=/
[ +140 ms] DevFS: Creating new filesystem on the device (null)
[  +72 ms] DevFS: Created new filesystem on the device
(file:///data/user/0/io.flutter.plugins.batteryexample.example/code_cache/exampleRILXZC/example/)
[   +5 ms] Updating assets
[ +265 ms] Syncing files to device sdk gphone x86...
[   +8 ms] Compiling dart to kernel with 0 updated files
[  +15 ms] Processing bundle.
[   +9 ms] <- recompile package:battery_plus_example/main.dart 4a229dce-7884-46c6-8c93-c34bf8db76a6
[  +26 ms] <- 4a229dce-7884-46c6-8c93-c34bf8db76a6
[  +36 ms] Bundle processing done.
[ +183 ms] Updating files.
[        ] DevFS: Sync finished
[   +1 ms] Syncing files to device sdk gphone x86... (completed in 279ms)
[  +31 ms] Synced 0.0MB.
[  +25 ms] <- accept
[  +39 ms] Connected to _flutterView/0xebf04ec0.
[  +14 ms] Flutter run key commands.
[  +27 ms] r Hot reload. 
[   +1 ms] R Hot restart.
[   +2 ms] h List all available interactive commands.
[   +1 ms] d Detach (terminate "flutter run" but leave application running).
[   +2 ms] c Clear the screen
[   +2 ms] q Quit (terminate the application on the device).
[  +13 ms]  Running with sound null safety 
[   +5 ms] An Observatory debugger and profiler on sdk gphone x86 is available at: http://127.0.0.1:57848/GtbUOfQeQwo=/
[+1058 ms] E/EventChannel#dev.fluttercommunity.plus/charging(21504): Failed to open event stream
[   +1 ms] E/EventChannel#dev.fluttercommunity.plus/charging(21504): java.lang.NullPointerException: Parameter specified as non-null
is null: method kotlin.jvm.internal.Intrinsics.checkNotNullParameter, parameter arguments
[   +1 ms] E/EventChannel#dev.fluttercommunity.plus/charging(21504):    at
dev.fluttercommunity.plus.battery.BatteryPlusPlugin.onListen(Unknown Source:2)
[   +1 ms] E/EventChannel#dev.fluttercommunity.plus/charging(21504):    at
io.flutter.plugin.common.EventChannel$IncomingStreamRequestHandler.onListen(EventChannel.java:218)
[   +4 ms] E/EventChannel#dev.fluttercommunity.plus/charging(21504):    at
io.flutter.plugin.common.EventChannel$IncomingStreamRequestHandler.onMessage(EventChannel.java:197)
[   +1 ms] E/EventChannel#dev.fluttercommunity.plus/charging(21504):    at
io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
[   +1 ms] E/EventChannel#dev.fluttercommunity.plus/charging(21504):    at
io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
[   +7 ms] E/EventChannel#dev.fluttercommunity.plus/charging(21504):    at
io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
[   +5 ms] E/EventChannel#dev.fluttercommunity.plus/charging(21504):    at android.os.Handler.handleCallback(Handler.java:938)       
[        ] E/EventChannel#dev.fluttercommunity.plus/charging(21504):    at android.os.Handler.dispatchMessage(Handler.java:99)       
[   +1 ms] E/EventChannel#dev.fluttercommunity.plus/charging(21504):    at android.os.Looper.loop(Looper.java:223)
[   +1 ms] E/EventChannel#dev.fluttercommunity.plus/charging(21504):    at android.app.ActivityThread.main(ActivityThread.java:7656) 
[   +2 ms] E/EventChannel#dev.fluttercommunity.plus/charging(21504):    at java.lang.reflect.Method.invoke(Native Method)
[        ] E/EventChannel#dev.fluttercommunity.plus/charging(21504):    at
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
[   +2 ms] E/EventChannel#dev.fluttercommunity.plus/charging(21504):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
[+1353 ms]
                    ══╡ EXCEPTION CAUGHT BY SERVICES LIBRARY ╞══════════════════════════════════════════════════════════
                    The following PlatformException was thrown while activating platform stream on channel
                    dev.fluttercommunity.plus/charging:
                    PlatformException(error, Parameter specified as non-null is null: method
                    kotlin.jvm.internal.Intrinsics.checkNotNullParameter, parameter arguments, null, null)

                    When the exception was thrown, this was the stack:
                    #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:653:7)
                    #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:296:18)
                    <asynchronous suspension>
                    #2      EventChannel.receiveBroadcastStream.<anonymous closure>
(package:flutter/src/services/platform_channel.dart:637:9)
                    <asynchronous suspension>
                    ════════════════════════════════════════════════════════════════════════════════════════════════════
[ +164 ms] The Flutter DevTools debugger and profiler on sdk gphone x86 is available at:
                    http://127.0.0.1:9101?uri=http://127.0.0.1:57848/GtbUOfQeQwo=/

Flutter Doctor

flutter doctor -v
[√] Flutter (Channel stable, 3.3.3, on Microsoft Windows [Version 10.0.19043.2006], locale en-IN)
    • Flutter version 3.3.3 on channel stable at C:\src\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 18a827f393 (2 days ago), 2022-09-28 10:03:14 -0700
    • Engine revision 5c984c26eb
    • Dart version 2.18.2
    • DevTools version 2.15.0

Checking Android licenses is taking an unexpectedly long time...[√] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at C:\Users\moham\AppData\Local\Android\sdk
    • Platform android-33, build-tools 33.0.0
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\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 2021.2)
    • 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.12+7-b1504.28-7817840)

[√] IntelliJ IDEA Community Edition (version 2022.1)
    • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2022.1.4
    • 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

[√] VS Code (version 1.71.2)
    • VS Code at C:\Users\moham\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.48.0

[√] Connected device (4 available)
    • sdk gphone x86 (mobile) • emulator-5554 • android-x86    • Android 11 (API 30) (emulator)
    • Windows (desktop)       • windows       • windows-x64    • Microsoft Windows [Version 10.0.19043.2006]
    • Chrome (web)            • chrome        • web-javascript • Google Chrome 104.0.5112.81
    • Edge (web)              • edge          • web-javascript • Microsoft Edge 105.0.1343.42

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

Checklist before submitting a bug

  • I Google'd a solution and I couldn't find it
  • [-] I searched on StackOverflow for a solution and I couldn't find it
  • I read the README.md file of the plugin
  • I'm using the latest version of the plugin
  • All dependencies are up to date with flutter pub upgrade
  • I did a flutter clean
  • I tried running the example project

Metadata

Metadata

Assignees

No one assigned

    Labels

    HacktoberfestIssues taking part in HacktoberfestbugSomething isn't workingtriage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions