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

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

Related

How do I handle .gitignore in Android Studio?

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.

Android Studio integration with GitHub failing to upload project files apart from MainActivity.java

I have recently created a new Android application and have used its VCS to integrate with GitHub. My problem is that although the integration appears to work, the only file in my Android application that has been saved to GitHub is MainActivity.java. I have tried to add files into GitHub but via the Website but this fails as there are too many files and it doesnt allow Folders to be added.
Has anyone else had this issue?
It's frustrating as when I make changes to MainActivity.java it gets saved and committed/pushed okay but the VCS in Android just doesn't see the other files I have changed such as the content_main.xml which I changed to see if it would then be added to GH.
I cannot seee how to add files within Android Studio to GH via VCS. Does anyone have any pointers where I may start? Thanks!
NB I have had a look through existing questions but none address my issue as far as I can tell.
Usually when you start a new project, Go on VCS -> Enable Version Controle Integration.
Then you should have the Version Control accessible on the Bottom Left of the IDE.
In the tab Local Changes, you will see Default and Unversioned Files.
Just take files from Unversioned Files to Default to start to track them.
To my shame once I checked Xiaomis suggestion I could see that my git was pointing to a directory lower than my /app directory. I tried to change in in my GitHub shell but was unable to do this as GitHub Desktop shell didn't recognise the new directory.
To fix my muddle I deleted my original repo and delted the .gitignore file and other git files from my Android project folder. I then opened Android Studio and went through the process of creating a new repo from there, circumventing GitHub entirely. This worked and enabled me to select my /app directory as the Git root.
Thanks go to Xiaomi who's suggestion made me notice that git was looking at the wrong root. Live and learn!

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.

How do I export an Android Studio project?

I just started using the Android Studio IDE and I already released and published a simple APK to Google Play store.
The problem is that I did this at work.
Now I downloaded the Android Studio at my home and I want to continue working and fixing bugs on my Project.
I see that there is Import Project in the Android Studio home screen, but from where I export the project in order to import it?
I tried Zipping my whole Project folder and import it but it didn't work very well.
In the Android Studio go to File then Close Project. Then take the folder (in the workspace folder) of the project and copy it to a flash memory or whatever. Then when you get comfortable at home, copy this folder in the workspace folder you've already created, open the Android Studio and go to File then Open and import this project into your workspace.
The problem you have with this is that you're searching for the wrong term here, because in Android, exporting a project means compiling it to .apk file (not exporting the project). Import/Export is used for the .apk management, what you need is Open/Close project, the other thing is just copy/paste.
As mentioned by other answers, as of now android studio does not provide this out of the box. However, there are ways to do this easily.
As mentioned by #Elad Lavi, you should consider cloud hosting of your source code. Checkout github, bitbucket, gitlab, etc. All these provide private repositories, some free, some not.
If all you want is to just zip the sources, you can achieve this using git's git archive. Here are the steps:
git init # on the root of the project folder
git add . # note: android studio already created .gitignore
git commit -m 'ready to zip sources'
git archive HEAD --format=zip > /tmp/archive.zip
Note: If you intend to send this by email, you have to remove gradlew.bat from zip file.
Both these solutions are possible thanks to VCS like git.
It seems as if Android Studio is missing some features Eclipse has (which is surprising considering the choice to make Android Studio official IDE).
Eclipse had the ability to export zip files which could be sent over email for example.
If you zip the folder from your workspace, and try to send it over Gmail for example, Gmail will refuse because the folder contains executable.
Obviously you can delete files but that is inefficient if you do that frequently going back and forth from work.
Here's a solution though:
You can use source control. Android Studio supports that. Your code will be stored online.
A git will do the trick. Look under "VCS" in the top menu in Android Studio.
It has many other benefits as well. One of the downsides though, is that if you use GitHub for free, your code is open source and everyone can see it.
Source control is best way to handle this problem, if you don't want to pay then try bitbucket
It's free, allows private repo for upto 5 members team.
Windows:
First Open Command Window and set location of your android studio project folder like:
D:\MyApplication>
then type below command in it:
gradlew clean
then wait for complete clean process. after complete it now zip your project like below:
right click on your project folder
then select send to option now
select compressed via zip
Apparently, there's a lot of "dead wood" in the "build" directories of a project.
Under linux/unix, a simple way to get a clean, private backup is to use the "tar" command along with the "--exclude=String" option.
For example, to create an archive of all my apps while excluding the build directories, I have a script that creates the following 2 commands :
cd $HOME/android/Studio
tar cvf MyBackup-2017-07-13.tar Projects --exclude=build
For Android Studio below 4.1:
From the Top menu Click File and then click Export to Zip File
For Android Studio 4.1 and above:
From the Top menu click File > Manage IDE Settings > Export to Zip File ()

Work on an Android program with several computers

I am developing a project from work, but would like to be able to take the project home and continue it. I can't just "open" a project, so what are the settings to save it on one computer, then open it from home, then save it again to work on it from home?
I use Dropbox. My Eclipse workspace is inside my Dropbox folder, so whenever I load up Eclipse on any of my computers, I always have the most updated versions of my files without any hassle.
This also gives you the added benefit of not having to worry about a harddisk failure and being able to rollback files.
Either do as Glendon said or setup a subversion or git repository.
I usually do both.
If you're not using Dropbox or github, I assume you're emailing the code or using a USB drive. After you've unzipped your project to your other computer's home directory, run Eclipse and do
File, New, Android Project
enter the Project Name
in Contents, select Create project from existing source
in Location, browse to the directory you just created in your home directory
choose a Build Target
and click Finish assuming the other settings have been filled in for you.
I do the same thing by putting a bare git repository on a memory stick and cloning it onto all development machines.
As the repositories on the development machines are cloned from the one on the stick, their "origin" will point back to the memory stick. So all I have to do when bouncing from one development machine to the other is
<insert memory stick>
cd <work_directory_on_harddisk>
git pull
...write code
git push
<remove memory stick>
and I am done.
What is nice about this is that even if you forget the stick, or forget to synchronize and end up working on an outdated directory, you can untangle it easily with all the power of git.

Categories

Resources