Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native and build.gradle

I am new to React Native and I work with a colleague on a new app. I created a new react native project which has generated a .gitgnore file as well. In it all the .gradle files (and thus the build.gradle file inside /android/ folder) are ignored.

When I pushed the project to Github and my colleague pulled, he npm install to download the node_modules (which are also excluded <- I have read the rational behind this) and then he run react-native run-android. This failed. We realised that if he creates the build.gradle file inside /android/ and copy-paste the contents of my build.gradle which I have locally (as is ignored by git) everything runs smoothly.

My main questions are: 1) Should the build.gradle file be ignored as react native does by default? 2) If yes, how are teams supposed to work on a react native project if they somehow need to get the build.gradle contents to run the project on their side? 3) What happens if my disk drive fails? I can pull everything from git but I will not have the build.gradle. Should I right it from scratch?

The contents of the .gitignore file:

# OSX
#
.DS_Store

# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
project.xcworkspace

# Android/IntelliJ
#
build/
.idea
.gradle
local.properties
*.iml

# node.js
#
node_modules/
npm-debug.log
yarn-error.log

# BUCK
buck-out/
\.buckd/
*.keystore

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/

*/fastlane/report.xml
*/fastlane/Preview.html
*/fastlane/screenshots

# Bundle artifact
*.jsbundle
like image 416
Thanos Avatar asked Oct 17 '22 10:10

Thanos


1 Answers

It is .gradle file in .gitignore and not the *.gradle or build,gradle.

So the answer to your questions is build.gradle is not ignored and should not have to be ignored.

The android related things included in .gitignore are:

build/
.idea
.gradle
local.properties
*.iml
android/gradle.properties

For standard, you can refer to this below two sample .gitignore file.(you can replace your .gitignore contents with the below link contents and can check.)

enter link description here https://github.com/facebook/react-native/blob/master/.gitignore https://github.com/facebook/react-native/blob/master/local-cli/templates/HelloWorld/_gitignore

like image 64
Bhagwat K Avatar answered Oct 21 '22 05:10

Bhagwat K