简体   繁体   English

React Native:facebook-android-sdk依赖关系构建错误

[英]React Native: facebook-android-sdk dependency build error

I'm running React Native v0.53.0 and npm installed react-native-fbsdk v0.7.0 but I can't build my project. 我正在运行React Native v0.53.0并且npm已安装react-native-fbsdk v0.7.0但是我无法构建我的项目。

I've seen various issues and stackoverflow questions and it seems like it problem is sycning up the right versions. 我见过各种问题和stackoverflow问题,看来问题是在寻找正确的版本。 However I tried almost every version option I read online and I still get build errors. 但是,我尝试了几乎所有在线阅读的版本选项,但仍然出现构建错误。 So, I reverted my changes to post this question. 因此,我恢复了更改以发布此问题。

Thank you for any help! 感谢您的任何帮助!

android/app/build.gradle Android设备/应用/的build.gradle

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 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "com.upwork"
        minSdkVersion 16
        targetSdkVersion 22
        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 {
    compile project(':react-native-fbsdk')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "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'
}

android/build.gradle 安卓/的build.gradle

 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 {
                // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
                url "$rootDir/../node_modules/react-native/android"
            }
        }
    }

react-native-fbsdk/android/build.gradle 反应天然-fbsdk /机器人/的build.gradle

apply plugin: 'com.android.library'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.2"

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 26
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile 'com.android.support:appcompat-v7:27.0.2'
    compile 'com.facebook.react:react-native:+' // support react-native-v0.22-rc+
    compile 'com.facebook.android:facebook-android-sdk:4.+'
}

repositories {
    mavenCentral()
    jcenter()
    maven {
        url 'https://maven.google.com/'
        name 'Google'
    }
}

stacktrace 堆栈跟踪

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugApkCopy'.
   > Could not find com.android.support:appcompat-v7:27.0.2.
     Searched in the following locations:
         file:/Users/annagarcia/Library/Android/sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.2/appcompat-v7-27.0.2.pom
         file:/Users/annagarcia/Library/Android/sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.2/appcompat-v7-27.0.2.jar
         file:/Users/annagarcia/Desktop/projects/Upwork/android/sdk-manager/com/android/support/appcompat-v7/27.0.2/appcompat-v7-27.0.2.jar
     Required by:
         Upwork:app:unspecified
         Upwork:app:unspecified > com.facebook.react:react-native:0.53.0
   > Could not find com.android.support:appcompat-v7:27.0.2.
     Searched in the following locations:
         file:/Users/annagarcia/Library/Android/sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.2/appcompat-v7-27.0.2.pom
         file:/Users/annagarcia/Library/Android/sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.2/appcompat-v7-27.0.2.jar
         file:/Users/annagarcia/Desktop/projects/Upwork/android/sdk-manager/com/android/support/appcompat-v7/27.0.2/appcompat-v7-27.0.2.jar
     Required by:
         Upwork:app:unspecified > Upwork:react-native-fbsdk:unspecified
         Upwork:app:unspecified > Upwork:react-native-fbsdk:unspecified > com.facebook.android:facebook-android-sdk:4.30.0 > com.facebook.android:facebook-common:4.30.0
         Upwork:app:unspecified > Upwork:react-native-fbsdk:unspecified > com.facebook.android:facebook-android-sdk:4.30.0 > com.facebook.android:facebook-login:4.30.0
   > Could not find com.android.support:support-annotations:27.0.2.
     Searched in the following locations:
         file:/Users/annagarcia/Library/Android/sdk/extras/android/m2repository/com/android/support/support-annotations/27.0.2/support-annotations-27.0.2.pom
         file:/Users/annagarcia/Library/Android/sdk/extras/android/m2repository/com/android/support/support-annotations/27.0.2/support-annotations-27.0.2.jar
         file:/Users/annagarcia/Desktop/projects/Upwork/android/sdk-manager/com/android/support/support-annotations/27.0.2/support-annotations-27.0.2.jar
     Required by:
         Upwork:app:unspecified > Upwork:react-native-fbsdk:unspecified > com.facebook.android:facebook-android-sdk:4.30.0 > com.facebook.android:facebook-core:4.30.0
   > Could not find com.android.support:support-core-utils:27.0.2.
     Searched in the following locations:
         file:/Users/annagarcia/Library/Android/sdk/extras/android/m2repository/com/android/support/support-core-utils/27.0.2/support-core-utils-27.0.2.pom
         file:/Users/annagarcia/Library/Android/sdk/extras/android/m2repository/com/android/support/support-core-utils/27.0.2/support-core-utils-27.0.2.jar
         file:/Users/annagarcia/Desktop/projects/Upwork/android/sdk-manager/com/android/support/support-core-utils/27.0.2/support-core-utils-27.0.2.jar
     Required by:
         Upwork:app:unspecified > Upwork:react-native-fbsdk:unspecified > com.facebook.android:facebook-android-sdk:4.30.0 > com.facebook.android:facebook-core:4.30.0
   > Could not find com.android.support:support-v4:27.0.2.
     Searched in the following locations:
         file:/Users/annagarcia/Library/Android/sdk/extras/android/m2repository/com/android/support/support-v4/27.0.2/support-v4-27.0.2.pom
         file:/Users/annagarcia/Library/Android/sdk/extras/android/m2repository/com/android/support/support-v4/27.0.2/support-v4-27.0.2.jar
         file:/Users/annagarcia/Desktop/projects/Upwork/android/sdk-manager/com/android/support/support-v4/27.0.2/support-v4-27.0.2.jar
     Required by:
         Upwork:app:unspecified > Upwork:react-native-fbsdk:unspecified > com.facebook.android:facebook-android-sdk:4.30.0 > com.facebook.android:facebook-common:4.30.0
   > Could not find com.android.support:cardview-v7:27.0.2.
     Searched in the following locations:
         file:/Users/annagarcia/Library/Android/sdk/extras/android/m2repository/com/android/support/cardview-v7/27.0.2/cardview-v7-27.0.2.pom
         file:/Users/annagarcia/Library/Android/sdk/extras/android/m2repository/com/android/support/cardview-v7/27.0.2/cardview-v7-27.0.2.jar
         file:/Users/annagarcia/Desktop/projects/Upwork/android/sdk-manager/com/android/support/cardview-v7/27.0.2/cardview-v7-27.0.2.jar
     Required by:
         Upwork:app:unspecified > Upwork:react-native-fbsdk:unspecified > com.facebook.android:facebook-android-sdk:4.30.0 > com.facebook.android:facebook-common:4.30.0
   > Could not find com.android.support:customtabs:27.0.2.
     Searched in the following locations:
         file:/Users/annagarcia/Library/Android/sdk/extras/android/m2repository/com/android/support/customtabs/27.0.2/customtabs-27.0.2.pom
         file:/Users/annagarcia/Library/Android/sdk/extras/android/m2repository/com/android/support/customtabs/27.0.2/customtabs-27.0.2.jar
         file:/Users/annagarcia/Desktop/projects/Upwork/android/sdk-manager/com/android/support/customtabs/27.0.2/customtabs-27.0.2.jar
     Required by:
         Upwork:app:unspecified > Upwork:react-native-fbsdk:unspecified > com.facebook.android:facebook-android-sdk:4.30.0 > com.facebook.android:facebook-common:4.30.0

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

BUILD FAILED

Try upgrading your gradle version, to 26 尝试将Gradle版本升级到26

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.1"
}

dependencies {
    compile project(':react-native-fbsdk')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:26.0.1"
    compile "com.facebook.react:react-native:+"
}

Android Studio Setup Android Studio安装程序

  1. Go to Android Studio | 转到Android Studio | New Project | 新项目| Minimum SDK. 最低SDK。
  2. Select API 15: Android 4.0.3 or higher and create your new project. 选择API 15:Android 4.0.3或更高版本,然后创建新项目。
  3. After you create a new project, open your_app | 创建新项目后,打开your_app | build.gradle. 的build.gradle。
  4. Add the following to the buildscript { repositories {}} section of the build.gradle ( Project ) file: 将以下内容添加到build.gradleProject )文件的buildscript {存储库{}}部分:

    mavenCentral() mavenCentral()

  5. Add the following to the dependencies {} section of your build.gradle (module: app) file to compile the latest version of the Facebook SDK: 将以下内容添加到build.gradle(模块:app)文件的依赖项{}部分中,以编译最新版本的Facebook SDK:

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

Now try to rebuild your project. 现在尝试重建您的项目。 I hope it will help. 希望对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Facebook-Android-SDK问题 - Problems with facebook-android-sdk 使用facebook-android-sdk - using facebook-android-sdk 难以将facebook-android-sdk导入eclipse - difficulty in importing the facebook-android-sdk into eclipse facebook-android-sdk兼容性问题 - facebook-android-sdk compatibility issue 错误:在 com.facebook.android:facebook-android-sdk:11.3.0 中找不到符号 AppLinks.getTargetUrlFromInboundIntent - error: cannot find symbol AppLinks.getTargetUrlFromInboundIntent in com.facebook.android:facebook-android-sdk:11.3.0 同步Gradle错误当我尝试在我的build.gradle依赖项上添加“compile”com.facebook.android:facebook-android-sdk:[4,5)'“ - Sync Gradle Error When I try to add “compile 'com.facebook.android:facebook-android-sdk:[4,5)'” on my build.gradle dependencies Facebook 在 Android 上连接与 facebook-android-sdk - Facebook Connect vs facebook-android-sdk on Android 如何禁用Facebook单点登录为Android - Facebook-android-sdk - How to disable Facebook single sign on for android - Facebook-android-sdk facebook-android-sdk:使用sdk 3.0.1强制重新认证 - facebook-android-sdk: Force reauthentication using the sdk 3.0.1 如何使用 facebook-android-sdk 获取 facebook 页面的 stream - How to get facebook page's stream with facebook-android-sdk
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM