react-native: react-native-fbsdk makes my build fail

Is this a bug report?

YES

Have you read the Contributing Guidelines?

YES

Environment

OS:  macOS Sierra 10.12.6
Node:  8.9.3
Yarn:  1.3.2
npm:  5.6.0
Watchman:  4.9.0
Xcode: 9.1 (9B55)
Android Studio:  3.0 AI-171.4443003

Packages: (wanted => installed) “react”: “^16.0.0-beta.5” “react-native”: “^0.49.5”

Steps to Reproduce

  1. create-react-native-app my-test-app
  2. cd my-test-app
  3. npm run eject 3.1. option1: React Native: I’d like a regular React Native project 3.2 option2: give a name 3.3 option3: confirm
  4. yarn add react-native-fbsdk
  5. react-native link react-native-fbsdk
  6. configure native project as described here
  7. react-native run-android

Expected Behavior

The app is built and runs on android without any problem

Actual Behavior

I have this error during the build of the project:

➜  my-test-app react-native run-android
Scanning folders for symlinks in /Users/sunrising/Documents/work/sitrap/my-test-app/node_modules (7ms)
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugApk'.
   > A problem occurred configuring project ':react-native-fbsdk'.
      > Could not resolve all dependencies for configuration ':react-native-fbsdk:_debugPublishCopy'.
         > Could not find com.android.support:appcompat-v7:27.0.1.
           Searched in the following locations:
               file:/Users/sunrising/Library/Android/sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.1/appcompat-v7-27.0.1.pom
               file:/Users/sunrising/Library/Android/sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.1/appcompat-v7-27.0.1.jar
               file:/Users/sunrising/Documents/work/sitrap/my-test-app/android/sdk-manager/com/android/support/appcompat-v7/27.0.1/appcompat-v7-27.0.1.jar
           Required by:
               mytestapp:react-native-fbsdk:unspecified
         > Could not find com.android.support:appcompat-v7:27.0.1.
           Searched in the following locations:
               file:/Users/sunrising/Library/Android/sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.1/appcompat-v7-27.0.1.pom
               file:/Users/sunrising/Library/Android/sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.1/appcompat-v7-27.0.1.jar
               file:/Users/sunrising/Documents/work/sitrap/my-test-app/android/sdk-manager/com/android/support/appcompat-v7/27.0.1/appcompat-v7-27.0.1.jar
           Required by:
               mytestapp:react-native-fbsdk:unspecified > com.facebook.react:react-native:0.50.3
         > Could not find com.android.support:support-annotations:27.0.1.
           Searched in the following locations:
               file:/Users/sunrising/Library/Android/sdk/extras/android/m2repository/com/android/support/support-annotations/27.0.1/support-annotations-27.0.1.pom
               file:/Users/sunrising/Library/Android/sdk/extras/android/m2repository/com/android/support/support-annotations/27.0.1/support-annotations-27.0.1.jar
               file:/Users/sunrising/Documents/work/sitrap/my-test-app/android/sdk-manager/com/android/support/support-annotations/27.0.1/support-annotations-27.0.1.jar
           Required by:
               mytestapp:react-native-fbsdk:unspecified > com.facebook.android:facebook-android-sdk:4.29.0 > com.facebook.android:facebook-core:4.29.0
         > Could not find com.android.support:support-core-utils:27.0.1.
           Searched in the following locations:
               file:/Users/sunrising/Library/Android/sdk/extras/android/m2repository/com/android/support/support-core-utils/27.0.1/support-core-utils-27.0.1.pom
               file:/Users/sunrising/Library/Android/sdk/extras/android/m2repository/com/android/support/support-core-utils/27.0.1/support-core-utils-27.0.1.jar
               file:/Users/sunrising/Documents/work/sitrap/my-test-app/android/sdk-manager/com/android/support/support-core-utils/27.0.1/support-core-utils-27.0.1.jar
           Required by:
               mytestapp:react-native-fbsdk:unspecified > com.facebook.android:facebook-android-sdk:4.29.0 > com.facebook.android:facebook-core:4.29.0
         > Could not find com.android.support:appcompat-v7:27.0.1.
           Searched in the following locations:
               file:/Users/sunrising/Library/Android/sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.1/appcompat-v7-27.0.1.pom
               file:/Users/sunrising/Library/Android/sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.1/appcompat-v7-27.0.1.jar
               file:/Users/sunrising/Documents/work/sitrap/my-test-app/android/sdk-manager/com/android/support/appcompat-v7/27.0.1/appcompat-v7-27.0.1.jar
           Required by:
               mytestapp:react-native-fbsdk:unspecified > com.facebook.android:facebook-android-sdk:4.29.0 > com.facebook.android:facebook-common:4.29.0
         > Could not find com.android.support:cardview-v7:27.0.1.
           Searched in the following locations:
               file:/Users/sunrising/Library/Android/sdk/extras/android/m2repository/com/android/support/cardview-v7/27.0.1/cardview-v7-27.0.1.pom
               file:/Users/sunrising/Library/Android/sdk/extras/android/m2repository/com/android/support/cardview-v7/27.0.1/cardview-v7-27.0.1.jar
               file:/Users/sunrising/Documents/work/sitrap/my-test-app/android/sdk-manager/com/android/support/cardview-v7/27.0.1/cardview-v7-27.0.1.jar
           Required by:
               mytestapp:react-native-fbsdk:unspecified > com.facebook.android:facebook-android-sdk:4.29.0 > com.facebook.android:facebook-common:4.29.0
         > Could not find com.android.support:customtabs:27.0.1.
           Searched in the following locations:
               file:/Users/sunrising/Library/Android/sdk/extras/android/m2repository/com/android/support/customtabs/27.0.1/customtabs-27.0.1.pom
               file:/Users/sunrising/Library/Android/sdk/extras/android/m2repository/com/android/support/customtabs/27.0.1/customtabs-27.0.1.jar
               file:/Users/sunrising/Documents/work/sitrap/my-test-app/android/sdk-manager/com/android/support/customtabs/27.0.1/customtabs-27.0.1.jar
           Required by:
               mytestapp:react-native-fbsdk:unspecified > com.facebook.android:facebook-android-sdk:4.29.0 > com.facebook.android:facebook-common:4.29.0
         > Could not find com.android.support:support-v4:27.0.1.
           Searched in the following locations:
               file:/Users/sunrising/Library/Android/sdk/extras/android/m2repository/com/android/support/support-v4/27.0.1/support-v4-27.0.1.pom
               file:/Users/sunrising/Library/Android/sdk/extras/android/m2repository/com/android/support/support-v4/27.0.1/support-v4-27.0.1.jar
               file:/Users/sunrising/Documents/work/sitrap/my-test-app/android/sdk-manager/com/android/support/support-v4/27.0.1/support-v4-27.0.1.jar
           Required by:
               mytestapp:react-native-fbsdk:unspecified > com.facebook.android:facebook-android-sdk:4.29.0 > com.facebook.android:facebook-common:4.29.0

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 11.653 secs
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html

Reproducible Demo

Take a look at Steps to Reproduce

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 43
  • Comments: 27 (3 by maintainers)

Commits related to this issue

Most upvoted comments

I had to define the facebook sdk version on android/build.gradle:

allprojects {
    repositories {
        ...
        configurations.all {
            resolutionStrategy {
                force 'com.facebook.android:facebook-android-sdk:4.28.0'
            }
        }
    }
}

Adding a maven repository url to google solved this for me:

allprojects {
    repositories {
        mavenLocal()
        jcenter()
        maven {
            url "https://maven.google.com"
            }
        configurations.all {
            resolutionStrategy {
                force 'com.facebook.android:facebook-android-sdk:4.28.0'
                }
            }
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
                url "$rootDir/../node_modules/react-native/android"
            }

        }
    }  

I tried it @yannickschuchmann @crysfel

But returns to me another error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Colored'

It works to me, with

configurations.all {
            resolutionStrategy {
                force 'com.facebook.android:facebook-android-sdk:4.22.1'
            }
        }

Thanks!

@heralight Thanks for reply. I was following this: so I used “compile”.

Finally I got it to work!

What I did blank app with only react-native 0.54.2 (I tried from 0.52, 54.0, 54.1, 54.2) react-native-fbsdk 0.7.0

after following the tutorial the errors were

Could not find com.android.support:appcompat-v7:27.0.2. …

then I added this to build.gradle

allprojects { repositories { … maven { url “https://maven.google.com” } configurations.all { resolutionStrategy { force ‘com.facebook.android:facebook-android-sdk:4.28.0’ } } } }

the error became this:

/Users/chuck/Code/fblogin/android/app/build/intermediates/res/merged/debug/values-v24/values-v24.xml:3: AAPT: Error retrieving parent for item: No resource found that matches the given name ‘android:TextAppearance.Material.Widget.Button.Borderless.Colored’. …

then in app/build.gradle I changed to compileSdkVersion 26 buildToolsVersion “26.0.1”

defaultConfig { … targetSdkVersion 26 }

And then It works on android now 😃 Guys please give it a try

@rafaesc You might be using a lower compileSdkVersion and buildToolsVersion under android/app/build.gradle. I had used 23 and 23.0.1 respectively, and had the same problem as you. When I used 26 and 26.0.1, I could use the solution by @yannickschuchmann

    compileSdkVersion 26
    buildToolsVersion "26.0.1"

For me this was the simplest solution. Way better than fiddling with node_modules. But be aware of updating the SDK dependency manually from time to time… 😃

So to get FB-login working in react-native you have to up target and compile sdk to 26? Which isnt supported by react native?

Or, not to risk breaking anything, I have to use a old version of fbsdk targeting sdk 23?

I try all the solution which have been provided but it didn’t work. My issue is in fbsdk build.gradles, it use com.android.support:appcompat-v7:27.0.2 but the newest version i can see in my folder C:\Users\ComputerName\AppData\Local\Android\sdk\extras\android\m2repository\com\android\support\appcompat-v7 is 26.0.0-alpha1 I try to update in Android Studio but still the same.

@chuckcwh if you upgrade compileSdkVersion and buildToolsVersion, you don’t need to force ‘com.facebook.android:facebook-android-sdk:4.28.0’ …

@heralight As you mentioned the error in facebook docs

use compile ‘com.facebook.android:facebook-android-sdk:[4,5)’

<-- this is the same as facebook doc right?

I just tested in a new blank app with: RN 0.54.1 react-native-fbsdk 0.7.0

My app BUILD SUCCESSFUL but app crashed.

Error reappeared in react-native-fbsdk@0.7.0 and the resolutionStrategy with fiex facebook-sdk version doesn’t help in 0.7.0. Anyone has a solution for the new version?

Just a comment. Using API 26 is breaking the Dev Menu in Android 8, because of a change in permissions with the overlay. Just blindily putting a greater compileVersion is not that good idea.

https://github.com/facebook/react-native/issues/4043

Yeah, given that this is a Facebook module meant to work with their own react-native framework, I must say this should have been much more robust

what a idiot SDK, cant get success build

for react-native-fbsdk 0.7.0, as explain https://github.com/facebook/react-native/issues/17147#issuecomment-352722825 @rafaesc, you need to upgrade your settings: compileSdkVersion 27 buildToolsVersion “27.0.1”

and there is an error in facebook docs: use compile ‘com.facebook.android:facebook-android-sdk:[4,5)’ instead of implementation ‘com.facebook.android:facebook-android-sdk:[4,5)’

0.70.0 works for as long as I stick to older sdk libraries. When I use latest sdk library, app crashes on launching.