social_share icon indicating copy to clipboard operation
social_share copied to clipboard

Nullpointer Exception: instagram

Open Babwenbiber opened this issue 3 years ago • 0 comments

From time to time, I get an exception on calling shareInstagramStory. The IG closes automatically and I get back to my app. Here Is the exception:

E/AndroidRuntime(19390): FATAL EXCEPTION: main
E/AndroidRuntime(19390): Process: com.instagram.android, PID: 19390
E/AndroidRuntime(19390): java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference
E/AndroidRuntime(19390): 	at X.50D.A04(:7)
E/AndroidRuntime(19390): 	at X.CJr.run(:100)
E/AndroidRuntime(19390): 	at android.os.Handler.handleCallback(Handler.java:888)
E/AndroidRuntime(19390): 	at android.os.Handler.dispatchMessage(Handler.java:100)
E/AndroidRuntime(19390): 	at android.os.Looper.loop(Looper.java:213)
E/AndroidRuntime(19390): 	at android.app.ActivityThread.main(ActivityThread.java:8178)
E/AndroidRuntime(19390): 	at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(19390): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
E/AndroidRuntime(19390): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1101)
flutter doctor --verbose
[✓] Flutter (Channel master, 2.1.0-13.0.pre.292, on macOS 11.2 20D64 darwin-x64, locale de-DE)
    • Flutter version 2.1.0-13.0.pre.292 at /Users/frede/Project/flutter
    • Framework revision b60c855af5 (5 weeks ago), 2021-03-26 22:14:01 -0700
    • Engine revision b5e15d055d
    • Dart version 2.13.0 (build 2.13.0-162.0.dev)

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/frede/Library/Android/sdk
    • Platform android-30, build-tools 30.0.3
    • Java binary at: /Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/Contents/Home/bin/java
    • Java version Java(TM) SE Runtime Environment (build 9.0.4+11)
    • All Android licenses accepted.

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

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

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).

[✓] Connected device (1 available)
    • Chrome (web) • chrome • web-javascript • Google Chrome 90.0.4430.93

! Doctor found issues in 1 category.

I am using social_share: ^2.1.1

Code
void shareOnInsta() async {
    await controller.capture().then((image) async {
      Directory tempDir = await getTemporaryDirectory();
      String filePath = '${tempDir.path}/my_image.jpg';
      File(filePath).writeAsBytes(image);
      SocialShare.shareInstagramStory(
        filePath,
        attributionURL: "https://deep-link-url",
      ).then((data) {
        print(data);
      });
    }).catchError((onError) {
      print(onError);
    });
  }

Babwenbiber avatar May 02 '21 12:05 Babwenbiber