繁体   English   中英

React Native:构建项目失败,可能与 react-native-fbsdk-next 有关?

[英]React Native: failed to build project, possibly related to react-native-fbsdk-next?

在我的 react-native 应用程序中,我突然收到此构建错误!

它似乎与我正在使用的 react-native-fbsdk-next 有关......

Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:mergeDebugAssets'.
> Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.
   > Could not resolve com.facebook.android:facebook-android-sdk:9.0.+.
     Required by:
         project :app > project :react-native-fbsdk-next
      > Failed to list versions for com.facebook.android:facebook-android-sdk.
         > Unable to load Maven meta-data from https://jcenter.bintray.com/com/facebook/android/facebook-android-sdk/maven-metadata.xml.
            > Could not HEAD 'https://jcenter.bintray.com/com/facebook/android/facebook-android-sdk/maven-metadata.xml'.
               > org.apache.http.client.ClientProtocolException (no error message)

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

* Get more help at https://help.gradle.org

BUILD FAILED in 54s

    at makeError (C:\xampp\htdocs\AdoptaTias\node_modules\execa\index.js:174:9)
    at C:\xampp\htdocs\AdoptaTias\node_modules\execa\index.js:278:16
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async runOnAllDevices (C:\xampp\htdocs\AdoptaTias\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:5)
    at async Command.handleAction (C:\xampp\htdocs\AdoptaTias\node_modules\react-native\node_modules\@react-native-community\cli\build\index.js:186:9)
info Run CLI with --verbose flag for more details.

这是我的 android/build.gradle

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

buildscript {
    
    ext {

        buildToolsVersion = "30.0.3"
        minSdkVersion = 26
        compileSdkVersion = 30
        targetSdkVersion = 30

        

        googlePlayServicesAuthVersion = "18.0.0" // <--- use this version or newer
        /*androidXAnnotation = "1.2.0"
        androidXBrowser = "1.3.0"*/
    }
    repositories {

        mavenLocal()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }
        maven { 
            // react-native-date-picker
            url "https://www.jitpack.io" 
        }

        google()
        mavenCentral()
        maven { url "https://maven.google.com" }

        maven { url "https://plugins.gradle.org/m2/" }
        maven { url "https://repo.spring.io/plugins-release/" }
    }
    dependencies {
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        //classpath("com.android.tools.build:gradle:3.5.3")
        classpath("com.android.tools.build:gradle:4.0.0")
        //Added this line
        classpath('com.google.gms:google-services:4.3.4')

        

        
    }
}

allprojects {
    repositories {
        mavenLocal()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }
        maven { 
            // react-native-date-picker
            url "https://www.jitpack.io" 
        }

        google()
        mavenCentral()
        maven { url "https://maven.google.com" }

        maven { url "https://plugins.gradle.org/m2/" }
        maven { url "https://repo.spring.io/plugins-release/" }
    }
}

  • 转到 android\build.gradle
  • 找到所有的 jcenter()
  • 将它们替换为 gradlePluginPortal() / 或者只是尝试在存储库和所有项目中添加这个 gradlePluginPortal()
  • 立即尝试构建应用程序

转到 android\build.gradle 转到 allProjects->repostories-> 只需添加 mavenCentral() 然后构建应用程序

昨天我从同一个包中收到同样的错误,只需更改您的网络或使用 VPN

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM