'Could not resolve all artifacts for configuration ':react-native-safe-area-context:classpath'

I have created a boilerplate react-native application and then trying to add react-navigation to it. However the moment I add dependencies for "react-native-safe-area-context": "^4.2.5", I started getting following error in my build:

   yarn run v1.22.10
$ react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1379 file(s) to forward-jetify. Using 8 workers...
info JS server already running.
info Installing the app...

> Configure project :react-native-safe-area-context
[Fatal Error] semver4j-0.16.4.pom:2:1: Content is not allowed in prolog.

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':react-native-safe-area-context'.
> Could not resolve all artifacts for configuration ':react-native-safe-area-context:classpath'.
   > Could not resolve com.github.gundy:semver4j:0.16.4.
     Required by:
         project :react-native-safe-area-context > org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10
      > Could not resolve com.github.gundy:semver4j:0.16.4.
         > Could not parse POM https://repo.maven.apache.org/maven2/com/github/gundy/semver4j/0.16.4/semver4j-0.16.4.pom
            > Content is not allowed in prolog.

I am not sure what exactly is causing this issue as I am still using mostly the standard boilerplate code. My build.gradle looks like below:

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

buildscript {
    ext {
        buildToolsVersion = "30.0.2"
        minSdkVersion = 21
        compileSdkVersion = 30
        targetSdkVersion = 30
        ndkVersion = "21.4.7075529"
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:4.2.2")
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenCentral()
        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()
        maven { url 'https://www.jitpack.io' }
    }
}


Solution 1:[1]

Strange! but it was issue with my internet connection

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Vitthal Kulkarni