Nubescope / react-native-facebook-account-kit

Facebook Account Kit SDK wrapper for React Native
321 stars 120 forks source link

Error RNAccountKitNative.configure #147

Closed adrianofernande closed 5 years ago

adrianofernande commented 6 years ago

Hi Guys,

### Issue Description

My app is getting error: undefined is not an object (evaluating 'RNAccountKitNative.configure').

I tried some solutions founded in this git, but without success.

The errors appeared on android and ios.

I followed all instructions to configure and install this api.

My package.json

{ "name": "MyAppName", "version": "1.0.0", "private": true, "devDependencies": { "babel-eslint": "^8.2.1", "babel-jest": "22.1.0", "babel-preset-react-native": "4.0.0", "chai": "^4.1.2", "eslint": "^4.15.0", "eslint-config-airbnb": "16.1.0", "eslint-plugin-import": "^2.8.0", "eslint-plugin-jsx-a11y": "^6.0.3", "eslint-plugin-react": "^7.5.1", "eslint-plugin-react-native": "^3.2.1", "jest": "22.1.1", "jest-expo": "^24.0.0", "jest-react-native": "18.0.0", "mocha": "^4.1.0", "react-native-scripts": "^1.14.0", "react-test-renderer": "16.2.0", "remote-redux-devtools-on-debugger": "^0.8.3" }, "main": "./node_modules/react-native-scripts/build/bin/crna-entry.js", "scripts": { "start": "react-native-scripts start", "eject": "react-native-scripts eject", "android": "react-native-scripts android", "ios": "react-native-scripts ios" }, "jest": { "preset": "jest-expo" }, "dependencies": { "@expo/vector-icons": "^6.2.2", "@mapbox/polyline": "^0.2.0", "cep-promise": "^3.0.2", "color": "^2.0.1", "expo": "^27.0.0", "lodash": "^4.17.4", "moment": "^2.20.1", "native-base": "2.3.6", "prop-types": "^15.6.0", "react": "16.3.1", "react-native": "https://github.com/expo/react-native/archive/sdk-27.0.0.tar.gz", "react-native-communications": "^2.2.1", "react-native-country-picker-modal": "0.5.1", "react-native-datepicker": "^1.6.0", "react-native-facebook-account-kit": "^0.10.1", "react-native-image-zoom-viewer": "^2.2.13", "react-native-modalbox": "^1.4.2", "react-native-onboarding-swiper": "^0.6.0", "react-native-play-sound": "^1.0.24", "react-native-progress": "^3.5.0", "react-native-router-flux": "4.0.0-beta.22", "react-native-vector-icons": "4.5.0", "react-redux": "^5.0.6", "redux": "^3.7.2", "redux-form": "7.2.0", "redux-logger": "^3.0.6", "redux-persist": "^4.10.1", "redux-persist-transform-filter": "0.0.16", "redux-thunk": "^2.2.0", "remote-redux-devtools": "^0.5.12", "sentry-expo": "^1.7.0", "socket.io-client": "^2.0.4", "whatwg-fetch": "^2.0.3", "xml2js": "^0.4.19" } }

### Additional Information

I tried: https://github.com/underscopeio/react-native-facebook-account-kit/issues/38 https://github.com/underscopeio/react-native-facebook-account-kit/issues/48

Thanks for your help!.

hoanghuy27297 commented 6 years ago

I got the same problem. worked fine on Android but this error appear when running on ios

henrique1977 commented 5 years ago

I've got the same error. You have to compile again; only refreshing won't do. Calling react-native run-ios again fixed it for me.

Good luck!

nhnam commented 5 years ago

I suppose that you import accountkit right import RNAccountKit from 'react-native-facebook-account-kit'; Instead of RNAccountKitNative.configure you should use RNAccountKit.configure

jpgarcia commented 5 years ago

It seems that this related to a misconfiguration issue. Closing it for now, if issue still happening please provide a public repro with the source code failing so we can troubleshoot it.

adrianofernande commented 5 years ago

Hi Garcias,

I didn't can fix this error, so, for now, I'm not using this lib.

I'm using twilio, but this service is pay :(

Adriano

Em ter, 12 de fev de 2019 às 17:37, crsgarcias notifications@github.com escreveu:

Someone can fix the error? I have the same

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/underscopeio/react-native-facebook-account-kit/issues/147#issuecomment-462903358, or mute the thread https://github.com/notifications/unsubscribe-auth/AOFqRrbTxAAyZrljfptH4SIljQopsiU5ks5vMxfugaJpZM4VpasT .

tmjordan commented 5 years ago

@adrianofernande actually if you are using expo, you must eject your expo project first, because you have to link the library with the native projects. I think that's why you receive that error

adrianofernande commented 5 years ago

@tmjordan I tryed to eject my project from expo and link it, but the lib isn't available to use with react native in the native form. I tryed to use the mobile web form to without success.

For these reason, I quitted.

Adriano

Em qua, 13 de fev de 2019 às 08:16, tmjordan notifications@github.com escreveu:

@adrianofernande https://github.com/adrianofernande actually if you are using expo, you must eject your expo project first, because you have to link the library with the native projects. I think that's why you receive that error

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/underscopeio/react-native-facebook-account-kit/issues/147#issuecomment-463141539, or mute the thread https://github.com/notifications/unsubscribe-auth/AOFqRuSnzzB2dQKJV9R2qwQtPU5FnxCiks5vM-YRgaJpZM4VpasT .

tmjordan commented 5 years ago

@adrianofernande, i'm not sure to really understand your problem. I mean that's exactly what the lib does. Accountkit is built on native platforms, so that lib allows you to interact with the native functionalities of AccountKit. Anyway you can't use it with an expo project. After ejecting, you must follow the documentation to install and link the lib correctly. That's definitely a link issue, and i can assure you, that you can use Accountkit with your react native project thanks to that lib. I'm using it in my project without any problems.

carlg0020 commented 5 years ago

Thank you, but i cant fix the error, I quited the library because I was trying without success. Someone have an example?

adrianofernande commented 5 years ago

@tmjordan I already used this lib in native platform before, but I couldn't use it in react native even after ejected from expo.

I followed all instructions in documentation and some tips in various forums, but without success.

@tmjordan if you can to post a full code to examplify how I can do that in react native, I really appreciate man, because this lib is awesome and I don't know what I did wrong.

tks dude!

Em qua, 13 de fev de 2019 às 09:45, tmjordan notifications@github.com escreveu:

@adrianofernande https://github.com/adrianofernande, i'm not sure to really understand your problem. I mean that's exactly what the lib does. Accountkit is built on native platforms, so that lib allows you to interact with the native functionalities of AccountKit. Anyway you can't use it with an expo project. After ejecting, you must follow the documentation to install and link the lib correctly. That's definitely a link issue, and i can assure you, that you can use Accountkit with your react native project thanks to that lib. I'm using it in my project without any problems.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/underscopeio/react-native-facebook-account-kit/issues/147#issuecomment-463169344, or mute the thread https://github.com/notifications/unsubscribe-auth/AOFqRmDWAD-ne62G5hHc6bHzNTjBlRq1ks5vM_rHgaJpZM4VpasT .

tmjordan commented 5 years ago

@adrianofernande For Android, you must have:

new RNAccountKitPackage(), //in the list of packages `

If you don't have all of that, it means your android project is not properly linked

tmjordan commented 5 years ago

For ios, if you are using cocoapods, you must have that line in your Podfile pod 'RNAccountKit', :path => '../node_modules/react-native-facebook-account-kit/ios' Then run Pod install If you are not using cocoapods, you must link the library as explained in the documentation of RNAccountkit

tmjordan commented 5 years ago

@adrianofernande I recommend you to install the lib, in a fresh pure react native project. Then link the library and try use it. At least to well understand how it works. You must also rebuild all your native projects, after the linking

tmjordan commented 5 years ago

I suppose that you import accountkit right import RNAccountKit from 'react-native-facebook-account-kit'; Instead of RNAccountKitNative.configure you should use RNAccountKit.configure

I think the solution of your problem, could also be the answer of @nhnam. Anyway try with code. And don't forget to rebuild all your native projects

tmjordan commented 5 years ago
import React from 'react';
import {View} from 'react-native';
import RNAccountKit, { Color, StatusBarStyle } from "react-native-facebook-account-kit";

class Login extends React.Component {

    componentWillMount() {
        this.configureAccountKit();
    }

    configureAccountKit = () => {
        RNAccountKit.configure({
            responseType: 'token', // 'token' by default,
            enableSendToFacebook: true,
            enableGetACall: true,
            facebookNotificationsEnabled: true, // true by default
            readPhoneStateEnabled: true, // true by default,
            receiveSMS: true, // true by default,
            defaultCountry: 'FR',
            // viewControllerMode: 'present', // for iOS only, 'present' by default,
        })
    };

    _loginWithPhone = async () => {
        try {
            const payload = await RNAccountKit.loginWithPhone();

            if (!payload) {
                console.log('Login cancelled', payload)
            } else {
                console.log('Logged with phone. Payload:', payload);
            }
        } catch (err) {
            console.log('Error', err.message)
        }
    };

    _loginWithEmail = async () => {
        try {
            const payload = await RNAccountKit.loginWithEmail();

            if (!payload) {
                console.log('Login cancelled', payload)
            } else {
                console.log('Logged with email. Payload:', payload);
            }
        } catch (err) {
            console.log('Error', err.message)
        }
    };
}
adrianofernande commented 5 years ago

@tmjordan show man!!!

I'll try to do this in this weekend and I'll let you know about

thanks a lot man!!!

Em qua, 13 de fev de 2019 às 13:42, tmjordan notifications@github.com escreveu:

import React from 'react'; import {View} from 'react-native'; import RNAccountKit, { Color, StatusBarStyle } from "react-native-facebook-account-kit";

class Login extends React.Component {

componentWillMount() {
    this.configureAccountKit();
}

configureAccountKit = () => {
    RNAccountKit.configure({
        responseType: 'token', // 'token' by default,
        enableSendToFacebook: true,
        enableGetACall: true,
        facebookNotificationsEnabled: true, // true by default
        readPhoneStateEnabled: true, // true by default,
        receiveSMS: true, // true by default,
        defaultCountry: 'FR',
        // viewControllerMode: 'present', // for iOS only, 'present' by default,
    })
};

_loginWithPhone = async () => {
    try {
        const payload = await RNAccountKit.loginWithPhone();

        if (!payload) {
            console.log('Login cancelled', payload)
        } else {
            console.log('Logged with phone. Payload:', payload);
        }
    } catch (err) {
        console.log('Error', err.message)
    }
};

_loginWithEmail = async () => {
    try {
        const payload = await RNAccountKit.loginWithEmail();

        if (!payload) {
            console.log('Login cancelled', payload)
        } else {
            console.log('Logged with email. Payload:', payload);
        }
    } catch (err) {
        console.log('Error', err.message)
    }
};

}

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/underscopeio/react-native-facebook-account-kit/issues/147#issuecomment-463247956, or mute the thread https://github.com/notifications/unsubscribe-auth/AOFqRnz7SSsxJuZ8LHUpk9P1mDY39DmAks5vNDJhgaJpZM4VpasT .

carlg0020 commented 5 years ago

I qas run the example RN0577 and its ok, but in my project not working. I have react-native react-native-fbsdk too.

The error is:

* What went wrong:
Execution failed for task ':app:preDebugBuild'.
> Android dependency 'com.android.support:support-v4' has different version for the compile (27.0.2) and runtime (27.1.1) classpath. You should manually set the s
ame version via DependencyResolution
tmjordan commented 5 years ago

@crsgarcias try adding this implementation ("com.android.support:support-v4:27.1.1") { force = true }

tmjordan commented 5 years ago

in dependencies section of your android/app/build.gradle

carlg0020 commented 5 years ago

Thank you.

The libraries react-native react-native-fbsdk + react-native-facebook-account-kit can be together?

apply plugin: "com.android.application"

import com.android.build.OutputFile

project.ext.react = [
    entryFile: "index.js"
]

apply from: "../../node_modules/react-native/react.gradle"

/**
 * Set this to true to create two separate APKs instead of one:
 *   - An APK that only works on ARM devices
 *   - An APK that only works on x86 devices
 * The advantage is the size of the APK is reduced by about 4MB.
 * Upload all the APKs to the Play Store and people will download
 * the correct one based on the CPU architecture of their device.
 */
def enableSeparateBuildPerCPUArchitecture = false

/**
 * Run Proguard to shrink the Java bytecode in release builds.
 */
def enableProguardInReleaseBuilds = false

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion

    defaultConfig {
        applicationId "com.project"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 11
        versionName "1.0.11"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }

    signingConfigs {
        release {
            if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
                storeFile file(MYAPP_RELEASE_STORE_FILE)
                storePassword MYAPP_RELEASE_STORE_PASSWORD
                keyAlias MYAPP_RELEASE_KEY_ALIAS
                keyPassword MYAPP_RELEASE_KEY_PASSWORD
            }
        }
    }

    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86"
        }
    }
    buildTypes {
        release {
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            signingConfig signingConfigs.release
        }
    }
    // applicationVariants are e.g. debug, release
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            // For each separate APK per architecture, set a unique version code as described here:
            // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
            def versionCodes = ["armeabi-v7a":1, "x86":2]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {  // null for the universal-debug, universal-release variants
                output.versionCodeOverride =
                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
            }
        }
    }
}

dependencies {
    compile project(':react-native-facebook-account-kit')
    compile project(':react-native-fbsdk')
    compile project(':react-native-vector-icons')
    implementation 'com.facebook.android:facebook-android-sdk:4.34.0'
    implementation project(':react-native-smart-splashscreen')
    implementation project(':react-native-admob')
    implementation project(':react-native-contacts')
    implementation project(':react-native-share')
    implementation project(':react-native-fetch-blob')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation ("com.android.support:support-v4:27.1.1") { force = true }
    implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
    implementation "com.facebook.react:react-native:+"  // From node_modules
}

// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}

After Add that line, i have the result:

node_modules\react-native-fbsdk\android\src\main\java\com\facebook\reactnative\androidsdk\FBGraphRequestModule.java:155: e
rror: no suitable constructor found for AccessToken(String,String,String,<null>,<null>,<null>,<null>,<null>)
            graphRequest.setAccessToken(new AccessToken(
                                        ^
    constructor AccessToken.AccessToken(String,String,String,Collection<String>,Collection<String>,AccessTokenSource,Date,Date,Date) is not applicable
      (actual and formal argument lists differ in length)
    constructor AccessToken.AccessToken(Parcel) is not applicable
      (actual and formal argument lists differ in length)
C:\Users\cgarcias\private\project\node_modules\react-native-fbsdk\android\src\main\java\com\facebook\reactnative\androidsdk\Utility.java:64: error: no suita
ble constructor found for AccessToken(String,String,String,List<String>,List<String>,AccessTokenSource,Date,Date)
        return new AccessToken(
               ^
    constructor AccessToken.AccessToken(String,String,String,Collection<String>,Collection<String>,AccessTokenSource,Date,Date,Date) is not applicable
      (actual and formal argument lists differ in length)
    constructor AccessToken.AccessToken(Parcel) is not applicable
      (actual and formal argument lists differ in length)
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\Users\cgarcias\private\project\node_modules\react-native-fbsdk\android\src\main\java\com\facebook\reactnative\androidsdk\Utility.java uses unchecke
d or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-fbsdk:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
tmjordan commented 5 years ago

@crsgarcias , which version of react-native-fbsdk are you using? If you don't have the latest, then get it. I've never experienced that issue before. Maybe you can find solution on the github of react-native-fbsdk

carlg0020 commented 5 years ago

The version is 0.8.0, In the site is https://github.com/facebook/react-native-fbsdk

tmjordan commented 5 years ago

@crsgarcias here is an example of android/build.gradle which is working for me. I'm using react native 0.57.8. Hope it can help.

apply plugin: "com.android.application"

import com.android.build.OutputFile

/**
 * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
 * and bundleReleaseJsAndAssets).
 * These basically call `react-native bundle` with the correct arguments during the Android build
 * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
 * bundle directly from the development server. Below you can see all the possible configurations
 * and their defaults. If you decide to add a configuration block, make sure to add it before the
 * `apply from: "../../node_modules/react-native/react.gradle"` line.
 *
 * project.ext.react = [
 *   // the name of the generated asset file containing your JS bundle
 *   bundleAssetName: "index.android.bundle",
 *
 *   // the entry file for bundle generation
 *   entryFile: "index.android.js",
 *
 *   // whether to bundle JS and assets in debug mode
 *   bundleInDebug: false,
 *
 *   // whether to bundle JS and assets in release mode
 *   bundleInRelease: true,
 *
 *   // whether to bundle JS and assets in another build variant (if configured).
 *   // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
 *   // The configuration property can be in the following formats
 *   //         'bundleIn${productFlavor}${buildType}'
 *   //         'bundleIn${buildType}'
 *   // bundleInFreeDebug: true,
 *   // bundleInPaidRelease: true,
 *   // bundleInBeta: true,
 *
 *   // whether to disable dev mode in custom build variants (by default only disabled in release)
 *   // for example: to disable dev mode in the staging build type (if configured)
 *   devDisabledInStaging: true,
 *   // The configuration property can be in the following formats
 *   //         'devDisabledIn${productFlavor}${buildType}'
 *   //         'devDisabledIn${buildType}'
 *
 *   // the root of your project, i.e. where "package.json" lives
 *   root: "../../",
 *
 *   // where to put the JS bundle asset in debug mode
 *   jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
 *
 *   // where to put the JS bundle asset in release mode
 *   jsBundleDirRelease: "$buildDir/intermediates/assets/release",
 *
 *   // where to put drawable resources / React Native assets, e.g. the ones you use via
 *   // require('./image.png')), in debug mode
 *   resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
 *
 *   // where to put drawable resources / React Native assets, e.g. the ones you use via
 *   // require('./image.png')), in release mode
 *   resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
 *
 *   // by default the gradle tasks are skipped if none of the JS files or assets change; this means
 *   // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
 *   // date; if you have any other folders that you want to ignore for performance reasons (gradle
 *   // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
 *   // for example, you might want to remove it from here.
 *   inputExcludes: ["android/**", "ios/**"],
 *
 *   // override which node gets called and with what additional arguments
 *   nodeExecutableAndArgs: ["node"],
 *
 *   // supply additional arguments to the packager
 *   extraPackagerArgs: []
 * ]
 */

project.ext.react = [
    entryFile: "index.js"
]

apply from: "../../node_modules/react-native/react.gradle"

/**
 * Set this to true to create two separate APKs instead of one:
 *   - An APK that only works on ARM devices
 *   - An APK that only works on x86 devices
 * The advantage is the size of the APK is reduced by about 4MB.
 * Upload all the APKs to the Play Store and people will download
 * the correct one based on the CPU architecture of their device.
 */
def enableSeparateBuildPerCPUArchitecture = false

/**
 * Run Proguard to shrink the Java bytecode in release builds.
 */
def enableProguardInReleaseBuilds = false

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion

    defaultConfig {
        applicationId "com.izi"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86"
        }
    }
    buildTypes {
        release {
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }
    // applicationVariants are e.g. debug, release
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            // For each separate APK per architecture, set a unique version code as described here:
            // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
            def versionCodes = ["armeabi-v7a":1, "x86":2]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {  // null for the universal-debug, universal-release variants
                output.versionCodeOverride =
                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
            }
        }
    }
}

dependencies {
    implementation project(':react-native-gesture-handler')
    implementation project(':react-native-camera')
    implementation project(':rn-fetch-blob')
    implementation project(':react-native-i18n')
    implementation project(':react-native-fbsdk')
    implementation project(':react-native-splash-screen')
    implementation project(':react-native-facebook-account-kit')

    //implementation 'com.facebook.android:facebook-android-sdk:4.+'

    implementation ("com.android.support:support-v4:27.1.1") {
        force = true
    }
    implementation ("com.android.support:design:27.1.1") {
        force = true
    }

    implementation(project(':react-native-facebook-account-kit')){
        exclude group: 'com.facebook.android', module: 'account-kit-sdk'
    }
    implementation ('com.facebook.android:account-kit-sdk:4.+') {
        exclude group: 'com.google.android.gms', module: 'play-services-auth-api-phone'
        exclude group: 'com.google.android.gms', module: 'play-services-auth'
    }
    implementation 'com.google.android.gms:play-services-base:16+'
    implementation 'com.google.android.gms:play-services-auth-api-phone:16.+'
    implementation 'com.google.android.gms:play-services-auth:16.+'

    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
    implementation "com.facebook.react:react-native:+"  // From node_modules
}

// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}
carlg0020 commented 5 years ago

@tmjordan thank you, after your example my app/build.graddle look like this

dependencies {
    implementation project(':react-native-fbsdk')
    implementation project(':react-native-vector-icons')
    implementation project(':react-native-smart-splashscreen')
    implementation project(':react-native-admob')
    implementation project(':react-native-contacts')
    implementation project(':react-native-share')
    implementation project(':react-native-fetch-blob')

    implementation 'com.facebook.android:facebook-android-sdk:[4,5)'

    implementation ("com.android.support:support-v4:27.1.1") { 
        force = true
    }

    implementation ("com.android.support:design:27.1.1") {
        force = true
    }

    implementation(project(':react-native-facebook-account-kit')){
        exclude group: 'com.facebook.android', module: 'account-kit-sdk'
    }
 /*
    implementation ('com.facebook.android:account-kit-sdk:4.+') {
        exclude group: 'com.google.android.gms', module: 'play-services-auth-api-phone'
        exclude group: 'com.google.android.gms', module: 'play-services-auth'
    }
    */

    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
    implementation "com.facebook.react:react-native:+"  // From node_modules
}

I had to add in android/build.graddle the line classpath 'com.google.android.gms:play-services:11.4.0'

The output of console is

BUILD SUCCESSFUL in 21s
179 actionable tasks: 1 executed, 178 up-to-date
Running C:\\Users\\\cgarcias\\AppData\\Local\\Android\\Sdk/platform-tools/adb -s 192.168.220.101:5555 reverse tcp:8081 tcp:8081

But now, when the app is starting in the emulator, this is crashing.

Thank you @tmjordan

tmjordan commented 5 years ago

@crsgarcias, i think you must had those lines and replace 16+ by your the version of google play services you are using. I also had the crash problem, that solution worked for me. I'm not an android developper, so i can't tell you more Everything is ok on ios??

    implementation(project(':react-native-facebook-account-kit')){
        exclude group: 'com.facebook.android', module: 'account-kit-sdk'
    }
    implementation ('com.facebook.android:account-kit-sdk:4.+') {
        exclude group: 'com.google.android.gms', module: 'play-services-auth-api-phone'
        exclude group: 'com.google.android.gms', module: 'play-services-auth'
    }
    implementation 'com.google.android.gms:play-services-base:16+'
    implementation 'com.google.android.gms:play-services-auth-api-phone:16.+'
    implementation 'com.google.android.gms:play-services-auth:16.+'
tmjordan commented 5 years ago

i think the crash is related to a conflict with google play services

carlg0020 commented 5 years ago

I think so.

I modified my android/app/build.graddle

dependencies {
    implementation project(':react-native-fbsdk')
    implementation project(':react-native-vector-icons')
    implementation project(':react-native-smart-splashscreen')
    //implementation project(':react-native-admob')
    implementation project(':react-native-contacts')
    implementation project(':react-native-share')
    implementation project(':react-native-fetch-blob')

    implementation 'com.facebook.android:facebook-android-sdk:[4,5)'

    implementation ("com.android.support:support-v4:27.1.1") { 
        force = true
    }

    implementation ("com.android.support:design:27.1.1") {
        force = true
    }

    implementation(project(':react-native-facebook-account-kit')){
        exclude group: 'com.facebook.android', module: 'account-kit-sdk'
    }  

    implementation ('com.facebook.android:account-kit-sdk:4.+') {
        exclude group: 'com.google.android.gms', module: 'play-services-auth-api-phone'
        exclude group: 'com.google.android.gms', module: 'play-services-auth'
    }
    implementation 'com.google.android.gms:play-services-base:16+'
    implementation 'com.google.android.gms:play-services-auth-api-phone:16.+'
    implementation 'com.google.android.gms:play-services-auth:16.+'

    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
    implementation "com.facebook.react:react-native:+"  // From node_modules
}

My android/build.graddle too

 dependencies {
        classpath 'com.android.tools.build:gradle:3.1.4'
        //classpath 'com.google.android.gms:play-services:11.4.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
 }

The app work!. I think the crash was caused by react-native-admob + react-native-facebook-account-kit, I'm cheking this beacause I need the advertising to ear some money.

tmjordan commented 5 years ago

@crsgarcias yes, i did'nt see that you were using admob too. I had the same problem becouse of that

tmjordan commented 5 years ago

Check that link: https://github.com/sbugert/react-native-admob/issues/370

carlg0020 commented 5 years ago

Yes I will check that integration with admob. In this moment I quited the library. Thank you @tmjordan In this moment I am checking the realease because I dont get it.

ppv94 commented 5 years ago

I am getting the below compile error in android studio and the build fails how can I resolve this error. react-native version - 0.56.0. Caused by: org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':react-native-facebook-account-kit:compileDebugJavaWithJavac'.