FBSDK错误Android React Native

Posted

技术标签:

【中文标题】FBSDK错误Android React Native【英文标题】:FBSDK Error Android React Native 【发布时间】:2018-03-02 23:44:44 【问题描述】:

我在运行react-native run-android 命令时遇到问题,这仅发生在Android 上,在ios 中一切正常(包括使用Facebook 登录)。 终端中出现的错误。

> 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.2.
>            Searched in the following locations:
>                file:/usr/local/share/android-sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.2/appcompat-v7-27.0.2.pom
>                file:/usr/local/share/android-sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.2/appcompat-v7-27.0.2.jar
>                file:/Users/rafaelaugusto/Documents/Aplicativos/ReactNative/Vesti/android/sdk-manager/com/android/support/appcompat-v7/27.0.2/appcompat-v7-27.0.2.jar
>            Required by:
>                Vesti:react-native-fbsdk:unspecified
>          > Could not find com.android.support:appcompat-v7:27.0.2.
>            Searched in the following locations:
>                file:/usr/local/share/android-sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.2/appcompat-v7-27.0.2.pom
>                file:/usr/local/share/android-sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.2/appcompat-v7-27.0.2.jar
>                file:/Users/rafaelaugusto/Documents/Aplicativos/ReactNative/Vesti/android/sdk-manager/com/android/support/appcompat-v7/27.0.2/appcompat-v7-27.0.2.jar
>            Required by:
>                Vesti:react-native-fbsdk:unspecified > com.facebook.react:react-native:0.53.0
>          > Could not find com.android.support:support-annotations:27.0.2.
>            Searched in the following locations:
>                file:/usr/local/share/android-sdk/extras/android/m2repository/com/android/support/support-annotations/27.0.2/support-annotations-27.0.2.pom
>                file:/usr/local/share/android-sdk/extras/android/m2repository/com/android/support/support-annotations/27.0.2/support-annotations-27.0.2.jar
>                file:/Users/rafaelaugusto/Documents/Aplicativos/ReactNative/Vesti/android/sdk-manager/com/android/support/support-annotations/27.0.2/support-annotations-27.0.2.jar
>            Required by:
>                Vesti:react-native-fbsdk:unspecified > com.facebook.android:facebook-android-sdk:4.31.0 >
> com.facebook.android:facebook-core:4.31.0
>          > Could not find com.android.support:support-core-utils:27.0.2.
>            Searched in the following locations:
>                file:/usr/local/share/android-sdk/extras/android/m2repository/com/android/support/support-core-utils/27.0.2/support-core-utils-27.0.2.pom
>                file:/usr/local/share/android-sdk/extras/android/m2repository/com/android/support/support-core-utils/27.0.2/support-core-utils-27.0.2.jar
>                file:/Users/rafaelaugusto/Documents/Aplicativos/ReactNative/Vesti/android/sdk-manager/com/android/support/support-core-utils/27.0.2/support-core-utils-27.0.2.jar
>            Required by:
>                Vesti:react-native-fbsdk:unspecified > com.facebook.android:facebook-android-sdk:4.31.0 >
> com.facebook.android:facebook-core:4.31.0
>          > Could not find com.android.support:support-v4:27.0.2.
>            Searched in the following locations:
>                file:/usr/local/share/android-sdk/extras/android/m2repository/com/android/support/support-v4/27.0.2/support-v4-27.0.2.pom
>                file:/usr/local/share/android-sdk/extras/android/m2repository/com/android/support/support-v4/27.0.2/support-v4-27.0.2.jar
>                file:/Users/rafaelaugusto/Documents/Aplicativos/ReactNative/Vesti/android/sdk-manager/com/android/support/support-v4/27.0.2/support-v4-27.0.2.jar
>            Required by:
>                Vesti:react-native-fbsdk:unspecified > com.facebook.android:facebook-android-sdk:4.31.0 >
> com.facebook.android:facebook-common:4.31.0
>          > Could not find com.android.support:appcompat-v7:27.0.2.
>            Searched in the following locations:
>                file:/usr/local/share/android-sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.2/appcompat-v7-27.0.2.pom
>                file:/usr/local/share/android-sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.2/appcompat-v7-27.0.2.jar
>                file:/Users/rafaelaugusto/Documents/Aplicativos/ReactNative/Vesti/android/sdk-manager/com/android/support/appcompat-v7/27.0.2/appcompat-v7-27.0.2.jar
>            Required by:
>                Vesti:react-native-fbsdk:unspecified > com.facebook.android:facebook-android-sdk:4.31.0 >
> com.facebook.android:facebook-common:4.31.0
>                Vesti:react-native-fbsdk:unspecified > com.facebook.android:facebook-android-sdk:4.31.0 >
> com.facebook.android:facebook-login:4.31.0
>          > Could not find com.android.support:cardview-v7:27.0.2.
>            Searched in the following locations:
>                file:/usr/local/share/android-sdk/extras/android/m2repository/com/android/support/cardview-v7/27.0.2/cardview-v7-27.0.2.pom
>                file:/usr/local/share/android-sdk/extras/android/m2repository/com/android/support/cardview-v7/27.0.2/cardview-v7-27.0.2.jar
>                file:/Users/rafaelaugusto/Documents/Aplicativos/ReactNative/Vesti/android/sdk-manager/com/android/support/cardview-v7/27.0.2/cardview-v7-27.0.2.jar
>            Required by:
>                Vesti:react-native-fbsdk:unspecified > com.facebook.android:facebook-android-sdk:4.31.0 >
> com.facebook.android:facebook-common:4.31.0
>          > Could not find com.android.support:customtabs:27.0.2.
>            Searched in the following locations:
>                file:/usr/local/share/android-sdk/extras/android/m2repository/com/android/support/customtabs/27.0.2/customtabs-27.0.2.pom
>                file:/usr/local/share/android-sdk/extras/android/m2repository/com/android/support/customtabs/27.0.2/customtabs-27.0.2.jar
>                file:/Users/rafaelaugusto/Documents/Aplicativos/ReactNative/Vesti/android/sdk-manager/com/android/support/customtabs/27.0.2/customtabs-27.0.2.jar
>            Required by:
>                Vesti:react-native-fbsdk:unspecified > com.facebook.android:facebook-android-sdk:4.31.0 >
> com.facebook.android:facebook-common:4.31.0

我尝试了一些我在互联网上找到的解决方案,但到目前为止我还没有成功,通过谷歌的研究,在这里我设法解决了iOS中发生的错误,但我做不到同样的事情Android

【问题讨论】:

【参考方案1】:

只需更改 build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript 
    repositories 
        jcenter()
    
    dependencies 
        classpath 'com.android.tools.build:gradle:2.2.3'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    


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"
            

        
      

【讨论】:

以上是关于FBSDK错误Android React Native的主要内容,如果未能解决你的问题,请参考以下文章

React-Native FBSDK LoginButton 仅在 iOS 中崩溃应用程序

操作无法完成 com.facebook.sdk 错误 3 - IOS-react-native-FBSDK

React-native-fbsdk 问题:AAPT,任务“:app:processDebugResources”执行失败

安装 react-native-fbsdk 后 gradle build 失败,错误为 Error retrieving parent for item: No resource found that

未找到 react-native-fbsdk FBSDKCoreKit 和 FBSDKShareKit

如何获取用于 react-native-fbsdk 模块的 Facebook SDK 版本