Cannot commit android "gen" folder to Git - android

I am using EGit in eclipse to provide Git support for an Android project I am working on. The problem is that after committing my project to the local repository I realized that the "gen" folder was not getting committed. As a result of this when I try to open the project on another machine after getting the latest source from the Git repository I keep getting the following error:
ERROR: Unable to open class file D:\CodeRep\POCs\Java\Android\Sudoku\gen\org\blah\example\R.java: No such file or directory
Why can't I commit the "gen" folder to Git from Eclipse ? Everything gets committed just fine so I can push it to the remote repository.

You shouldn't be commiting the gen folder; it contains generated code and doesn't belong in source control. You should be recreating it on the machine you pull the source code on with either an Eclipse "Project -> Clean" or a command line "ant clean" if you're using the build scripts.

This is a file of generated code, you would normally only be commit sources to git.
You probably need to clean your project when you check it out, perhaps you've got some other object files mistakenly included in the commit so it looks like it's already been built.

It shouldn't be necessary to commit the "gen" directory to git as everything in it should be automatically generated based upon content elsewhere in your source. In fact, the "gen" directory may have been added to your .gitignore by the Android SDK.

Related

GitHub Desktop won't detect changes when I make a build apk?

I'm building a voice recording app and right now I'm backing up all of my code to GitHub and a memory stick. Whenever I make it build it saves it into the file directory that GitHub desktop it's backing up, but it won't detect some of my files. Such as: app.iml and app-debug.apk.
Has anyone else had this problem and if you have fixed it could you tell me how?
Those files shouldn't be committed or relied on since you will need to rebuild the project anyway when you do a fresh checkout. Your code might be different than your compiled code depending of how you added them. Check out this thread that talks about javascript Should compiled JavaScript files be committed to Git repo?
Sounds like Git ignoring files and directories specified in the .gitignore file in the root of your repository directory.
See lines from one of my repositories:
*.iml
..
..
/build
Your apk file is just the latest build of your code, so the source code saved to GitHub is the backup.

How to keep library files out of github in android?

How do I keep library files out of my github repo yet still have them work if someone downloads my code? I get about 600 "changes" each time I make a small change to my code! Also if it changes anything I am using github desktop (not through cmd). Thanks in advance!
you need to use git ignore to ignore your build folders from updating with git. git ignore helps you to make a blacklist of items you dont want to commit everytime.
you can see how to make a git ignore file in below:
How to create .gitignore file
I guess you see changes to the workspace files modified by Android Studio / IntelliJ in the .idea folder. These files are automatically re-generated if you remove them and should be private to each user, i.e. not uploaded to source control with git.
Step by step fix
Close Android Studio
Remove the .idea folder in your project root (or backup elsewhere for now)
in the .gitignore file in the root of your project, add a line containing just .idea to ignore the folder and its content when you use git
Commit changes to git which should be the removal of the .idea folder & the .gitignore change
Open Android Studio, re-import you project
.idea folder is now regenerated and private to each git user
Run git status to verify

Can't Remove git Sub-Module

I am fairly new to git and had not really utilized the command-line interface until recently. I was trying to start a new private repository on github using Android Studio and made a mistake. I ran the command:
git remote add origin [github.com/location]in two places, one of which was the root folder of the project, and one of which was subfolder containing the java class files. When I tried to add and commit all the files, it wouldn't include the subfolder, giving me the error: fatal: Pathspec 'file' is in submodule 'app/src/...' Before thinking through what I was doing, I tried removing the .git folder from the subfolder. There is no .gitmodules file in the .git folder in the root project folder, so there are no submodules to remove. I'm not sure if this is enough information to go off of so I'm sorry in advance if this sounds vague, but I was hoping someone could help me clear whatever is causing this so I can add this subfolder to the main project and commit it. Thank you!
FIXED:
I figured out that I needed to remove the subfolder and re-add it thusly:
git rm --cached dirname
git add dirname
I also had to get rid of the index.lock file in the base project .git folder in order to do this.
Did you check on the github repo if there is no conflict?
Do you try to commit locally or commit and push?
Did you try to clone the project on a another location?
If you use Windows or Mac, I have a nice tool for git repository Source Tree

Resolve Conflicts Between Two Branches

I'm working on an application and managing its repo on bitbucket.
During the development process, I created a new branch 'price-module' a few days ago and pushed its changes in the remote branch by the same name. Now, when I'm merging 'price-module' to 'master' branch, bitbucket is showing me an error that there are conflicts between some files. (specifically in bin/R.txt). How can I resolve these conflicts and merge the changes I did in 'price-module' to 'master' branch without losing my code?
PS: the project I'm working on is an Android project.
Update: what have I tried so far to solve the problem
I did some research on my own to try and solve the conflict between files. These are the steps I took to solve the conflict:
Switched to master branch, manually overridden the conflicted files by copying them from 'price-module' branch (they are mainly gen or bin), pushed them to master and then tried to merge 'price-module' into 'master' -- FAILED!
Added Android-specific rules in exclude file in my .git folder from this answer but the gen and bin folders kept showing up.
In an Android project, you should not be storing the bin folder in version control in the first place as it contains only generated files. Though R.txt isn't one of them, there's R.java in gen/your/package/name.
Assuming it's the generated bin folder, you should remove it from git, add it to .gitignore so it doesn't show up as non-versioned in git status, merge or re-apply the deletion to both branches, and just let the build tools generate bin files as needed.
For more things to not put in version control, see Typical .gitignore file for an Android app

Mercurial creating extra files after cloning a repo

I am working on an Android App and the APK file is located in the out folder. I am also using Mercurial as version control system and cloned the repo, the clone was successful but Mercurial created two APK files one inside the bin directory and another in the root directory of the project.
Why Mercurial created these extra two APK files and how to get rid of them?
You have these two files in repo, clone just show it to you
You didn't see only these files in original Working Copy, because (not discovered yet) local settings for original workspace now ignore these files (after they was commited to repo - see hg log FILENAME), but adding to ignore-list doesn't mean "automatically forget and remove from repo"
how to get rid of them?
In cloned repo-root create .hgignore, add global pattern for all and any (?) *.apk-file
hg forget both APK (or Forget from CMenu of THG)
commit changes
remove files from WorkingCopy

Categories

Resources