React Native and build.gradle
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
Thanos
EngD student in Model-driven Software Engineering. MSc in Software Engineering. BSc in Applied Informatics.
Updated on July 02, 2022Comments
-
Thanos almost 2 years
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 runreact-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
-
Thanos over 5 yearsThe react native's genarated .gitignore ignores it. Is it wrong?
-
K.. over 5 yearsI think it's wrong. It didn't do so in my apps and I have some custom code in it, which is needed by other devs to build.
-
Thanos over 5 yearsI am afraid that although your logic seems correct, I still somehow have the problem. Unless I explicitly ask the default gitignore not to ignore it (i.e., !android/build.gradle), it ignores it. I tried it in a fresh project. What am I missing?
-
Bhagwat K over 5 yearsCan you add your .gitignore file content? So I can try to help you in that case.
-
Thanos over 5 yearsUploaded the gitignore file.
-
Morris over 2 yearsIt's September 2021 today, and RN includes
android/gradle.properties
file in git. reactnative.dev/docs/signed-apk-android said to put some credentials likeMYAPP_UPLOAD_KEY_PASSWORD
inandroid/gradle.properties
. Does anyone know if this practice is secure? I disagree with putting plain passwords in any git-checked file.