Skip to content

[pigeon] Regression in number handing on Android #155512

@vanyasem

Description

@vanyasem

What package does this bug report belong to?

pigeon

What target platforms are you seeing this bug on?

Android

Have you already upgraded your packages?

Yes

Dependency versions

pigeon: ^22.4.0

Steps to reproduce

  1. Configure pigeons to generate Messages.java for Android
  2. Add a function that takes an integer as a parameter to messages.dart
  3. Generate pigeons
  4. Implement the generated interface from Messages.java in native plugin's kotlin source code
  5. Call the method from Flutter

Expected results

The native function gets executed, and the integer is passed from Flutter to Kotlin

Actual results

The native function does not get executed, and instead an exception is thrown: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Long (see full log under "Logs" section)

It appears to be a regression caused by this pull request: flutter/packages#7392, which was made in response to this issue #136111

pigeon: ^21.2.0 does not suffer from such an issue
pigeon: ^22.0.0 and all versions above do suffer from such an issue

Code sample

I have created a repository with a reproducible example: https://github.com/vanyasem/pigeon-bug

Logs

Logs
E/BasicMessageChannel#dev.flutter.pigeon.pigeon_bug.IntPigeonBugApi.testIntFunction(26398): Failed to handle message
E/BasicMessageChannel#dev.flutter.pigeon.pigeon_bug.IntPigeonBugApi.testIntFunction(26398): java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Long
E/BasicMessageChannel#dev.flutter.pigeon.pigeon_bug.IntPigeonBugApi.testIntFunction(26398): 	at com.example.pigeon_bug.Messages$IntPigeonBugApi$-CC.lambda$setUp$0(Messages.java:106)
E/BasicMessageChannel#dev.flutter.pigeon.pigeon_bug.IntPigeonBugApi.testIntFunction(26398): 	at com.example.pigeon_bug.Messages$IntPigeonBugApi$$ExternalSyntheticLambda0.onMessage(Unknown Source:2)
E/BasicMessageChannel#dev.flutter.pigeon.pigeon_bug.IntPigeonBugApi.testIntFunction(26398): 	at io.flutter.plugin.common.BasicMessageChannel$IncomingMessageHandler.onMessage(BasicMessageChannel.java:261)
E/BasicMessageChannel#dev.flutter.pigeon.pigeon_bug.IntPigeonBugApi.testIntFunction(26398): 	at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:292)
E/BasicMessageChannel#dev.flutter.pigeon.pigeon_bug.IntPigeonBugApi.testIntFunction(26398): 	at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
E/BasicMessageChannel#dev.flutter.pigeon.pigeon_bug.IntPigeonBugApi.testIntFunction(26398): 	at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
E/BasicMessageChannel#dev.flutter.pigeon.pigeon_bug.IntPigeonBugApi.testIntFunction(26398): 	at android.os.Handler.handleCallback(Handler.java:959)
E/BasicMessageChannel#dev.flutter.pigeon.pigeon_bug.IntPigeonBugApi.testIntFunction(26398): 	at android.os.Handler.dispatchMessage(Handler.java:100)
E/BasicMessageChannel#dev.flutter.pigeon.pigeon_bug.IntPigeonBugApi.testIntFunction(26398): 	at android.os.Looper.loopOnce(Looper.java:232)
E/BasicMessageChannel#dev.flutter.pigeon.pigeon_bug.IntPigeonBugApi.testIntFunction(26398): 	at android.os.Looper.loop(Looper.java:317)
E/BasicMessageChannel#dev.flutter.pigeon.pigeon_bug.IntPigeonBugApi.testIntFunction(26398): 	at android.app.ActivityThread.main(ActivityThread.java:8592)
E/BasicMessageChannel#dev.flutter.pigeon.pigeon_bug.IntPigeonBugApi.testIntFunction(26398): 	at java.lang.reflect.Method.invoke(Native Method)
E/BasicMessageChannel#dev.flutter.pigeon.pigeon_bug.IntPigeonBugApi.testIntFunction(26398): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
E/BasicMessageChannel#dev.flutter.pigeon.pigeon_bug.IntPigeonBugApi.testIntFunction(26398): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:878)
E/flutter (26398): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(channel-error, Unable to establish connection on channel: "dev.flutter.pigeon.pigeon_bug.IntPigeonBugApi.testIntFunction"., null, null)
E/flutter (26398): #0      IntPigeonBugApi.testIntFunction (package:pigeon_bug/messages.g.dart:46:7)
E/flutter (26398): <asynchronous suspension>
E/flutter (26398): #1      _MyAppState._testInt (package:pigeon_bug_example/main.dart:38:5)
E/flutter (26398): <asynchronous suspension>
E/flutter (26398): 

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.24.3, on macOS 15.0 24A335 darwin-x64, locale en-US)
    • Flutter version 3.24.3 on channel stable at /Users/vanyasem/fvm/versions/3.24.3
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 2663184aa7 (11 days ago), 2024-09-11 16:27:48 -0500
    • Engine revision 36335019a8
    • Dart version 3.5.3
    • DevTools version 2.37.3

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/vanyasem/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.0)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16A242d
    • CocoaPods version 1.15.2

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

[✓] Android Studio (version 2024.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 17.0.11+0-17.0.11b1207.24-11852314)

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

[✓] Connected device (6 available)
    -- Android/iOS devices redacted for privacy reasons --
    • macOS (desktop)        • macos                     • darwin-x64     • macOS 15.0 24A335 darwin-x64
    • Chrome (web)           • chrome                    • web-javascript • Google Chrome 129.0.6668.59

[✓] Network resources
    • All expected network resources are available.

Metadata

Metadata

Assignees

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