简体   繁体   中英

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

in my react-native app I am SUDDENLY getting this build error!

It seems to be related to react-native-fbsdk-next I'm using...

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.

This is my 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/" }
    }
}

  • go to android\build.gradle
  • find all the jcenter()
  • replace them with gradlePluginPortal() / or just trying adding this gradlePluginPortal() both in repositories and all porjects
  • try to build the app now

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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