facebookarchive / react-native-fbsdk

A React Native wrapper around the Facebook SDKs for Android and iOS. Provides access to Facebook login, sharing, graph requests, app events etc.
https://developers.facebook.com/docs/react-native
Other
2.99k stars 907 forks source link

“Invariant Violation: requireNativeComponent: ”RCTFBLoginButton“ was not found in the UIManager.”? in android #639

Open akhter004 opened 5 years ago

akhter004 commented 5 years ago

package.json { "name": "MyApp", "version": "0.0.1", "private": true, "scripts": { "start": "node node_modules/react-native/local-cli/cli.js start", "test": "jest", "ios": "react-native run-ios", "android": "react-native run-android" }, "dependencies": { "link": "^0.1.5", "react": "16.8.3", "react-native": "^0.59.9", "react-native-fbsdk": "^1.0.3" }, "devDependencies": { "@babel/core": "7.4.5", "@babel/runtime": "7.4.5", "babel-jest": "24.8.0", "jest": "24.8.0", "metro-react-native-babel-preset": "0.54.1", "react-test-renderer": "16.8.3" }, "jest": { "preset": "react-native" } }

App.js

import React, {Component} from 'react'; import {Platform, StyleSheet, Text, View, StatusBar} from 'react-native'; import { LoginButton, AccessToken } from 'react-native-fbsdk';

type Props = {}; export default class App extends Component { render() { return (

Hello MyApp Welcome to React Native! { if (error) { console.log("login has error: " + result.error); } else if (result.isCancelled) { console.log("login is cancelled."); } else { AccessToken.getCurrentAccessToken().then( (data) => { console.log(data.accessToken.toString()) } ) } } } onLogoutFinished={() => console.log("logout.")}/>
);

} }

const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#05818D', }, welcome: { fontSize: 20, textAlign: 'center', margin: 10, color:'#fff' }, instructions: { textAlign: 'center', color: '#333333', marginBottom: 5, }, });

Error-

Screenshot_2019-09-10-09-10-18-228_com shiksha

duytq94 commented 5 years ago

You haven't linked the library yet? Use react-native link react-native-fbsdk

akhter004 commented 5 years ago

I have link also but getting this error

On Wed, 11 Sep 2019, 12:19 pm Duy Tran, notifications@github.com wrote:

You haven't linked the library yet? Use react-native link react-native-fbsdk Also, config at MainApplication.java https://github.com/facebook/react-native-fbsdk#androidappsrcmainmainapplicationjava since the previous command not working at this file.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/facebook/react-native-fbsdk/issues/639?email_source=notifications&email_token=AG3MOEJYNWAGTOVQ5X76S6TQJCIGXA5CNFSM4IVOS622YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6NOYYY#issuecomment-530246755, or mute the thread https://github.com/notifications/unsubscribe-auth/AG3MOEPYX3QBUMFAMUNZBHDQJCIGXANCNFSM4IVOS62Q .

duytq94 commented 5 years ago

Also checking the manually linking to make sure the link command did all things true https://github.com/facebook/react-native-fbsdk#androidsettingsgradle

akhter004 commented 5 years ago

PFA.

even I am following this - https://github.com/facebook/react-native-fbsdk#installation

On Thu, Sep 12, 2019 at 8:24 AM Duy Tran notifications@github.com wrote:

Also checking the manually linking to make sure the link command did all things true https://github.com/facebook/react-native-fbsdk#androidsettingsgradle

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/facebook/react-native-fbsdk/issues/639?email_source=notifications&email_token=AG3MOEKUTSB2HF3LAGDBMBLQJGVPRA5CNFSM4IVOS622YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6QPSWQ#issuecomment-530643290, or mute the thread https://github.com/notifications/unsubscribe-auth/AG3MOEKQW6NESQBEDL52EUTQJGVPRANCNFSM4IVOS62Q .

-- Thanks & Regards Akhter Ali Ansari

akhter004 commented 5 years ago

PFA, if I add the selected part in build.gradle inside the dependencies then getting this "Could not find method implementation() for arguments [project ':react-native-fbsdk'] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. "

On Thu, Sep 12, 2019 at 8:31 AM Akhtar Ansari akhter004@gmail.com wrote:

PFA.

even I am following this - https://github.com/facebook/react-native-fbsdk#installation

On Thu, Sep 12, 2019 at 8:24 AM Duy Tran notifications@github.com wrote:

Also checking the manually linking to make sure the link command did all things true https://github.com/facebook/react-native-fbsdk#androidsettingsgradle

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/facebook/react-native-fbsdk/issues/639?email_source=notifications&email_token=AG3MOEKUTSB2HF3LAGDBMBLQJGVPRA5CNFSM4IVOS622YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6QPSWQ#issuecomment-530643290, or mute the thread https://github.com/notifications/unsubscribe-auth/AG3MOEKQW6NESQBEDL52EUTQJGVPRANCNFSM4IVOS62Q .

-- Thanks & Regards Akhter Ali Ansari

-- Thanks & Regards Akhter Ali Ansari

duytq94 commented 5 years ago

Make sure your root build.gradle file like this

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.2'  
    }
}
edgarbonillag commented 5 years ago

Hi, i'm using React Native 0.60.5 and i faced the same error. But I could solve it this way:

Multi-Thinker commented 4 years ago

+1 same issue. followed instructions, using version 3, even link doesn't work

yungkittty commented 4 years ago

For the people who still have this issue.

I managed to make it work thus realizing that I'm using react-native-navigation.

When you're using react-native-navigation you've a custom MainApplication.java file.

I suppose because of that react-native didn't success to add the package as described here :

https://github.com/facebook/react-native-fbsdk#androidappsrcmainmainapplicationjava.

So, I did it manually.

Btw, I didn't success make it works without using npx react-native link.

PS: sorry for my english :+1: