androidreact-nativeexpo

Can't run npx expo run:android on local machine


When I run npx expo run:android I get the following error:

Plugin [id: 'com.facebook.react.settings'] was not found in any of the following sources:

Here is my settings.gradle

pluginManagement {
  repositories {
    google()
    mavenCentral()
    gradlePluginPortal()
  }

  def rnPath = ["node", "--print",
    "require.resolve('@react-native/gradle-plugin/package.json')"
  ].execute(null, rootDir).text.trim()

  if (rnPath && rnPath != "null") {
    includeBuild(new File(rnPath).getParentFile())
  } else {
    println("⚠️  Could not resolve @react-native/gradle-plugin")
  }

  def expoPath = ["node", "--print",
    "require.resolve('expo-modules-autolinking/android/expo-gradle-plugin/package.json')"
  ].execute(null, rootDir).text.trim()

  if (expoPath && expoPath != "null") {
    includeBuild(new File(expoPath).getParentFile())
  } else {
    println("⚠️  Could not resolve expo-gradle-plugin")
  }
}

plugins {
  id("com.facebook.react.settings")
  id("expo-autolinking-settings")
}

rootProject.name = "test"
include(":app")
project(":app").projectDir = new File(rootDir, "app")

Solution

  • Remove the node_modules and package-lock.json folders. Also delete the android folders by running this command :
    rm -rf android/.cxx android/app/.cxx android/build android/app/build

    Now install again using npm i and then:
    cd android && ./gradlew clean

    If any issues arise also try ./gradlew stop and ./gradlew assembleDebug

    Also run npx expo-doctor to check if any issues arise and fix them.