Plugin [id: 'com.facebook.react.codegen'] was not found when build RN from sources
See original GitHub issueDescription
I got an error when tried to build React-native 0.64.0 from sources
React Native version:
react-native info
info Fetching system and libraries information…
(node:47514) Warning: Accessing non-existent property ‘padLevels’ of module exports inside circular dependency
(Use node --trace-warnings ...
to show where the warning was created)
System:
OS: macOS 11.2.3
CPU: (8) x64 Intel® Core™ i7-4770HQ CPU @ 2.20GHz
Memory: 315.03 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 14.14.0 - /usr/local/bin/node
Yarn: 1.22.10 - /usr/local/bin/yarn
npm: 6.14.8 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.10.1 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 14.4, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2
Android SDK:
API Levels: 28, 29, 30
Build Tools: 28.0.3, 29.0.2, 29.0.3, 30.0.0, 30.0.1, 30.0.2
System Images: android-23 | Google APIs Intel x86 Atom, android-23 | Google APIs Intel x86 Atom_64, android-30 | Google APIs Intel x86 Atom
Android NDK: 21.4.7075529
IDEs:
Android Studio: 4.1 AI-201.8743.12.41.7042882
Xcode: 12.4/12D4e - /usr/bin/xcodebuild
Languages:
Java: 1.8.0_271 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 17.0.1 => 17.0.1
react-native: github:facebook/react-native#master => 1000.0.0
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found
Steps To Reproduce
- Created empty RN project using command
npx react-native init AwesomeProject
- Started empty project
npx react-native run-android
- Prepared project for building from source
3.1. Installing the fork
First, you need to install react-native from your fork. For example, to install the master branch from the official repo, run the following:
npm install --save github:facebook/react-native#master
3.2. Adding gradle dependencies
Add gradle-download-task as dependency in android/build.gradle:
… dependencies { classpath ‘com.android.tools.build:gradle:4.1.0’ classpath ‘de.undercouch:gradle-download-task:4.0.0’
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
… 3.3. Adding the :ReactAndroid project
Add the :ReactAndroid project in android/settings.gradle:
… include ‘:ReactAndroid’
project(‘:ReactAndroid’).projectDir = new File( rootProject.projectDir, ‘…/node_modules/react-native/ReactAndroid’) … Modify your android/app/build.gradle to use the :ReactAndroid project instead of the pre-compiled library, e.g. - replace implementation ‘com.facebook.react:react-native:+’ with implementation project(‘:ReactAndroid’):
… dependencies { implementation fileTree(dir: ‘libs’, include: [‘*.jar’])
implementation project(':ReactAndroid')
...
}
- Start app
react-native run-android
Expected Results
App should be built and start on previously connected phone in debug mode
Actual results
-
Where: Build file ‘/Users/sergey/kamino/AwesomeProject/node_modules/react-native/ReactAndroid/build.gradle’ line: 10
-
What went wrong: Plugin [id: ‘com.facebook.react.codegen’] was not found in any of the following sources:
- Gradle Core Plugins (plugin is not in ‘org.gradle’ namespace)
- Plugin Repositories (plugin dependency must include a version number for this source)
Issue Analytics
- State:
- Created 3 years ago
- Reactions:6
- Comments:14 (1 by maintainers)
Top GitHub Comments
Finally, I have resolved the problem in my way. In my settings.gradle, I added these:
The problem here is that when I installed RN
0.64.1
, folderpackages/react-native-codegen
does not include theandroid
folder, it just contains some prebuilded JS scripts. So I need to go to GitHub and copy these files from branch0.64.1
.I think RN team should update “building from source” documentation.
Hey folks, wanted to share how we got this working on our end.
react-native
0.64-stable
for0.64.2
)packages/react-native-codegen
over tonode_modules/react-native
ReactAndroid
from source: https://gist.github.com/Ashoat/52e44f6f1e452559c4401d48b235494fsettings.gradle
patch may need an extra../
in some places to work correctly.