I am committing my first Android project to GitHub by following this video. I know that the bin and gen folders must be ignored. Using Eclipse, I did add them to the ignore file.
Now when I
Right Click on Project - Team - Commit
The window that comes up shows me the files in "bin" and "res" also. I can uncheck them, that is fine, but will I have to do this silly exercise again and again or maybe I am not understanding something.
Use this for your Android projects. Taken from github gitignore page
# Built application files
*.apk
*.ap_
# Files for the Dalvik VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
# Gradle files
.gradle/
build/
# Local configuration file (sdk path, etc)
local.properties
# Proguard folder generated by Eclipse
proguard/
# Log Files
*.log
Copy and paste this into your .gitignore file:
.settings/org.eclipse.jdt.core.prefs
*/.settings/org.eclipse.jdt.core.prefs
**/bin/*
**/gen/*
**/build/*
**/.idea/*
**/*.iml
.gradle
/local.properties
/.idea/workspace.xml
.DS_Store
.metadata/*
This setup will ignore the irrelevant files and folders.
If you have already committed some of these files, take a look at Ignore files that have already been committed to a Git repository.
Related
My problem is similar to the one outlined in this post, but the solution did not help. I essentially have one Github repository with a whole bunch of different folders/directories that each contain a separate Android project.
The structure of one such project looks like MyTeamRepo -> MyAndroidProject -> app
Normally if it was just a single Android project, throwing the .gitignore in the /gradle directory would work, but it's not working out in my case.
Here's what's currently in my .gitignore:
# Built application files
*.apk
*.ap_
*.aab
# Files for the ART/Dalvik VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
out/
# Gradle files
.gradle/
build/
# Local configuration file (sdk path, etc)
local.properties
# Proguard folder generated by Eclipse
proguard/
# Log Files
*.log
# Android Studio Navigation editor temp files
.navigation/
# Android Studio captures folder
captures/
# IntelliJ
*.iml
.idea/workspace.xml
.idea/misc.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/assetWizardSettings.xml
.idea/dictionaries
.idea/libraries
.idea/caches
# Android Studio 3 in .gitignore file.
.idea/caches/build_file_checksums.ser
.idea/modules.xml
# Keystore files
# Uncomment the following lines if you do not want to check your keystore files in.
#*.jks
#*.keystore
# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild
# Google Services (e.g. APIs or Firebase)
google-services.json
# Freeline
freeline.py
freeline/
freeline_project_description.json
# fastlane
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
fastlane/readme.md
# Version control
vcs.xml
# lint
lint/intermediates/
lint/generated/
lint/outputs/
lint/tmp/
lint/reports/
My problem is I still keep having these .idea and .gradle files popping up everywhere within the subfolders every time I make any changes to the Android project, causing all sorts of merge conflicts when I try to pull changes from Github.
I also think part of the problem is that the .idea had previously been committed to Github and now I am always tracking it.
What steps do I need to take to completely clean my repository and to make sure the .gitignore is doing its job?
If you want to ignore a file anywhere in the tree use something like
**/.idea/modules.xml
and no matter where the .idea directory is that the modules.xml file will be ignored.
I tried to find solution for me but my .gitignore file still doesn't work
I see this post, but it doesn't help me.
This is my gitignore file:
# Created by https://www.gitignore.io/api/android,macos
### Android ###
# Built application files
*.apk
*.ap_
# Files for the ART/Dalvik VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
out/
# Gradle files
.gradle/
build/
# Local configuration file (sdk path, etc)
local.properties
# Proguard folder generated by Eclipse
proguard/
# Log Files
*.log
# Android Studio Navigation editor temp files
.navigation/
# Android Studio captures folder
captures/
# Intellij
*.iml
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/dictionaries
.idea/libraries
# Keystore files
*.jks
# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild
# Google Services (e.g. APIs or Firebase)
google-services.json
# Freeline
freeline.py
freeline/
freeline_project_description.json
### Android Patch ###
gen-external-apklibs
### macOS ###
*.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
But when I make rebild I see this in SourceTree:
All files from libraryProjectFolder/Build folder
()
I have a situation that I added a file on gitignore and for some reason that I don’t know it doesn't recognize this file on gitignore and still showing it on my working area. To ignore this file I used the command below:
git rm --cached myfile
I hope it can help anyone in the future.
Git is already tracking those files, that's why you still see them.
You should create the .gitignore BEFORE doing any commit.
You can refer to the following post if you want to untrack those files. If the project is new you could create a new repository, copy your files over and make sure you have the .gitignore file in your new repo before doing the first commit.
This will function for me. I didn't know what was the reason. I modified my gitignore but always appeared the files I filtered.
That's what i made:
I untracked unneccesary files-
Include gitignore patterns
Commit changes.
Actually my repository works fine.
I have just sync my GitHub with Android Studio and I create a new project. I want to push it in my git repository. Last time when I did this with my previous android project, I saw that some foldres like .idea, gradle and other files out of the app folder are never updated again. They are staying like the first commit. So tell me - which folders I have to upload for full application without any missing recourse and others? Thanks again.
Typical gitignore file for an android project :
#built application files
*.apk
*.ap_
# files for the dex VM
*.dex
# Java class files
*.class
# generated files
bin/
gen/
# Local configuration file (sdk path, etc)
local.properties
# Windows thumbnail db
Thumbs.db
# OSX files
.DS_Store
# Eclipse project files
.classpath
.project
# Android Studio
.idea
#.idea/workspace.xml - remove # and delete .idea if it better suit your needs.
.gradle
build/
You can find sample .gitignore files in GitHub's gitignore repository. The one for Android is:
# Built application files
*.apk
*.ap_
# Files for the Dalvik VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
# Gradle files
.gradle/
build/
# Local configuration file (sdk path, etc)
local.properties
# Proguard folder generated by Eclipse
proguard/
# Log Files
*.log
You can also add your IDE related files and directories to this .gitignore file. For example for Android Studio:
# Android Studio
*.iml
*.ipr
*.iws
.idea/
I have used Eclipse and SVN for a while. However, I'm still not clear which files/folders usually should be ignored while commit the whole project to repository. I know .project needs to be ignored. What about others? By the way this is an android project. However, answers to general project are also welcome.
Thanks.
We are using configuration as below to support different IDE:
# Eclipse related (and M2e)
.classpath
.project
.settings/
.metadata/
test-output/
# Maven related (and some plugins)
target/
*~
dist
*.ser
*.ec
# Intellij
*.ipr
*.iml
*.iws
.idea
.temp
# Other
.svn/
bin/
bak/
*.log
*.orig
*.versionsBackup
Basically following list of files added in .gitignore file for android projects.
# Built application files
*.apk
*.ap_
# Files for the Dalvik VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
# Gradle files
.gradle/
build/
# Local configuration file (sdk path, etc)
local.properties
# Proguard folder generated by Eclipse
proguard/
Which files in an Android project should be committed to a version control repository? Which files should not be committed?
Right now my .gitignore file consists of the following lines:
# Android generated files #
###########################
android.keystore
local.properties
bin/
gen/
libs/
obj/
# OS generated files #
######################
.DS_Store*
ehthumbs.db
Icon?
Thumbs.db
# Eclipse generated files #
###########################
.settings/org.eclipse.jdt.core.prefs
Am I missing anything?
GitHub maintains an official list of recommended .gitignore files at this public repository.
For Android you can find it here
Or just copy/paste :
# Built application files
*.apk
*.aar
*.ap_
*.aab
# Files for the ART/Dalvik VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
out/
# Uncomment the following line in case you need and you don't have the release build type files in your app
# release/
# Gradle files
.gradle/
build/
# Local configuration file (sdk path, etc)
local.properties
# Proguard folder generated by Eclipse
proguard/
# Log Files
*.log
# Android Studio Navigation editor temp files
.navigation/
# Android Studio captures folder
captures/
# IntelliJ
*.iml
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/assetWizardSettings.xml
.idea/dictionaries
.idea/libraries
# Android Studio 3 in .gitignore file.
.idea/caches
.idea/modules.xml
# Comment next line if keeping position of elements in Navigation Editor is relevant for you
.idea/navEditor.xml
# Keystore files
# Uncomment the following lines if you do not want to check your keystore files in.
#*.jks
#*.keystore
# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild
.cxx/
# Google Services (e.g. APIs or Firebase)
# google-services.json
# Freeline
freeline.py
freeline/
freeline_project_description.json
# fastlane
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
fastlane/readme.md
# Version control
vcs.xml
# lint
lint/intermediates/
lint/generated/
lint/outputs/
lint/tmp/
# lint/reports/
The general rule of thumb is to not commit any file that can be re-generated, into the repository. Having said that, you may want to add your project.properties file to .gitignore as well (if it exists).
don't add bin folder and gen folder. They are not part of your sources they are generated. In future remember that you add only files necessary to build and run your project, and binary and generated files are not.
Yet if you're not using any tool like ivy or maven you may want your lib folder to present. Often when you use a library project, you also need to commit it
As of Android Studio 2.2.2 (and was probably added well before this version) when you create a new project, Google add a default .gitignore file to the project for you with the following contents:
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild
A little different from the above answers, as it also ignores the .idea folders, which tend to have a lot of files in them.
Using darcs, one adds the tracked files explicitly, rather than excluding them with an ignore file. After creating the new android project, I recorded my initial commit with all .java, .xml, .gradle, .properties, and .webp files added, except for local.properties.
This command did that:
( fd .*.java & fd .*.xml & fd .*.gradle & fd .*.properties & fd .*.webp; )
| cat
| rg -v ^local.properties
| xargs -I {} darcs add {}