cli icon indicating copy to clipboard operation
cli copied to clipboard

Problem with android/settings.gradle

Open rodrigotoledo opened this issue 9 months ago • 2 comments

Environment

npx react-native doctor passes without errors.

React Native: 0.79.1 Node: 18+ NPM: 9+

Description

I am using the latest version of React Native (0.79.1) and trying to run the project with the latest stable version of @react-native-community/cli.

However, the installed package does not include the expected file: cli-platform-android/native_modules.gradle.

As a result, the build fails when android/settings.gradle tries to execute:

apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle");
applyNativeModulesSettingsGradle(settings);

To temporarily fix the issue, I had to manually comment out these lines in android/settings.gradle:

// apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle");
// applyNativeModulesSettingsGradle(settings);

This behavior is unexpected, considering I am using the latest compatible stable versions.

Reproducible Demo

  • Create a new React Native 0.79.1 project.

  • Install @react-native-community/cli@latest.

  • Run npx react-native run-android.

  • Build fails due to missing native_modules.gradle.

  • Comment out the lines in android/settings.gradle to bypass the error.

rodrigotoledo avatar Apr 28 '25 10:04 rodrigotoledo

I'm also experiencing this with:

cainlevy avatar May 29 '25 21:05 cainlevy

The expected native_modules.gradle file appears to be nothing more than a log warning to upgrade to React Native Gradle Plugin. I'm not sure why this settings.gradle line exists in the project I've inherited, but it seems skippable.

cainlevy avatar May 29 '25 21:05 cainlevy

The settings.gradle file in default template changed in 0.75 and doesn't include calling ../node_modules/@react-native-community/cli-platform-android/native_modules.gradle anymore. See: https://react-native-community.github.io/upgrade-helper/?from=0.71.3&to=0.75.1#RnDiffApp-android-settings.gradle

thymikee avatar Jul 23 '25 18:07 thymikee