facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
118.05k stars 24.19k forks source link

Android build failed: 'Failed to list versions for com.facebook.react:react-native.' #35136

Closed aamagda closed 1 year ago

aamagda commented 1 year ago

Description

Version

0.65.1

Output of npx react-native info

System: OS: macOS 13.0 CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz Memory: 55.72 MB / 16.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 16.17.1 - ~/.nvm/versions/node/v16.17.1/bin/node Yarn: 3.1.1 - /usr/local/bin/yarn npm: 8.16.0 - ~/WebstormProjects/mono-front/node_modules/.bin/npm Watchman: 2022.08.15.00 - /usr/local/bin/watchman Managers: CocoaPods: 1.11.3 - /Users/magdaaa/.rvm/gems/ruby-2.7.4/bin/pod SDKs: iOS SDK: Platforms: DriverKit 21.4, iOS 16.0, macOS 12.3, tvOS 16.0, watchOS 9.0 Android SDK: Not Found IDEs: Android Studio: Not Found Xcode: 14.0.1/14A400 - /usr/bin/xcodebuild Languages: Java: 11.0.16 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 17.0.2 => 17.0.2 react-native: 0.65.1 => 0.65.1 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Steps to reproduce

start to build android app

Snack, code example, screenshot, or link to a repository

build.gradle

dependencies { ... implementation "com.facebook.react:react-native:+" ... }

DDTEC-00 commented 1 year ago

You're not alone, experiencing same error

BUILD FAILED in 1m 47s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

Steps to reproduce are the same.

mauricedoepke commented 1 year ago

I get a similar error with an expo managed rn app:

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':react-native-pager-view:verifyReleaseResources'.
> Could not resolve all task dependencies for configuration ':react-native-pager-view:releaseRuntimeClasspath'.

   > Could not resolve com.facebook.react:react-native:+.
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
     Required by:

         project :react-native-pager-view
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
      > Failed to list versions for com.facebook.react:react-native.
         > Unable to load Maven meta-data from https://jcenter.bintray.com/com/facebook/react/react-native/maven-metadata.xml.
            > Could not HEAD 'https://jcenter.bintray.com/com/facebook/react/react-native/maven-metadata.xml'.
               > Read timed out
stephanrotolante commented 1 year ago

Same! No libs were changed either :/

Screen Shot 2022-10-30 at 3 36 34 PM
louniss commented 1 year ago

JCenter and Bintray shut down today.

dsipahioglu commented 1 year ago

Do you have a resource that states this that you can share with us?

olcaneristi commented 1 year ago

I'm also getting the same error (version 0.66.4). anyone know what should we do?

stephanrotolante commented 1 year ago

@olcaneristi Probably going to have to change where were fetching these deps from in the build process because JCenter and Bintray aren't working.

@louniss I can't find any resources that state JCenter and Bintray being shutdown today? I found something that mentions being shutdown Feb 1st 2022, but were now way past that date

mauricedoepke commented 1 year ago

I was able to fix my build. Apparently jcenter is down. It was already deprecated for some time now. I am not sure if it is finally down forever now or if this is temporary.

I had to update all dependencies that still used jcenter to the newest version. Most of them replaced jcenter with maven already. One I had to manually patch with https://github.com/ds300/patch-package myself.

After that my build worked again.

stephanrotolante commented 1 year ago

@mauricedoepke hopefully this is just temp otherwise a fix is going to have to be made in all these RN pkgs

louniss commented 1 year ago

@olcaneristi

https://bintray.com/ says 410 gone and https://jcenter.bintray.com/ says 403 forbidden

edit: to those who are confused

410 Gone The HyperText Transfer Protocol (HTTP) 410 Gone client error response code indicates that access to the target resource is no longer available at the origin server and that this condition is likely to be permanent.

stephanrotolante commented 1 year ago

Hey everyone,

I tweaked a few things in my build.gradle file to emulate what this build.gradle looks like and my build errors went away

remove jcenter references and use mavenCentral

Hope this fixes everyone :)

nyomanyudis95 commented 1 year ago

@stephanrotolante can you help me share your complete build.gradle ?. because i already remove jcenter but still got error. Thanks

Bilal-Abdeen commented 1 year ago

I had to comment out the jcenter() commands in build.gradle. If it is required by any of your libraries, you would need to check if there is a newer version of the library, which does not need it.

Obviously, you will need to delete the following folders (if any of them exists) before trying to rebuild your app. android/.grdale, android/.idea, android/build & android/app/build

proselin commented 1 year ago

It may be stupid but work for me it is replace all jcenter() in your project even node_module by mavenCentral()

stephanrotolante commented 1 year ago

@nyomanyudis95 try running a gradle clean, then rebuild

buildscript {
    ext {
        buildToolsVersion = "30.0.3"
        minSdkVersion = 21
        compileSdkVersion = 31
        targetSdkVersion = 31
        androidXCore = "1.7.0"
        kotlinVersion = "1.6.0"
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath('com.android.tools.build:gradle:7.1.2')
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

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")
        }
        mavenCentral {
            // We don't want to fetch react-native from Maven Central as there are
            // older versions over there.
            content {
                excludeGroup "com.facebook.react"
            }
        }
        google()
        maven { url 'https://www.jitpack.io' }
    }

}

a554878526 commented 1 year ago

I'm having the same problem

orchsik commented 1 year ago

I'm having the same problem

vTrip commented 1 year ago

@a554878526 @orchsik

jcenter has shutdown in the last 24 hours I think.

You should grep "jcenter" and see which modules in your project contain references to it still. Upgrade those packages, if they have fixed it in a new release, or replace jcenter with mavenCentral in the package files yourself and use patch-package to maintain the change

I've just finished doing this and found many packages actually fixed this and just required an update to the version of those packages.

GL ✌️

dippathak26 commented 1 year ago

I had to comment out the jcenter() commands in build.gradle. If it is required by any of your libraries, you would need to check if there is a newer version of the library, which does not need it.

Obviously, you will need to delete the following folders (if any of them exists) before trying to rebuild your app. android/.grdale, android/.idea, android/build & android/app/build

Hello,

I am still facing the same issue when building new release app, works pretty well with debug app Looking for an update really soon.

Thanks!

darpsoft commented 1 year ago

Hello,

Same problem, in my case I can't replace jcenter with mavenCentral because I need it for some old libraries.

jinal1788 commented 1 year ago

It worked using [proselin] solution.. Replace jcenter with mavenCentral in all node_modules

nyomanyudis95 commented 1 year ago

BTW its already work for me just delete jcenter in build.gradle. After that you need to look carefully about what package that make your app dont run . For example i have problem like this after delete jcenter.

mowaisch commented 1 year ago

replacing jcenter to mavenCentral causes another error

`Could not determine the dependencies of task ':app:mergeDebugAssets'.

Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'. Could not find com.eightbitlab:blurview:1.6.6. Searched in the following locations:

doniwinata0309 commented 1 year ago

Could you guys try this and check if it works (in case you still using some library on jcenter)? So it seems not all jcenter repo down

    jcenter {
        content {
            excludeGroup "com.facebook.react"
            excludeGroup "net.minidev"
            excludeGroup "com.nimbusds"
        }
    }
jihokim2 commented 1 year ago

@mowaisch Did you try "@react-native-community/blur": "^4.2.0" ? If you do and install this problem disappear.

mowaisch commented 1 year ago

@doniwinata0309 after adding that

`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:13.+. 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'. Received status code 502 from server: Bad Gateway `

dippathak26 commented 1 year ago
image

After trying all the solutions above, now I get this. Really, JCenter and Bintray had to get shutdown today? Could you please find a way around for this? Issue faced when building new release app Thanks!

mowaisch commented 1 year ago

@jihokim2 I'm using same library https://www.npmjs.com/package/@react-native-community/blur

doniwinata0309 commented 1 year ago

@mowaisch did u already put mavenCentral() on top of jcenter ? seems com.facebook.android:facebook-android-sdk is from mavencentral

mowaisch commented 1 year ago

@doniwinata0309 yes I did that so I need to remove that?

jihokim2 commented 1 year ago

@mowaisch Did you check version? If you are using 4.2.0 this problem disappeared. Because this library don't use jcenter but use mavencentral

LeeKyungJoon2 commented 1 year ago

Most of our apps are old versions of npm. There are too many jcenter dependencies that can be changed at once. Is there any other way besides updating the npm?

doniwinata0309 commented 1 year ago

@mowaisch no, dont remove that. so mine is something like this on root/build.gradle --> allProject{}:

    mavenCentral {
        // exclude react-native from MavenCentral
        content {
            excludeGroup "com.facebook.react"
        }
    }

    jcenter {
        content {
            excludeGroup "com.facebook.react"
            excludeGroup "net.minidev"
            excludeGroup "com.nimbusds"
        }
    }
mowaisch commented 1 year ago

@jihokim2 you can see there are 2 more libraries that uses jcenter and twitter is not updated from a long time so how we can fix that.

mowaisch commented 1 year ago

@doniwinata0309 this is mine I changed according to yours. `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") }

    google()
    mavenCentral {
    // exclude react-native from MavenCentral
    content {
        excludeGroup "com.facebook.react"
    }
}

jcenter {
    content {
        excludeGroup "com.facebook.react"
        excludeGroup "net.minidev"
        excludeGroup "com.nimbusds"
    }
}
    // jcenter()
    maven { url 'https://www.jitpack.io' }
}

}`

ERROR `Could not determine the dependencies of task ':app:processDebugResources'.

Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'. Could not resolve com.facebook.react:react-native:+. Required by: project :app project :app > project :lottie-react-native project :app > project :react-native-audio-recorder-player project :app > project :react-native-splash-screen project :app > project :invertase_react-native-apple-authentication project :app > project :react-native-async-storage_async-storage project :app > project :react-native-clipboard_clipboard project :app > project :react-native-community_blur project :app > project :react-native-community_datetimepicker project :app > project :react-native-community_netinfo project :app > project :react-native-firebase_app project :app > project :react-native-firebase_messaging project :app > project :react-native-google-signin_google-signin project :app > project :react-native-masked-view_masked-view project :app > project :react-native-picker_picker project :app > project :react-native-twitter-signin_twitter-signin project :app > project :react-native-fast-image project :app > project :react-native-fbsdk-next project :app > project :react-native-fs project :app > project :react-native-geolocation-service project :app > project :react-native-gesture-handler project :app > project :react-native-iap project :app > project :react-native-image-crop-picker project :app > project :react-native-in-app-review project :app > project :react-native-incall-manager project :app > project :react-native-maps project :app > project :react-native-pager-view project :app > project :react-native-permissions project :app > project :react-native-safe-area-context project :app > project :react-native-screens project :app > project :react-native-sound-level project :app > project :react-native-svg project :app > project :react-native-vector-icons project :app > project :react-native-video project :app > project :rn-fetch-blob Failed to list versions for com.facebook.react:react-native. Unable to load Maven meta-data from https://jcenter.bintray.com/com/facebook/react/react-native/maven-metadata.xml. Could not HEAD 'https://jcenter.bintray.com/com/facebook/react/react-native/maven-metadata.xml'. Read timed out `

doniwinata0309 commented 1 year ago

@mowaisch now com.facebook.react missing. probably u load this from maven central, so try to change mavenCentral{xxx} to mavenCentral() maybe.

LuanNguyen-HnL commented 1 year ago

Switch off the internet when building the package works for me. I think that's just a temporary solution. But at least it worked!

0x0is1 commented 1 year ago

Switch off the internet when building the package works for me

Worked for me as well 👍🏻

mowaisch commented 1 year ago

@mowaisch now com.facebook.react missing. probably u load this from maven central, so try to change mavenCentral{xxx} to mavenCentral() maybe.

Tried but same error.

mowaisch commented 1 year ago

Switch off the internet when building the package works for me. I think that's just a temporary solution. But at least it worked!

This worked for me. But we need a proper solution.

codeYard17 commented 1 year ago

this answer worked for me, https://github.com/facebook/react-native/issues/32734#issuecomment-1013431238

dsipahioglu commented 1 year ago

From what I've understood, If you haven't cleaned your project recently, you can switch off the internet and it will build just fine.

But if you wanted to create a release build/test apk and you've cleaned beforehand, you'll need jcenter to work if you have dependencies that exist on jCenter, but not on maven.

In my case I've migrated from 0.60.5 fo 0.66.4 a long time ago, but I hadn't fully upgraded the packages to be supported by maven. So I hadn't deleted jcenter().

This is what happened before removing jCenter().

...Could not determine the dependencies of task ':app:lintVitalRelease'.

Could not resolve all artifacts for configuration ':app:debugRuntimeClasspath'. Could not resolve com.facebook.react:react-native:+. Required by: project :app project :app > project :react-native-share ...

After removing jCenter():

So I had to find replacements for the listed dependencies from maven, and the errors disappeared one by one. I have 25+ dependencies though... I hope they fix this soon..

LeeKyungJoon2 commented 1 year ago

this answer worked for me, #32734 (comment)

I've been using it like this for months. However, you can't use it like this because the download itself is blocked by jcenter from today.

Developeranees commented 1 year ago

worked for me replacing jcenter() to mavenCentral()

erenkulaksiz commented 1 year ago

worked for me replacing jcenter() to mavenCentral()

This worked for me too.

goodjun commented 1 year ago

use mavenCentral() to replace jcenter().

note that some versions of flipper do not exist, and you need to upgrade the flipper version.

latest version of Flipper requires react-native 0.69+! If you use react-native < 0.69.0, please, downgrade react-native-flipper to 0.162.0

# android/gradle.properties

# Version of flipper SDK to use with React Native
FLIPPER_VERSION=0.162.0
revosambat commented 1 year ago

using mavenCentral() to replace jcenter() fixes ./gradlew clean but while building the android application using yarn leads to: Execution failed for task ':app:checkDebugAarMetadata'.

Could not resolve all files for configuration ':app:debugRuntimeClasspath'. Could not find com.facebook.fresco:stetho:2.2.0. Searched in the following locations:

BUILD FAILED in 44s

at makeError (/home/user/FCS/fleet-compliance-driver-app-android/node_modules/execa/index.js:174:9)
at /home/user/FCS/fleet-compliance-driver-app-android/node_modules/execa/index.js:278:16
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async runOnAllDevices (/home/user/FCS/fleet-compliance-driver-app-android/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:109:5)
at async Command.handleAction (/home/user/FCS/fleet-compliance-driver-app-android/node_modules/@react-native-community/cli/build/index.js:192:9)

info Run CLI with --verbose flag for more details. error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

goodjun commented 1 year ago

using mavenCentral() to replace jcenter() fixes ./gradlew clean but while building the android application using yarn leads to: Execution failed for task ':app:checkDebugAarMetadata'.

Could not resolve all files for configuration ':app:debugRuntimeClasspath'. Could not find com.facebook.fresco:stetho:2.2.0. Searched in the following locations:

  • 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.

BUILD FAILED in 44s

at makeError (/home/user/FCS/fleet-compliance-driver-app-android/node_modules/execa/index.js:174:9)
at /home/user/FCS/fleet-compliance-driver-app-android/node_modules/execa/index.js:278:16
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async runOnAllDevices (/home/user/FCS/fleet-compliance-driver-app-android/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:109:5)
at async Command.handleAction (/home/user/FCS/fleet-compliance-driver-app-android/node_modules/@react-native-community/cli/build/index.js:192:9)

info Run CLI with --verbose flag for more details. error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

try upgrade flipper, latest version of Flipper requires react-native 0.69+! If you use react-native < 0.69.0, please use 0.162.0

LeeKyungJoon2 commented 1 year ago

From what I've understood, If you haven't cleaned your project recently, you can switch off the internet and it will build just fine.

But if you wanted to create a release build/test apk and you've cleaned beforehand, you'll need jcenter to work if you have dependencies that exist on jCenter, but not on maven.

In my case I've migrated from 0.60.5 fo 0.66.4 a long time ago, but I hadn't fully upgraded the packages to be supported by maven. So I hadn't deleted jcenter().

This is what happened before removing jCenter().

...Could not determine the dependencies of task ':app:lintVitalRelease'.

Could not resolve all artifacts for configuration ':app:debugRuntimeClasspath'. Could not resolve com.facebook.react:react-native:+. Required by: project :app project :app > project :react-native-share ...

After removing jCenter():

  • What went wrong: Could not determine the dependencies of task ':app:lintVitalRelease'.

Could not resolve all artifacts for configuration ':app:debugCompileClasspath'. Could not find com.otaliastudios:cameraview:2.7.0. ...

So I had to find replacements for the listed dependencies from maven, and the errors disappeared one by one. I have 25+ dependencies though... I hope they fix this soon..

So do I. Too many things to change dependencies. I hope this problem will be solved soon.

ZohaibAhmad786 commented 1 year ago

is there any update on this?