How to import Android Studio Project from Git - android

I have and android studio project that I have checked into git. My git ignore file looks like:
# 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
# Eclipse project files
.classpath
.project
# Proguard folder generated by Eclipse
proguard/
# Intellij project files
*.iws
.idea/workspace.xml
.idea/tasks.xml
/gradle
When I go to my laptop to pull the project down I am not sure whether I should do open or import inside android studio to correctly being in the project. When I do open I get the following error:
Cannot load module file 'D:\dev\android\projects\projectname\ProjectName.iml':
File D:\dev\android\projects\projectname\ProjectName.iml does not exist
Even though that file does exist.
When I do import instead of open android studio asks for the path to gradle home and I am not sure what to put in. I am using android studio 0.4.3.
Any help would be really appreciated.
Answer:
I was able to get the project to build by doing open instead of import. However in the process intellij created an additional iml file at the root of my project which doesn't exist on my desktop. Not sure why it was created and if I need it. Can't for the life of me figure out the proper way to push my project into git and then restore it on another machine without causing lots of new files to be generated and break things.

Use import and delete "/gradle" out of your .gitignore
Its ok to ignore .gradle, but /gradle should be included in the git.
At least this is the way i got it working for me.

Try is .gitignore file.
.gitignore
You can't import the project is because there are some IDE generated files in your project.

Related

Android Studio project with Github

I am currently working on a Android Studio Project that I am sharing with other team mates. In order to do this we are using GitHub to share the Project.
I tried using the option "Check out project from Version Control". However one I successfully download and open the Project I get "Error Loading Project: Cannot load 2 modules", being two .iml files, one which is the app.iml. This prevents me from accessing the app folder from the project, hence I cannot work with it in Android Studio.
I have tried downloading it from our GitHub repository directly and opening it with Android Studio, however I get the same error.
Can anyone help me figure out how to successfully run a GitHub shared Android Studio project?
I am running this on Windows 10.
.iml files are the local configuration of the IDE, you and other team members should add it to .gitignore.
Also you can deleted them any time you want , and select Build Project from the Run menu. They will be generared again.
That's because .iml files are specific for local configurations. You have to remove them manually from the repository and not push them. I recommend to you to use a .gitignore file that can be either global or a project file with some classic Android excludes:
#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
*.iml
.idea
#.idea/workspace.xml - remove # and delete .idea if it better suit your needs.
.gradle
build/
#NDK
obj/

Android studio, stashing or saving open tabs feature?

I use Android studio almost all day - everyday.
I'm aware that it's a build of IntelliJ.
I also use Git, and I switch between branches hourly.
I was wondering, cause I cannot find a solution searching around:
Is is possible to save open tabs so that when I switch branches I don't lose all my currently open tabs for files that don't exist, plus it would be super nice to see that work-space-view again. when switching to the concurrent branch.
For your information:
.idea and *.iml folder contains all the tab and work space related information of Android Studio Project.
Why it is not stored in git branches:
Typically when we create a .gitignore file for Android Studio project we include .idea folder and *.iml in ignore list. That's why switching branches doesn't keeps the changed preferences.
What to do:
If you want to track this information for git branches then simply remove this two files from .gitignore list. You can add an extra # before .idea and *.iml
# 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
#idea/studio
.idea
*.iml
.DS_Store
captures

Updating android project from bitbucket causes binary merge conflicts

I'm in the process of learning android development and I want to be able to develop from work, home or my laptop so it made sense to use github or bitbucket as a central repository. I chose bitbucket so I didn't have to learn in public so to speak.
I was not able to get bitbucket to work within android-studio but I didn't mind dropping out to the command line for my pushes and pulls.
Pushing works fine and cloning works pretty well (some settings need to get adjusted for the local environment but that not been a problem.)
However, I'm finding as I start to iterate on a project I'm getting merge conflicts on binary files such as:
CONFLICT (content): Merge conflict in app/build/outputs/apk/app-debug.apk
I guess it makes some sense but I don't know what to do about it. Do I have to set something so that git ignores certain files? How do I know which ones? It's certainly not all binary files since I do want to store app related graphics.
If I tried again to get this working natively in Android Studio (some people can do it apparently) would Android Studio protect me from these errors?
Is there something else I should be doing?
You shouldn't be committing your apk files, or any built stuff.
I use this this .gitignore by taken directly from an answer here by user Lior Iluz
#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
*.iml
.idea
#.idea/workspace.xml - remove # and delete .idea if it better suit your needs.
.gradle
build/

.gitignore file for multiple Android projects under a master folder?

I am having a problem building a .gitignore file for my Android Studio workspace, this is my folder setup:
Android Workspace---
-> School/Application1, Application2, etc.,
-> Projects/Application1, Application2, etc.
Android Workspace is the master folder, School and Projects are used to organize my applications, They contain the folders created when I create a new Android Studio project.
I created a .gitignore file and placed it in Android Workspace, but it doesn't seem to be ignoring the files, I then tried placing two .gitignore files in each sub directory, but that didn't work either, so, my question is: How do I structure my .gitignore file to ignore the unnecessary Android Studio files from the Android Workspace folder no matter how deeply nested they are? Or do I have to place a .gitignore in each of the application's directory?
Thanks, and here's the .gitignore file I'm using (Generated by https://www.gitignore.io/):
### Android ###
# Built application files
*.apk
*.ap_
# Files for the Dalvik VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
# Gradle files
.gradle/
build/
/*/build/
# Local configuration file (sdk path, etc)
local.properties
# Proguard folder generated by Eclipse
proguard/
# Log Files
*.log
You can create a global .gitignore that will have the files/folders to be ignored in all git projects. For this, just run the following command
git config --global core.excludesfile ~/.gitignore_global
It will create a .gitignore_global file in your home folder that should have the files/folders to be ignored.

Android Eclipse: .gitignore not ignoring bin and gen directories at all [duplicate]

This question already has answers here:
Eclipse Git gitignore file is ignored
(2 answers)
Closed 8 years ago.
I am trying to ignore some eclipse generated files that are not relevant for a push and here is my folder structure:
Project1/
.gitignore
extras/
..some stuff here
Project1/
bin
gen
libs
res
..and so forth
so I need the inner Project1 that is inside of outer Project1 because Eclipse was getting all crazy for not having a folder structure like that and it wouldn't import my project so that's that. The git ignore seems to work for the extras folder but not for bin, and gen or anyhting inside inner Project1 folder. I tried adding the folder like Project1/bin but nothing was hapening and git stil notices changes.
Here is my file:
# built application files
*.apk
*.ap_
# files for the dex VM
*.dex
# Java class files
*.class
# generated files
bin
gen
extras
# Local configuration file (sdk path, etc)
local.properties
# Eclipse project files
.classpath
.project
project.properties
# Proguard folder generated by Eclipse
proguard/
# Intellij project files
*.iml
*.ipr
*.iws
.idea/
This is my first android github project so I am still learning. Please do not mind if my questions or assumptions are wrong. Thank you!
Try changing bin to Project1\bin\**, and similarly gen to Project1\gen\**.

Categories

Resources