romatroskin / social_share_plugin

Social Share to Facebook and Instagram Flutter plugin.
BSD 2-Clause "Simplified" License
41 stars 87 forks source link

App stoped when send publication #13

Closed VeerneToor closed 4 years ago

VeerneToor commented 4 years ago

I was trying to make use of this package to publish on Facebook, however it has been impossible for me, I have already damaged the project several times due to flutter and AndroidX issues and now I don't know why this error was generated:

E/flutter (26489): [ERROR:flutter/shell/platform/android/platform_view_android_jni.cc(39)] java.lang.ExceptionInInitializerError E/flutter (26489): at com.cygnati.social_share_plugin.SocialSharePlugin.facebookShare(SocialSharePlugin.java:96) E/flutter (26489): at com.cygnati.social_share_plugin.SocialSharePlugin.onMethodCall(SocialSharePlugin.java:56) E/flutter (26489): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:231) E/flutter (26489): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:93) E/flutter (26489): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:642) E/flutter (26489): at android.os.MessageQueue.nativePollOnce(Native Method) E/flutter (26489): at android.os.MessageQueue.next(MessageQueue.java:326) E/flutter (26489): at android.os.Looper.loop(Looper.java:183) E/flutter (26489): at android.app.ActivityThread.main(ActivityThread.java:7285) E/flutter (26489): at java.lang.reflect.Method.invoke(Native Method) E/flutter (26489): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494) E/flutter (26489): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975) E/flutter (26489): Caused by: The SDK has not been initialized, make sure to call FacebookSdk.sdkInitialize() first. E/flutter (26489): at com.facebook.internal.Validate.sdkInitialized(Validate.java:146) E/flutter (26489): at com.facebook.FacebookSdk.getCallbackRequestCodeOffset(FacebookSdk.java:1017) E/flutter (26489): at com.facebook.internal.CallbackManagerImpl$RequestCodeOffset.toRequestCode(CallbackManagerImpl.java:119) E/flutter (26489): at com.facebook.share.widget.ShareDialog.<clinit>(ShareDialog.java:105) E/flutter (26489): ... 12 more E/flutter (26489): F/flutter (26489): [FATAL:flutter/shell/platform/android/platform_view_android_jni.cc(76)] Check failed: CheckException(env).

The application effectively opens facebook worse does nothing more, here is the code for AndroidXML and .dart

AndroidManifest.xml NOTE: The facebook app id is burned where the _____ are located. `

    <activity android:name="com.facebook.FacebookActivity"
        android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
        android:label="Mi Empresa" />

    <provider android:authorities="com.facebook.app.FacebookContentProvider{_________}"
        android:name="com.facebook.FacebookContentProvider"
        android:exported="true"/>`

Here is what runs it: FlatButton( child: Text('facebook'), onPressed: () async { await ImagePicker.pickImage(source: ImageSource.gallery).then((File file) async { await SocialSharePlugin.shareToFeedFacebook('caption', file.path); }); }, ),

ben060788 commented 4 years ago

same problem

romatroskin commented 4 years ago

try with updated plugin please and don't forget to add meta tags to the manifest as described in the readme

ben060788 commented 4 years ago

Hi @romatroskin

In my case, for iOS I did this cmd pod 'FBSDKCoreKit', '~> 5.8', :modular_headers => true in Podfile and //#import <FBSDKLoginKit/FBSDKLoginKit.h> in SocialSharePlugin.h

it works successful to share the post but there is a little bug.

When the screen pop the fb activity and keyboard , slide screen to unfocus keyboard, and click cancel button to discard post, a white block appears in the bottom of screen which covers my app content. I have no idea with this problem.

For Android , After updating plugin , still show the problem Caused by: The SDK has not been initialized, make sure to call FacebookSdk.sdkInitialize() first. The cause is fb_app_id meta-data tag should be in application tag Finally, it works fine.

So far, I only use shareToFeedFacebook. Thanks for your update.

romatroskin commented 4 years ago

Caused by: The SDK has not been initialized, make sure to call FacebookSdk.sdkInitialize() first.

this is appears when your are not fully configured, please check the example app configurations in the manifest and etc.

VeerneToor commented 4 years ago

Ok, i try that

Caused by: The SDK has not been initialized, make sure to call FacebookSdk.sdkInitialize() first.

this is appears when your are not fully configured, please check the example app configurations in the manifest and etc.

but now return that error ._.

Unhandled Exception: PlatformException(error, A ContentProvider for this app was not set up in the AndroidManifest.xml, please add com.facebook.app.FacebookContentProvider@strings/facebook_app_id as a provider to your AndroidManifest.xml file.

and my AndroidManifest.xml =>

<provider android:authorities="com.facebook.app.FacebookContentProvider@strings/facebook_app_id" android:name="com.facebook.FacebookContentProvider" android:exported="true"/>

romatroskin commented 4 years ago

Because it's not working like you have it, in the example app there is working example on how it should be actually so instead of

<provider     android:authorities="com.facebook.app.FacebookContentProvider@strings/facebook_app_id" android:name="com.facebook.FacebookContentProvider" android:exported="true"/>

there should be

<provider     android:authorities="com.facebook.app.FacebookContentProvider 000000000000000" android:name="com.facebook.FacebookContentProvider" android:exported="true"/>

where instead of 000000000000000 should be your Facebook ID :)

vivaan-m commented 4 years ago

I am Facing this issue App Crashes when i click on facebook icon to share in console i get Caused by: The SDK has not been initialized, make sure to call FacebookSdk.sdkInitialize() first.

i have used same manifest as example