How do I handle .gitignore in Android Studio? - android

To start, excuse my noob-ness as I'm pretty new.
I want to be able to work on an Android project between my desktop and laptop computers, but I'm having an issue with figuring out how to push and pull the files between computers.
I suppose one of my largest issues is I really don't understand gradle. But it seems to always be very important, and extremely fragile, cause it breaks everything any time I update something, or to import a project.
I set up my project with VCS, and it seemed to auto-generate a .gitignore with the necessary things, but when I pushed it to github through Android Studio it seemed to just push everything in the gitignore anyway.
I thought maybe this wouldn't matter, and tried to import the project onto my other machine, but it blew up anyway and told me it was missing modules or something. I'd try to fix this manually but I'd rather figure out how to just make the gitignore work properly. Should I not use the Android Studio VCS and just manually push and pull through bash, or is there something I'm missing?
I can't figure out if my issue is with the export of it to git/Github, or with the pull on my new machine, not having something configured properly.
If it helps, my project is at:
https://github.com/Ashanmaril/Quotr
If someone can tell me what I'm doing wrong, I'd appreciate it.

I think you mean that you pushed .idea folder to github, you should edit .gitignore to have line /.idea/ or just .idea/, you will have to remove .idea folder manually by:
git rm --cached -r .idea
git commit -am 'Removed .idea folder'
git push origin master
The folder with idea config will not be deleted from your disk, only from repo.

Related

Is it safe to delete all the content from .gradle and .idea?

I am facing an issue that I can see a suggestion someone made on a blog that supposedly helped them solve the same issue. The suggestion was to delete all content on .Gradle and .idea folder, followed by gradle re-sync and rebuild all.
I am fairly a beginner and I've never done anything like that, so I am scared of any destructive actions I don't know the results of. Is there anything to be afraid of by this action, or would these files just be regenerated again?
If all good, how is it done properly? Via the explorer? Or via Android Studio?
Thanks!
.gradle/ and .idea/ are safe to delete, though I would have the IDE not be open on that project while you do it. If that is your only project, close Android Studio, then delete those directories using your OS file explorer or the command line. Then, reopen Android Studio, and it will recreate and re-populate those directories.
On top of the other answers be sure to save the content already in the files. For instance, in your app/build.gradle file be sure to save content like your SDK version and dependencies. When your app is rebuilt and synced you may have to find code relying on a certain SDK Version or dependency.

How to keep using git after switch from Windows to Linux (Ubuntu)?

I swapped my OS from Windows to Ubuntu and after installing Android Studio I copied my projects into the new AndroidStudioProjects so the.git folders are in there too. Now, how could I keep tracking my projects to my Github from the same progress I was when I was using windows? Sorry if stupid question btw.
I did copy the .git directory. But if I do git status on the project directory all the files come in red as if they are not being tracked. This is what worried me.
If you copied only the .git folder, git detect that all the files of the working directory has been deleted.
The only thing you have to do is to restore them.
Beware, verify that your working directory is really empty or you could loose files.
If that's the case, just run:
git checkout .
Or (that should be the same) :
git reset --hard HEAD

Cloning AS Project Gradle Error

I'm trying to clone my remote repository for the first time.
I usually work on a desktop, but need to work on a laptop for the time being.
I know that I must have not included the proper gradle files in my pushes. I'm just trying to figure out exactly what I did wrong and find a way to fix it.
I won't be able to get back to my normal workstation until the weekend.
A link to my project on github here
After AS asks me to import project from VCS, it asks to create project from existing files or an external model. I've tried both, but I think the existing files option is what I'm supposed to do. After choosing that, I get the "Migrate Project to Gradle? This project does not use the gradle build....".
I've found quite a few posts about this topic, but none of them seem to be exactly what I'm going through.
It looks like a bunch of files are missing in the root of the project. Normally there is a master build.gradle at the same level as app that directs the build. This project doesn't have one.
What I would do is create a new project from scratch in a different space and copy its build.gradle, gradlew, gradle.bat, settings.gradle, and .gradle directory into a clean clone of your project and try again, choosing the root of your project as the import location.
I don't 100% guarantee this will work as there may have been modifications made to any of those file that may have been lost, but this should bootstrap your project again.
Also make sure a .gitignore isn't somehow ignoring these files so you can commit them back to your project. They really do need to live in source control.

Git and Android Studio nightmare Version Control

Yes i'm new in git, but as far as i can see it's a pain.
Assuming that:
I'm working on Windows 7 64 bit
Git perfectly installed
Using an Assembla repo which i'm currently using with Eclipse and SVN
I'm now developing with the absolute latest version of Android Studio (updated just 2 days ago...)
I want to ask here, if is my lack of expertise, or it's simply inferior to SVN (which also gives me a bunch of problems in Android Studio, when in Eclipse i can work like a charm!).
This is what i've done:
- made a project and decide to add to Version Control
- went in project dir and get Bash console.
- "git init" and there aren't all the files under git control because of this ignore list (why and how git decides alone that there are things to ignore here, is a mistery, if someone could explain that would be awesome.)
- Deleted ".ignoregit" file list and give a "git add ."
- now it seems everything's under VC but if when i drilled down in project tree i've found for example "build" folder not checked with git sign icon.
Tried every command like "add -f" and "add *" and such, no way.
Sometimes it seems fooling me around adding something that wasn't added before, but remove something else from the list of versione files!
Really really inexplicable.
Thanks
If you're going to use git I recommend you go through this quick tutorial http://www.gitimmersion.com. It takes about 2 hours all-in, but you'll have a strong foundation in git when you're done.
why and how git decides alone that there are things to ignore here
The gitignore files are not created by git but I asume by Android studio and they do make sense. You can still decide to delete them.
You probably have 2 gitignore files, one in the project folder, one in the app module folder.
After deleting them both, all files should be added.

git eclipse pulls no project

I am new to working with repositories.
I'm forced to work with my team on academic project using git. My job is to write Android app.
The problem is when I wrote it, then pushed it to repo I want to pull it on different machine.
But when I pull it, I get only "source" files, no: (for example) R.java.
Moreover: I wanted to use "Clean project" Option, but it seems, that my Eclipse is not treating the pulled files as project (when I click "Clean..." I can choose any project in my workspace, but the download one is lacking).
Anyone could help me?
EDIT:
I've solved the problem:
Git doesn't push to repository automatic-generated files, like R.java. After you pull it back, you have to Clear project and rebuilt it. If it still doesn't work: try restarting Eclipse

Categories

Resources