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

Android Error #39

Open
buskerone opened this issue Mar 22, 2017 · 18 comments
Open

Android Error #39

buskerone opened this issue Mar 22, 2017 · 18 comments

Comments

@buskerone
Copy link

buskerone commented Mar 22, 2017

I've an error while trying to share via Facebook or Twitter on an Android device (iOS ok):

captura de pantalla 2017-03-22 a las 16 53 34

_shareOnFacebook() { shareOnFacebook({ 'link':'https://artboost.com/' }, (results) => { console.log(results); } ); }
Maybe I've skipped something in the documentation?

@doefler
Copy link
Owner

doefler commented Mar 23, 2017

Hi @buskerone
I can't help you much with Android.
Maybe @Jberlinsky or @minhtule can help you 😄

@buskerone
Copy link
Author

@Jberlinsky @minhtule can you help me guys?

@minhtule
Copy link
Contributor

@buskerone I'm sorry that I'm not familiar with the share-via-Facebook feature. I would recommend you to use the official Facebook react native sdk. If you have a problem with share-via-Twitter, please share the stack trace here!

@buskerone
Copy link
Author

Ok thanks @minhtule . I'll try with Facebook RN SDK. The problem is also with sharing via twitter (Android). Same error.

@minhtule
Copy link
Contributor

minhtule commented Mar 24, 2017

@buskerone After installing the module (npm install react-native-social-share --save), did you run react-native link? I just checked and it's not part of the readme but it worked for me 😬

@buskerone
Copy link
Author

yes I did but for some reason it didn't work. Now I did a clean installation of the module and it seems to be working fine for Twitter, about Facebook isn't working but no errors at all, I assume that is b/c I'm using the simulator and without the Facebook app installed! Thanks for your help @minhtule.

@minhtule
Copy link
Contributor

@buskerone You're welcome! I'm glad that it's finally working for you! 😄

@fab-devtag
Copy link

fab-devtag commented Apr 3, 2017

I got the same error on android emulator, I was unable to make shareOnTwitter to work.

I added an import : import com.barefootcoders.android.react.KDSocialShare.KDSocialShare; to the MainApplication.java and new KDSocialShare() in the getPackages method and finally got it working, but only the text field.

Not tested on device with the twitter app installed yet.

Hope these two lines will help !

@angusmccloud
Copy link

@minhtule or @Jberlinsky I seem to be having the same issue as the people above. I have the module installed and working on IOS, no luck with Android yet.

Things I've tried:

  • Running the Link (which runs successfully)
  • Manually adding the 2 lines @Tigrakto suggested above
  • Uninstalling the Module and reinstalling it (along with linking it after re-installing)

I've attached a picture of the error I get, along with the MainApplication file where you can see the 2 lines in there (these were added through the Link).

If I remove the 2 lines from MainApplication I can get the app to compile, but when I try to tweet I get undefined is not an object (evaluating 'KDSocialShare.tweet')

Any suggestions are very appreciated.

Thanks!

image
image

@minhtule
Copy link
Contributor

minhtule commented May 9, 2017

Here are the changes I had when installing this library.

  • In package.json
...
 "react-native-social-share": "^1.0.0",
...
  • In android/settings.gradle
...
include ':react-native-social-share'
project(':react-native-social-share').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-social-share/android')
...
  • In android/app/build.gradle
dependencies(
    compile project(':react-native-social-share')
   ...
)

And the 2 lines in MainApplication.java that Tigrakto mentioned. @angusmccloud Could you please check that you have all these changes?

@angusmccloud
Copy link

angusmccloud commented May 10, 2017

@minhtule you got me on the right path, thank you! I was missing the line in build.gradle (and package.json was referring to 0.9.0 instead of 1.0). Once I added the link into build.gradle the package started building successfully on Android, but wouldn't actually post anything (i'd just get an "error" as the result).

To get it to actually work, I needed to uninstall and reinstall specifically installing version 1.0.0. Once I installed, re-linked, checked all files were right, it actually worked (for twitter only, as expected)!

This did break iPhone from building, time to go try and figure out why fixing this broke iOS...

EDIT:
For anyone else in the future who breaks their iOS instance this way. I realized my issue was from re-running Link after downloading 1.0.0. To fix this:

  • I created a new branch from Master (where it was compiling and working on iOS, compiling but not working on Android)
  • I made sure I had 1.0.0 installed
  • I manually checked/updated the 4 files outlined above by @minhtule

Once I followed those steps I got my app back compiling on both platforms and twitter working on both platforms.

@doefler
Copy link
Owner

doefler commented May 10, 2017

Let me know if I should add/edit something in the README.md or other files, keeping in mind it should work for all scenarios 😄

@angusmccloud
Copy link

@doefler the only thing I would do is add to the website the steps of checking those 4 files as part of installation. It seems like running npm link takes care of 3 of the 4 - but checking all 4 can't hurt.

OR, I suppose that can continue to live in this thread where anyone trying to get Android working will find it (aka how I got here).

@doefler
Copy link
Owner

doefler commented May 10, 2017

I think some of your advice from above could be combined into a step by step guide and video.
This could have its own section I can link to from the README.md
What do you think?
I could also link to this issue?

@eggybot
Copy link

eggybot commented May 23, 2017

this happen to me also.

Is there a way to separate the share system of twitter and facebook? I just want to use the twitter and the facebook part is having an issue with the current rn fbsdk module, so its much better if you can separate it because when I install it, it crash the app also it duplicates all codes that I added for rn-fbsdk for android, And I need to uninstall this and manually remove all codes that this plugin install.

thanks,

@doefler
Copy link
Owner

doefler commented May 23, 2017

Hey @eggybot

I am not quite sure how you imagine it to work/be implemented.
As I haven't don't know much about the Android part, I can't tell if it is possible.
Looking through the Android code, it seems to me that fallbacks have been built in, so I don't understand what is causing errors.
See this code snippet from https://github.com/doefler/react-native-social-share/blob/master/android/src/main/java/com/barefootcoders/android/react/KDSocialShare/KDSocialShareModule.java:

if (options.hasKey("text") && doesPackageExist("com.facebook.katana")) {
	String shareText = options.getString("text");
	shareIntent = new Intent(Intent.ACTION_SEND);
	shareIntent.setType("text/plain");
	shareIntent.putExtra(Intent.EXTRA_TEXT, shareText);
} else if (options.hasKey("link")) {
	String shareUrl = options.getString("link");
	String sharerUrl = "https://www.facebook.com/sharer/sharer.php?u=" + shareUrl;
	shareIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(sharerUrl));
} else {
	if (options.hasKey("text") && !doesPackageExist("com.facebook.katana")) {
		callback.invoke("error", "If text is provided to Facebook sharing, the application must be installed");
	} else {
		callback.invoke("error");
	}
	return;
}

Would be awesome to find a sustainable fix for Android, so people don't get these issues :)
@buskerone @minhtule @Tigrakto @angusmccloud

@nandhakishore-g
Copy link

image not loading in twitter share android and tweet button is also disable @minhtule can u help me fix i :)

@minhtule
Copy link
Contributor

@nandhakishore14 I'm very sorry to disappoint you but I no longer do development on React Native so I'm not familiar with the latest changes on the platform to help you debug 😞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants