Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: SharewithResult always returning null in Android #916

Closed
santhoshvgts opened this issue Jun 19, 2022 · 16 comments · Fixed by #1301
Closed

[Bug]: SharewithResult always returning null in Android #916

santhoshvgts opened this issue Jun 19, 2022 · 16 comments · Fixed by #1301
Labels
bug Something isn't working Hacktoberfest Issues taking part in Hacktoberfest triage

Comments

@santhoshvgts
Copy link

Platform

Android 11

Plugin

share_plus

Version

4.0.8

Flutter SDK

3.0.2

Steps to reproduce

  1. use shareFilesWithResult and check the result. result.raw returns null

Code Sample

No response

Logs

[+54664 ms] Observatory URL on device: http://127.0.0.1:34899/7ETFkDQwO_Q=/
[   +2 ms] executing: /Users/vgts/Library/Android/sdk/platform-tools/adb -s emulator-5554 forward tcp:0 tcp:34899
[  +34 ms] 52673
[        ] Forwarded host port 52673 to device port 34899 for Observatory
[  +11 ms] Caching compiled dill
[ +295 ms] Connecting to service protocol: http://127.0.0.1:52673/7ETFkDQwO_Q=/
[ +659 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:52673/7ETFkDQwO_Q=/.
[ +288 ms] DDS is listening at http://127.0.0.1:52682/LB1yIN6BQhk=/.
[ +103 ms] Successfully connected to service protocol: http://127.0.0.1:52673/7ETFkDQwO_Q=/
[ +173 ms] DevFS: Creating new filesystem on the device (null)
[  +75 ms] DevFS: Created new filesystem on the device (file:///data/user/0/io.flutter.plugins.shareexample/code_cache/exampleWMUXHN/example/)
[   +4 ms] Updating assets
[ +214 ms] Syncing files to device sdk gphone x86...
[   +3 ms] <- reset
[        ] Compiling dart to kernel with 0 updated files
[        ] Processing bundle.
[   +1 ms] <- recompile package:share_example/main.dart 260be2e5-1266-4797-b78b-e46ac513b004
[        ] <- 260be2e5-1266-4797-b78b-e46ac513b004
[   +3 ms] Bundle processing done.
[ +513 ms] Updating files.
[        ] DevFS: Sync finished
[   +2 ms] Syncing files to device sdk gphone x86... (completed in 523ms)
[        ] Synced 0.0MB.
[   +4 ms] <- accept
[   +5 ms] Connected to _flutterView/0xf52865e0.
[   +5 ms] Flutter run key commands.
[   +2 ms] r Hot reload. 🔥🔥🔥
[   +1 ms] R Hot restart.
[        ] h List all available interactive commands.
[        ] d Detach (terminate "flutter run" but leave application running).
[        ] c Clear the screen
[        ] q Quit (terminate the application on the device).
[        ] 💪 Running with sound null safety 💪
[   +1 ms] An Observatory debugger and profiler on sdk gphone x86 is available at: http://127.0.0.1:52682/LB1yIN6BQhk=/
[+2073 ms] The Flutter DevTools debugger and profiler on sdk gphone x86 is available at:
http://127.0.0.1:9100?uri=http://127.0.0.1:52682/LB1yIN6BQhk=/
[+3299 ms] I/AssistStructure(26783): Flattened final assist data: 532 bytes, containing 1 windows, 3 views
[+4850 ms] I/TextInputPlugin(26783): Composing region changed by the framework. Restarting the input method.
[  +13 ms] W/IInputConnectionWrapper(26783): getTextBeforeCursor on inactive InputConnection
[   +6 ms] W/IInputConnectionWrapper(26783): getSelectedText on inactive InputConnection
[   +3 ms] W/IInputConnectionWrapper(26783): getTextAfterCursor on inactive InputConnection
[   +6 ms] W/IInputConnectionWrapper(26783): getTextBeforeCursor on inactive InputConnection
[   +2 ms] W/IInputConnectionWrapper(26783): getSelectedText on inactive InputConnection
[   +3 ms] W/IInputConnectionWrapper(26783): getTextAfterCursor on inactive InputConnection
[  +30 ms] W/IInputConnectionWrapper(26783): beginBatchEdit on inactive InputConnection
[   +4 ms] W/IInputConnectionWrapper(26783): getTextBeforeCursor on inactive InputConnection
[        ] W/IInputConnectionWrapper(26783): endBatchEdit on inactive InputConnection
[   +5 ms] W/IInputConnectionWrapper(26783): beginBatchEdit on inactive InputConnection
[   +2 ms] W/IInputConnectionWrapper(26783): getTextBeforeCursor on inactive InputConnection
[   +1 ms] W/IInputConnectionWrapper(26783): endBatchEdit on inactive InputConnection
[ +113 ms] I/TextInputPlugin(26783): Composing region changed by the framework. Restarting the input method.
[        ] W/IInputConnectionWrapper(26783): getTextBeforeCursor on inactive InputConnection
[   +2 ms] W/IInputConnectionWrapper(26783): getSelectedText on inactive InputConnection
[   +7 ms] W/IInputConnectionWrapper(26783): getTextAfterCursor on inactive InputConnection
[  +24 ms] W/IInputConnectionWrapper(26783): getTextBeforeCursor on inactive InputConnection
[        ] W/IInputConnectionWrapper(26783): getSelectedText on inactive InputConnection
[        ] W/IInputConnectionWrapper(26783): getTextAfterCursor on inactive InputConnection
[  +34 ms] W/IInputConnectionWrapper(26783): beginBatchEdit on inactive InputConnection
[        ] W/IInputConnectionWrapper(26783): getTextBeforeCursor on inactive InputConnection
[        ] W/IInputConnectionWrapper(26783): endBatchEdit on inactive InputConnection
[ +210 ms] I/TextInputPlugin(26783): Composing region changed by the framework. Restarting the input method.
[   +3 ms] W/IInputConnectionWrapper(26783): getTextBeforeCursor on inactive InputConnection
[   +3 ms] W/IInputConnectionWrapper(26783): getSelectedText on inactive InputConnection
[  +13 ms] W/IInputConnectionWrapper(26783): getTextAfterCursor on inactive InputConnection
[   +1 ms] W/IInputConnectionWrapper(26783): getTextBeforeCursor on inactive InputConnection
[        ] W/IInputConnectionWrapper(26783): getSelectedText on inactive InputConnection
[        ] W/IInputConnectionWrapper(26783): getTextAfterCursor on inactive InputConnection
[  +51 ms] W/IInputConnectionWrapper(26783): beginBatchEdit on inactive InputConnection
[        ] W/IInputConnectionWrapper(26783): getTextBeforeCursor on inactive InputConnection
[   +2 ms] W/IInputConnectionWrapper(26783): endBatchEdit on inactive InputConnection
[   +7 ms] W/IInputConnectionWrapper(26783): beginBatchEdit on inactive InputConnection
[        ] W/IInputConnectionWrapper(26783): getTextBeforeCursor on inactive InputConnection
[  +19 ms] W/IInputConnectionWrapper(26783): endBatchEdit on inactive InputConnection
[  +81 ms] I/TextInputPlugin(26783): Composing region changed by the framework. Restarting the input method.
[   +2 ms] W/IInputConnectionWrapper(26783): getTextBeforeCursor on inactive InputConnection
[   +3 ms] W/IInputConnectionWrapper(26783): getSelectedText on inactive InputConnection
[   +9 ms] W/IInputConnectionWrapper(26783): getTextAfterCursor on inactive InputConnection
[+1078 ms] W/IInputConnectionWrapper(26783): getTextBeforeCursor on inactive InputConnection
[   +7 ms] I/AssistStructure(26783): Flattened final assist data: 524 bytes, containing 1 windows, 3 views
[        ] W/IInputConnectionWrapper(26783): getSelectedText on inactive InputConnection
[        ] W/IInputConnectionWrapper(26783): getTextAfterCursor on inactive InputConnection
[ +723 ms] I/TextInputPlugin(26783): Composing region changed by the framework. Restarting the input method.
[   +8 ms] W/IInputConnectionWrapper(26783): getTextBeforeCursor on inactive InputConnection
[   +2 ms] W/IInputConnectionWrapper(26783): getSelectedText on inactive InputConnection
[   +3 ms] W/IInputConnectionWrapper(26783): getTextAfterCursor on inactive InputConnection
[   +3 ms] W/IInputConnectionWrapper(26783): beginBatchEdit on inactive InputConnection
[        ] W/IInputConnectionWrapper(26783): getTextBeforeCursor on inactive InputConnection
[   +9 ms] W/IInputConnectionWrapper(26783): endBatchEdit on inactive InputConnection
[ +173 ms] I/TextInputPlugin(26783): Composing region changed by the framework. Restarting the input method.
[  +12 ms] W/IInputConnectionWrapper(26783): getTextAfterCursor on inactive InputConnection
[   +3 ms] W/IInputConnectionWrapper(26783): beginBatchEdit on inactive InputConnection
[        ] W/IInputConnectionWrapper(26783): endBatchEdit on inactive InputConnection
[  +12 ms] W/IInputConnectionWrapper(26783): setComposingRegion on inactive InputConnection
[        ] W/IInputConnectionWrapper(26783): getTextBeforeCursor on inactive InputConnection
[        ] W/IInputConnectionWrapper(26783): getSelectedText on inactive InputConnection
[        ] W/IInputConnectionWrapper(26783): getTextAfterCursor on inactive InputConnection
[ +313 ms] I/TextInputPlugin(26783): Composing region changed by the framework. Restarting the input method.
[   +6 ms] W/IInputConnectionWrapper(26783): getSelectedText on inactive InputConnection
[   +6 ms] W/IInputConnectionWrapper(26783): getTextAfterCursor on inactive InputConnection
[  +11 ms] W/IInputConnectionWrapper(26783): getTextBeforeCursor on inactive InputConnection
[   +4 ms] W/IInputConnectionWrapper(26783): getSelectedText on inactive InputConnection
[  +14 ms] W/IInputConnectionWrapper(26783): getTextAfterCursor on inactive InputConnection
[  +31 ms] W/IInputConnectionWrapper(26783): beginBatchEdit on inactive InputConnection
[   +2 ms] W/IInputConnectionWrapper(26783): getTextBeforeCursor on inactive InputConnection
[   +2 ms] W/IInputConnectionWrapper(26783): endBatchEdit on inactive InputConnection
[+1244 ms] I/TextInputPlugin(26783): Composing region changed by the framework. Restarting the input method.
[  +49 ms] W/IInputConnectionWrapper(26783): getTextBeforeCursor on inactive InputConnection
[  +13 ms] W/IInputConnectionWrapper(26783): getSelectedText on inactive InputConnection
[  +15 ms] W/IInputConnectionWrapper(26783): getTextAfterCursor on inactive InputConnection
[ +195 ms] W/IInputConnectionWrapper(26783): beginBatchEdit on inactive InputConnection
[        ] W/IInputConnectionWrapper(26783): getTextBeforeCursor on inactive InputConnection
[  +13 ms] W/IInputConnectionWrapper(26783): endBatchEdit on inactive InputConnection
[+1079 ms] I/TextInputPlugin(26783): Composing region changed by the framework. Restarting the input method.
[  +13 ms] W/ListenableEditingState(26783): a listener was added to EditingState while a batch edit was in progress
[  +89 ms] W/IInputConnectionWrapper(26783): endBatchEdit on inactive InputConnection
[  +76 ms] W/IInputConnectionWrapper(26783): setComposingRegion on inactive InputConnection
[        ] W/IInputConnectionWrapper(26783): getTextBeforeCursor on inactive InputConnection
[   +3 ms] W/IInputConnectionWrapper(26783): getSelectedText on inactive InputConnection
[  +20 ms] W/IInputConnectionWrapper(26783): getTextAfterCursor on inactive InputConnection
[  +88 ms] W/IInputConnectionWrapper(26783): getTextBeforeCursor on inactive InputConnection
[        ] W/IInputConnectionWrapper(26783): getSelectedText on inactive InputConnection
[        ] W/IInputConnectionWrapper(26783): getTextAfterCursor on inactive InputConnection
[  +90 ms] W/IInputConnectionWrapper(26783): beginBatchEdit on inactive InputConnection
[        ] W/IInputConnectionWrapper(26783): getTextBeforeCursor on inactive InputConnection
[  +19 ms] W/IInputConnectionWrapper(26783): endBatchEdit on inactive InputConnection
[+8172 ms] I/System.out(26783): onReceuve
[   +2 ms] I/System.out(26783): null
[ +254 ms] I/flutter (26783): ShareResultStatus.success
[        ] I/flutter (26783): null

Flutter Doctor

[✓] Flutter (Channel stable, 3.0.2, on macOS 12.2.1 21D62 darwin-x64, locale en-IN)
    • Flutter version 3.0.2 at /Users/vgts/Documents/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision cd41fdd495 (11 days ago), 2022-06-08 09:52:13 -0700
    • Engine revision f15f824b57
    • Dart version 2.17.3
    • DevTools version 2.12.2

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/vgts/Library/Android/sdk
    • Platform android-31, build-tools 30.0.3
    • ANDROID_HOME = /Users/vgts/Library/Android/sdk
    • ANDROID_SDK_ROOT = /Users/vgts/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)
    • All Android licenses accepted.

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

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

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

[✓] Connected device (3 available)
    • sdk gphone x86 (mobile) • emulator-5554 • android-x86    • Android 11 (API 30) (emulator)
    • macOS (desktop)         • macos         • darwin-x64     • macOS 12.2.1 21D62 darwin-x64
    • Chrome (web)            • chrome        • web-javascript • Google Chrome 102.0.5005.115

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

• No issues found!
@santhoshvgts santhoshvgts added bug Something isn't working triage labels Jun 19, 2022
@Letalus
Copy link

Letalus commented Jun 21, 2022

having the same issue with the latest package version. @santhoshvgts 4.0.4 of share_plus is working properly for me, but the current one isnt

@santhoshvgts
Copy link
Author

@Letalus I tried 4.0.4 but same issue

@Coronon
Copy link
Contributor

Coronon commented Jul 6, 2022

Hi there,
are you really seeing ShareResult.raw == null?

The definition of the raw property is as follows:

final String raw;

The dart null safety guarantees that the raw property cannot be null.

Please explain your issue a bit clearer :)

@santhoshvgts
Copy link
Author

@Coronon

#800 (comment)

shareWithresult fallback to share if the result is null

@Coronon
Copy link
Contributor

Coronon commented Sep 1, 2022

I am currently very short on time but will probably find some at the end of the month. When I last tried this I wasn’t able to reproduce this. Would you guys mind sharing a sample project for me to be on the same page? I am only able to test with the android emulator as I am not in possession of a real android device.

@cl549723678
Copy link

I had the same problem when running on Android 11, but Android 10 was normal

@mhadaily mhadaily added the Hacktoberfest Issues taking part in Hacktoberfest label Sep 28, 2022
@aakash-pamnani
Copy link
Contributor

print(result.raw == "null");//true
its not null its string "null"

@aakash-pamnani
Copy link
Contributor

@Coronon
intent.getParcelableExtra<ComponentName>(Intent.EXTRA_CHOSEN_COMPONENT)
returns null

@jimmy-rakh
Copy link

I have the same problem in version 4.4.0

final res = await Share.shareWithResult('some text',subject: title);

print(res.status);
print(res.raw);

@Coronon
Copy link
Contributor

Coronon commented Oct 17, 2022

@aakash-pamnani Thanks for your hint. Sadly, my PC broke and I was unable to work on this with my old Macbook. I expect to be able to look into the issue this weekend. As I don’t have an android device the hint that the new Android version might have something to do with it is greatly appreciated :)

@aakash-pamnani
Copy link
Contributor

@Coronon PendingIntent.FLAG_IMMUTABLE is the problem, changing it to PendingIntent.FLAG_MUTABLE returns the package name of the app clicked.
Is it ok using PendingIntent.FLAG_MUTABLE then i wil create a PR.

@Coronon
Copy link
Contributor

Coronon commented Oct 26, 2022

@aakash-pamnani If I remember correctly, there was a problem with the MUTABLE option. Something else in the code broke back then - I'll have to look into the old PRs. What's interesting is that I was not able to find anything in the change logs between Android v10 and v11 that would hint at any change in behaviour...

@Coronon
Copy link
Contributor

Coronon commented Oct 27, 2022

Finally got around to look into this and was able to reproduce it - now looking into a fix.

@Coronon
Copy link
Contributor

Coronon commented Oct 27, 2022

Okay, so I finally got a fix working that resolves the issue and cleans up the little callback-hell, while protecting us from any integrity issues a FLAG_MUTABLE Intent may carry.

It is really late at night for me, so I'll clean up my changes tomorrow to then submit a PR :)
Sorry again for the huge delay, I was sadly really busy :/

PS: It really is a nightmare to debug this with an Android emulator on a Mid 2012 Macbook Air lol

@Coronon
Copy link
Contributor

Coronon commented Oct 28, 2022

As I just submitted my PR, I would love for everyone to try out the changes to see if they fix the issue outside my simulator.

As always, I provide share_plus_example as a pre-setup example project for this PR.
You may also try out this PR in your own projects using these dependency overrides in your pubspec.yml:

dependency_overrides:
  share_plus:
    git:
      url: https://github.com/Coronon/plus_plugins
      ref: 488a27c5a6ca2cadb1a27591b5c17a1986cbd8b1
      path: packages/share_plus/share_plus
  share_plus_platform_interface:
    git:
      url: https://github.com/Coronon/plus_plugins
      ref: 488a27c5a6ca2cadb1a27591b5c17a1986cbd8b1
      path: packages/share_plus/share_plus_platform_interface

@aakash-pamnani
Copy link
Contributor

Its working @Coronon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Hacktoberfest Issues taking part in Hacktoberfest triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants