Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

React Native Android build cannot find the foojay-resolver-convention plugin

ErrorPlugin [id: 'org.gradle.toolchains.foojay-resolver-convention', version: '0.5.0'] was not found in any of the following sources:

Short answer

The foojay plugin is a settings plugin that Gradle downloads from the Plugin Portal. It is not found when pluginManagement leaves the portal out of its repositories, when the plugins block is not first in settings.gradle, or when the old 0.x version meets Gradle 9, which it does not support. Fix the one the output shows.

  • Applies to React Native 0.7x to 0.8x, Gradle 8.x and 9.x, JDK 17
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Open android/settings.gradle and read it from the top, then ask the wrapper which Gradle version runs the build. The error lines also name the sources Gradle searched.

    cd android
    sed -n 1,20p settings.gradle
    ./gradlew --version
  2. 2Match what you see, then jump to its fix

    1. 1The pluginManagement block has a repositories list that does not contain gradlePluginPortal().pluginManagement does not list the Gradle Plugin PortalFix
    2. 2The error comes from settings.gradle and the plugins block sits below other code.The plugins block is not the first block in settings.gradleFix
    3. 3./gradlew --version prints Gradle 9, or the plugin version in settings.gradle is below 1.0.0.An old 0.x plugin version on a Gradle version it does not supportFix

What does the error look like?

  • Plugin [id: 'org.gradle.toolchains.foojay-resolver-convention', version: '0.5.0'] was not found in any of the following sources:
  • Plugin [id: 'org.gradle.toolchains.foojay-resolver-convention'] was not found in any of the following sources:

Cause 1 of 3

pluginManagement does not list the Gradle Plugin Portal

1Check

The Gradle docs say plugins resolve from the Plugin Portal by default, and that a pluginManagement repositories list without gradlePluginPortal() removes the portal from the search. Look for a repositories block in the pluginManagement section of settings.gradle.

grep -n -A8 "pluginManagement" android/settings.gradle

2Fix

Add gradlePluginPortal() to the list. Keep the pluginManagement block as the first block in the file.

pluginManagement {
    repositories {
        gradlePluginPortal()
        google()
        mavenCentral()
    }
    includeBuild("../node_modules/@react-native/gradle-plugin")
}

3Verify

Run any Gradle task from the android folder and confirm settings are evaluated.

cd android && ./gradlew help

Confirmed by docs.gradle.org

Did this fix it?

Cause 2 of 3

The plugins block is not the first block in settings.gradle

1Check

The Gradle docs say the plugins block in a settings file must appear before any other block there, except pluginManagement which has to be first of all.

grep -n "pluginManagement\|^plugins\|include" android/settings.gradle

2Fix

Order the file as pluginManagement, then plugins, then the rest.

pluginManagement { /* ... */ }
plugins {
    id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0"
}
rootProject.name = 'MyApp'

3Verify

Run the help task again.

cd android && ./gradlew help

Confirmed by docs.gradle.org

Did this fix it?

Cause 3 of 3

An old 0.x plugin version on a Gradle version it does not support

1Check

The foojay README says versions before 1.0.0 work with Gradle 7.6 through 8.14.x, and versions from 1.0.0 need Gradle 7.6 or later and Java 17 or later.

./gradlew --version
grep -n "foojay" android/settings.gradle

2Fix

Raise the plugin to 1.0.0 or later and run Gradle on JDK 17 or newer. If your Gradle itself is below 7.6, update the wrapper; the Gradle docs say to run the wrapper task, twice to refresh all wrapper files.

id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0"
# only if Gradle is below 7.6:
./gradlew :wrapper --gradle-version <version>

3Verify

Run the version check, then a task.

./gradlew --version && ./gradlew help

Confirmed by github.com

Did this fix it?

How do I stop it coming back?

  • Take the settings.gradle from the template of the React Native version you upgrade to, and merge changes by hand.
  • Upgrade the Gradle wrapper and the foojay plugin together.
  • Pin the plugin to an exact version, not a range.
  • Use the same JDK in Android Studio, the terminal and CI.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.