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/
Related
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/
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
I try to import my Android Studio project on different machines and wondering which project files are realy needed. For example the .idea or .gradle directories. I won't to much trash in my svn repo. Can someone tell my more about required files for Android Studio projects?
You need to keep these files in your root project
app folder (tough ignore the build folder inside it recursively, it's a big waste of space)
gradle
.gitignore if you are using GIT
build.gradle
gradle.properties if you want to have the same configuration on all of your pc's. You need to cinfugure it first tough.
gradlew
gradlew.bat
settings.gradle
Anything else that is not on the list and was not created by you, can be ignored
Make sure you ignore these by file name wildcard. This is the garbage created by macs and windows machines.
.DS_Store
desktop.ini
Thumbs.db
*.iml (garbage created by Android studio)
I truely recomend you to use git in Android Studio, the integration is awesome and it`s so easy to use. It select the files u need for you and have really good tools for merge files.
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.
I am currently using Git on the command line to help me incrementally add features without breaking existing code. The part that worries me is this line of output from Git after committing:
[optimized_managed_event 6c9a98c] Added managed event insert into my ContentProvider
12 files changed, 202 insertions(+), 16 deletions(-)
rewrite bin/classes.dex (87%)
rewrite bin/classes/com/zeroe/SmartCalProvider.class (85%)
Should I worry about the rewrites if they are .class files and other types that aren't text? I am fairly new to Git, but am pretty comfortable with the command line and I understand the basic workflow for most Git projects:
> git add .
> git commit -m 'comment on commit'
> git checkout [master]
> git merge [branch]
What I am slightly worried about is issues that can occur when committing, then merging since Android projects have a lot of files that it creates itself in different formats.
My question is essentially in anything I need to worry about when doing this in Android development?
Create .gitignore in the root of your project and add at least the following:
*~
*.apk
bin
gen
local.properties
.apt_generated
This way you avoid putting in repository automatically generated files, which usually blows the repository size up without any reason. The only automatically generated files you might want to save are proguard/ files, which might be necessary to unroll the call-stack after the user-generated crash reports.
Also, I found it's very helpful to have giggle utility installed to see what changes you have in your files.