react-native: Could not find com.facebook.react:react-native-gradle-plugin:.
New Version
0.71.11
Old Version
0.67.5
Build Target(s)
While building for Android
Output of react-native info
System:
OS: macOS 13.1
CPU: (8) arm64 Apple M1
Memory: 106.58 MB / 16.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 18.13.0 - ~/.nvm/versions/node/v18.13.0/bin/node
Yarn: 1.22.19 - ~/.nvm/versions/node/v14.20.0/bin/yarn
npm: 8.19.3 - ~/.nvm/versions/node/v18.13.0/bin/npm
Watchman: 2023.01.09.00 - /opt/homebrew/bin/watchman
Managers:
CocoaPods: 1.11.3 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1
Android SDK: Not Found
IDEs:
Android Studio: 2021.2 AI-212.5712.43.2112.8609683
Xcode: 14.2/14C18 - /usr/bin/xcodebuild
Languages:
Java: 11.0.17 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 18.2.0 => 18.2.0
react-native: 0.71.11 => 0.71.11
react-native-macos: Not Found
npmGlobalPackages:
*react-native*: Not Found
Issue and Reproduction Steps
While building the app for Android after upgrading React Native I’m getting this error
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'App'.
> Could not determine the dependencies of null.
> Could not resolve all task dependencies for configuration ':classpath'.
> Could not find com.facebook.react:react-native-gradle-plugin:.
Required by:
project :
Thing’s I’ve tried
- Clearing gradle cache
- Clearing build cache for android
- Reseting cache using --reset-cache
- Tried other solution listed on similar issues from GitHub and StackOverflow
Files -
package.json
{
"name": "App",
"version": "1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint .",
"clean": "cd android && ./gradlew clean && cd ..",
"build": "cd android && ./gradlew clean && ./gradlew bundleRelease && cd .. && react-native run-android --variant=release",
"build:prod": "cd android && ./gradlew clean && ./gradlew app:bundleRelease"
},
"dependencies": {
"@datadog/mobile-react-native": "^1.0.0-rc5",
"@datadog/mobile-react-navigation": "^1.0.0-rc5",
"@invertase/react-native-apple-authentication": "^2.2.2",
"@ptomasroos/react-native-multi-slider": "^2.2.0",
"@react-native-clipboard/clipboard": "^1.8.5",
"@react-native-community/art": "^1.2.0",
"@react-native-community/async-storage": "^1.8.1",
"@react-native-community/datetimepicker": "^6.1.3",
"@react-native-community/masked-view": "^0.1.7",
"@react-native-community/push-notification-ios": "^1.10.1",
"@react-native-firebase/analytics": "^14.4.0",
"@react-native-firebase/app": "^14.4.0",
"@react-native-firebase/crashlytics": "^14.4.0",
"@react-native-firebase/dynamic-links": "^14.4.0",
"@react-native-firebase/messaging": "^14.4.0",
"@react-navigation/native": "^5.0.9",
"@react-navigation/stack": "^5.1.1",
"@shopify/flash-list": "^1.4.0",
"algoliasearch": "3.32.0",
"axios": "^0.19.1",
"babel-plugin-transform-remove-console": "^6.9.4",
"color": "^3.1.2",
"dayjs": "^1.8.25",
"eventemitter3": "^4.0.0",
"formik": "^2.1.4",
"imagekit-javascript": "^1.4.0",
"jwt-decode": "^3.1.2",
"lodash.isequal": "^4.5.0",
"prop-types": "^15.7.2",
"react": "18.2.0",
"react-native": "0.71.11",
"react-native-animatable": "^1.3.3",
"react-native-check-box": "^2.1.7",
"react-native-code-push": "^6.3.0",
"react-native-fast-image": "^8.6.3",
"react-native-fbsdk": "^1.1.2",
"react-native-gesture-handler": "^1.4.1",
"react-native-google-signin": "^2.1.1",
"react-native-image-crop-picker": "^0.36.0",
"react-native-image-zoom-viewer": "^2.2.27",
"react-native-inappbrowser-reborn": "^3.7.0",
"react-native-keyboard-aware-scroll-view": "^0.9.1",
"react-native-linear-gradient": "^2.5.6",
"react-native-modal": "^11.5.6",
"react-native-otp-inputs": "^7.1.1",
"react-native-permissions": "^3.6.0",
"react-native-radio-buttons-group": "^1.0.7",
"react-native-raw-bottom-sheet": "^2.0.6",
"react-native-reanimated": "^1.3.0",
"react-native-safe-area-context": "^0.7.3",
"react-native-screens": "^3.12.0",
"react-native-share": "^8.0.0",
"react-native-size-matters": "^0.3.0",
"react-native-splash-screen": "^3.2.0",
"react-native-status-bar-height": "^2.5.0",
"react-native-svg": "^11.0.1",
"react-native-svg-transformer": "^0.14.3",
"react-native-swiper": "^1.6.0-nightly.5",
"react-native-tab-view": "^2.14.0",
"react-native-toast-message": "^2.1.5",
"react-native-video": "^5.1.1",
"react-native-webengage": "^1.2.12",
"react-native-webview": "^9.4.0",
"react-redux": "^7.1.3",
"recyclerlistview": "^3.0.0",
"redux": "^4.0.5",
"redux-logger": "^3.0.6",
"redux-thunk": "^2.3.0",
"reselect": "^4.0.0",
"yup": "^0.28.3"
},
"devDependencies": {
"@babel/core": "^7.20.0",
"@babel/preset-env": "^7.20.0",
"@babel/runtime": "^7.20.0",
"@react-native-community/eslint-config": "^3.2.0",
"babel-jest": "^29.2.1",
"eslint": "^8.19.0",
"jest": "^29.2.1",
"metro-react-native-babel-preset": "0.73.10",
"prettier": "^2.4.1",
"react-test-renderer": "18.2.0",
"babel-loader": "^8.0.6",
"babel-plugin-module-resolver": "^4.0.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jsx-a11y": "^6.6.0",
"eslint-plugin-react": "^7.30.1",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-native": "^4.0.0"
},
"jest": {
"preset": "react-native"
}
}
android/build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "33.0.0"
minSdkVersion = 21
compileSdkVersion = 33
targetSdkVersion = 33
// We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
ndkVersion = "23.1.7779620"
kotlinVersion = "1.8.0"
androidXBrowser = "1.4.0"
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:7.3.1")
classpath("com.facebook.react:react-native-gradle-plugin")
classpath("com.google.gms:google-services:4.3.5")
classpath("com.google.firebase:firebase-crashlytics-gradle:2.8.1")
}
}
android/app/build.gradle
apply plugin: "com.android.application"
apply plugin: "com.facebook.react"
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
import com.android.build.OutputFile
/**
* This is the configuration block to customize your React Native Android app.
* By default you don't need to apply any configuration, just uncomment the lines you need.
*/
react {
/* Folders */
// The root of your project, i.e. where "package.json" lives. Default is '..'
// root = file("../")
// The folder where the react-native NPM package is. Default is ../node_modules/react-native
// reactNativeDir = file("../node_modules/react-native")
// The folder where the react-native Codegen package is. Default is ../node_modules/react-native-codegen
// codegenDir = file("../node_modules/react-native-codegen")
// The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js
// cliFile = file("../node_modules/react-native/cli.js")
/* Variants */
// The list of variants to that are debuggable. For those we're going to
// skip the bundling of the JS bundle and the assets. By default is just 'debug'.
// If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
// debuggableVariants = ["liteDebug", "prodDebug"]
/* Bundling */
// A list containing the node command and its flags. Default is just 'node'.
// nodeExecutableAndArgs = ["node"]
//
// The command to run when bundling. By default is 'bundle'
// bundleCommand = "ram-bundle"
//
// The path to the CLI configuration file. Default is empty.
// bundleConfig = file(../rn-cli.config.js)
//
// The name of the generated asset file containing your JS bundle
// bundleAssetName = "MyApplication.android.bundle"
//
// The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
// entryFile = file("../js/MyApplication.android.js")
//
// A list of extra flags to pass to the 'bundle' commands.
// See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
// extraPackagerArgs = []
/* Hermes Commands */
// The hermes compiler command to run. By default it is 'hermesc'
// hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc"
//
// The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
// hermesFlags = ["-O", "-output-source-map"]
}
/**
* Set this to true to create four separate APKs instead of one,
* one for each native architecture. This is useful if you don't
* use App Bundles (https://developer.android.com/guide/app-bundle/)
* and want to have separate APKs to upload to the Play Store.
*/
def enableSeparateBuildPerCPUArchitecture = false
/**
* Set this to true to Run Proguard on Release builds to minify the Java bytecode.
*/
def enableProguardInReleaseBuilds = false
/**
* The preferred build flavor of JavaScriptCore (JSC)
*
* For example, to use the international variant, you can use:
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
*
* The international variant includes ICU i18n library and necessary data
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
* give correct results when using with locales other than en-US. Note that
* this variant is about 6MiB larger per architecture than default.
*/
def jscFlavor = 'org.webkit:android-jsc:+'
/**
* Private function to get the list of Native Architectures you want to build.
* This reads the value from reactNativeArchitectures in your gradle.properties
* file and works together with the --active-arch-only flag of react-native run-android.
*/
def reactNativeArchitectures() {
def value = project.getProperties().get("reactNativeArchitectures")
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
}
android {
ndkVersion rootProject.ext.ndkVersion
compileSdkVersion rootProject.ext.compileSdkVersion
namespace "com.app"
defaultConfig {
applicationId "com.app"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1"
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
resValue 'string', "CODE_PUSH_APK_BUILD_TIME", String.format("\"%d\"", System.currentTimeMillis())
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include (*reactNativeArchitectures())
}
}
signingConfigs {
debug {
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
release {
if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
storeFile file(MYAPP_RELEASE_STORE_FILE)
storePassword MYAPP_RELEASE_STORE_PASSWORD
keyAlias MYAPP_RELEASE_KEY_ALIAS
keyPassword MYAPP_RELEASE_KEY_PASSWORD
}
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
// Caution! In production, you need to generate your own keystore file.
// see https://reactnative.dev/docs/signed-apk-android.
signingConfig signingConfigs.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:
// https://developer.android.com/studio/build/configure-apk-splits.html
def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
defaultConfig.versionCode * 1000 + versionCodes.get(abi)
}
}
}
}
dependencies {
// The version of react-native is set by the React Native Gradle Plugin
implementation("com.facebook.react:react-android")
// Add the Firebase SDK for Google Analytics
implementation("com.google.firebase:firebase-analytics:18.0.2")
// Add the SDK for Firebase Cloud Messaging
implementation("com.google.firebase:firebase-messaging:22.0.0")
// For animated GIF support
implementation("com.facebook.fresco:fresco:2.+")
implementation("com.facebook.fresco:animated-gif:2.+")
implementation("androidx.appcompat:appcompat:1.0.0")
implementation("com.webengage:android-sdk:3.+")
implementation("com.android.installreferrer:installreferrer:1.1.1")
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0")
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
exclude group:'com.squareup.okhttp3', module:'okhttp'
}
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}")
if (hermesEnabled.toBoolean()) {
implementation("com.facebook.react:hermes-android")
} else {
implementation jscFlavor
}
}
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"
settings.gradle
rootProject.name = 'App'
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':react-native-code-push'
project(':react-native-code-push').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-code-push/android/app')
include ':react-native-video'
project(':react-native-video').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-video/android-exoplayer')
include ':app'
includeBuild('../node_modules/react-native-gradle-plugin')
Screenshot
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 6
- Comments: 27 (8 by maintainers)
Closing as @nikit-psl is unresponsive.
This issue is most likely caused from a wrong
settings.gradle
file in your project.Specifically, if you’re on React Native 0.72+, that file should look as follows: https://github.com/facebook/react-native/blob/79c4ec1a9a27dc0fd76c1a65ebcb77257d3d4095/packages/react-native/template/android/settings.gradle#L2-L4
If you’re on React Native <= 0.71, it should look as follows: https://github.com/facebook/react-native/blob/7636e4c10209ab26b0d9f79ca34d08e874635dd1/template/android/settings.gradle#L2-L4
this error may be caused by incorrect jdk version in android studio
I had this same issue which I’m pretty sure was due to incorrect java version (8). It resolved after switching java version to 11. https://reactnative.dev/docs/next/environment-setup?platform=android#jdk
This works for me. Thx all!
RN 73.5, gradle 8.4, android gradle 8.3.0
package.json “@react-native/gradle-plugin”: “^0.73.4”,
android/build.gradle buildscript { ext { kotlin_version = ‘1.9.22’ buildToolsVersion = “34.0.0” minSdkVersion = 30 compileSdkVersion = 34 targetSdkVersion = 34
settings.gradle apply from: file(“…/node_modules/@react-native-community/cli-platform-android/native_modules.gradle”); applyNativeModulesSettingsGradle(settings) include ‘:app’ includeBuild(‘…/node_modules/@react-native/gradle-plugin’)
In my settings.gradle, I had to change
includeBuild('../node_modules/@react-native/gradle-plugin')
toincludeBuild('../node_modules/react-native-gradle-plugin')
in order match the
classpath
in the build.gradle ofclasspath("com.facebook.react:react-native-gradle-plugin")
However, I noticed that the
@react-native/gradle-plugin
package has the latest updates on NPM and thatreact-native-gradle-plugin
is likely deprecated or will be soon. The only issue with using the@react-native/gradle-plugin
version is that I don’t know how to add the correct syntax in theclasspath
.I tried this, for example, which doesn’t work:
classpath("com.facebook.react:@react-native/gradle-plugin")
Does anybody know how to write that syntax correctly so it lines up with the new package name?
Thanks for sharing. Unfortunately I can’t help you further without a reproducer.