Are you supposed to check-in R.java file in to VCS? - android

Very basic question. I plan to do our builds via Hudson and have android apk files available for download there. Is R.java in the /gen directory something that you check-in with you VCS? Or is it something that needs to be ignored and android sdk will generate every time if it doesn't exist?

The entire gen folder is automatically generated and shouldn't be checked into VCS.

Nothing in gen should go into your repository.
Add gen to your .gitignore to avoid mistakes/cluttered git status.

No, you don't have to include any of the gen/ files. You must exclude the gen directory itself, otherwise you could ran into problems when updating/committing to git or any other VCS.

You need to ignore this file. Ant build task create this file.

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.

Android Studio keeps adding additional files to GitHub

I'm using Android Studio 2.2.2, using the built in VCS tool. For some reason, Android Studio automatically adds a bunch of extra xml files and folders that I did not add nor edit.
More specifically, it's adding the following files when I don't want it to:
/_windows
IntelliLang.xml
debugger.xml
diff.xml
vcs.xml
web-browsers.xml
This makes making pull requests downright impossible as the master branch doesn't have these files, and none of my other group members seem to have this problem either.
Any help in removing / configuring Android Studio to stop this pesky bug?
--
edit: I am already using a gitignore file already. The weird thing is that my additional files are in the wrong folder too. Basically, my root folder, has a subfolder for my app. All the junk files are created in my root folder for some reason by Android Studio.
/root/
/_windows
IntelliLang.xml
debugger.xml
diff.xml
vcs.xml
web-browsers.xml
/my_android_app/
gitignore for my app
/files actually needed for my project
Turns out this feature is called "Settings Repository", and it's intended to save IDE settings automatically. I guess I might accidentally agree on some popup from IDEA which look like add files to the git repository, so this started working.
FIX: Open Preferences → Tools → Settings Repository → Delete. I also disabled Auto-Sync. Dunno where it's going to save if I delete everything, but I switch it off to be extra safe..
Use gitIgnore file.. i am currently using this .
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
.externalNativeBuild
/captures
check if the same works for you or not ..
if you want to know the details please check here
If the IDE you are using is adding files that it requires, but which you don't want to be included in your repository, then this is a good candidate for additions to your .gitingore file.
Are you currently using a .gitignore file?
More information can be found here:
https://git-scm.com/docs/gitignore
You basically add an entry for each file or folder you want to ignore, and as a result, git will no longer try to include these files in commits going forward.
There is a good resource here:
https://github.com/github/gitignore
For creating a default .gitignore file. You would pick the .gitignore template that closely matches the type of development that you are doing, and customize from there. For example, I always start with the default Visual Studio template.
Probably the best suggestion would be to use the template .gitignore file for Android Development which is located here:
https://github.com/github/gitignore/blob/master/Android.gitignore
NOTE: I would copy the contents of this linked file into this answer, however, these template .gitignore files are always changing, as new recommendations are being added. It is best to keep referring to the source file for the most up to date version.
It doesn't explicitly ignore the files that you have mentioned, but it could be that those files are created within a folder that is being ignored.

Android eclipse project is broken

After switching to my release branch the project had a missing gen file so I added the gen file from java build path.
Now the assets and the res folders are show like gray packages and not folders and I get the errors like res/values/ is missing.
How to return to the standard android project structure in eclipse?
Is there a standard way of returning to the standard Android project. I have become tired to fix project properties and I have tried to clean and restart eclipse It seams that some project metadata is saved the wrong way.
Thanks .
/gen/ folder is automatically generated during compilation. You should include that and /bin/ and also /.properties/ to .gitignore to avoid having to fix properties all the time and also minimise the amount of unnecessary data stored in your repo.

How can it be two AndroidManifest.xml files on a single android project

I learned that in every project we have only 1 AndroidManifest.xml file.
BUT I found two of the same file name !!
One is in the root folder, and the other is in the /bin folder...
How come, and what shell I do ?
thx !
project/bin folder is for compiled (to bytecode) source code and project resources.
Do not worry about it, your IDE is handling content of bin folder automaticly.
When all code is compilled, your IDE (I think, it is Eclipse) can build your project.
When your project builds, it creates a copy of itself for execution in the bin folder.
You can ignore everything in the bin folder as its automatically generated and it doesn't require any edit directly of you.
The only AndroidManifest.xml you have to worry about is the one in your root project directory
One is created by the developer (the one in root folder) and the other one (the one in /bin) is created by eclipse or whatever IDE you are using.
The other one is a compiled binary. This is totally fine. You don't have to do anything. Continue developing!

Should R.java be placed under version control

Is R.java file generated by Android SDK on each compile or only when new resources are added using Eclipse? Do I need to put it under version control or not?
The R.java file is generated during resource compilation by aapt tool. You shouldn't add it to source control system.
Also, you should have noted the gen folder where R.java is placed. Your version control system should ignore this folder altogether, not only R.java file inside it. Because this folder is deleted on clean build (not sure about eclipse, but ant script definitely deletes it).
When using Git to control Android projects I add
bin/*
gen/
to .gitignore
You don't need to put it under version control. I think it's on each compile, one every new resource or clean up project.. but need to test to be sure.
I have had projects with R in and out of source control. Both worked.
When the android SDK is loaded into eclipse, it will automatically generate the R.java file. In older versions of the adt, having an incorrect R.java file would give an error, but I believe this is fixed now, and it shouldn't matter either way. If you have the choice though, avoid checking it in.
I would add it to svn:ignore.

Categories

Resources