Android studio, stashing or saving open tabs feature? - android

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

Related

How to remove some files from commit checklist Android Studio?

I would like to commit changes which I did in my AS project. But I see that changeslist contains release folder:
It means that I will commit workable apk file and some config files which were generated during building installer. I can also untick these files but when I will try to make commit at the next time I will see these files again. Maybe I can remove these files totally from my changes list and prevent its appearing at all next times. I think it happens because I tried some commands at the terminal and one command can add these files, I think it was:
git commit --am
So, how I can solve this problem without damaging all project?
UPDATE:
Can I solve my problem with the command:
git rm --app-release.apk ?
First Things first:
You can add a .gitignore file to your repository, via terminal, by the commands below:
In Terminal, navigate to the location of your Git repository.
Enter touch .gitignore to create a .gitignore file.
Second, you should pay attention that, If you already have a file checked in and you want to ignore it, Git will not ignore the file if you add a rule later. In those cases, you must untrack the file first, by running the following command in your terminal:
$ git rm --cached FILENAME
for more information on this follow https://help.github.com/en/articles/ignoring-files
First add the file/folder to your .gitignore file (In your case, the app-level one and not the project-level one)
Go to the Terminal in Android Studio and type in these commands:
git rm -r the-directory-to-remove In which case your the-directory-to-remove is the release folder.
The above command will remove the specified directory from git.
git commit -m "Delete release folder"
The above command commits the changes, you can change "Delete release folder" to whatever you like.
git push origin <your-git-branch>
The above command pushes the changes to Github (or BitBucket).
Now, if you want to delete the file from Github/BitBucket ONLY but not from the entire git filesystem, run git rm -r --cached myFolder instead of the first command.
you need to add those files in your ignored files under version control area in your android studio. For navigation go to
Open File -> Settings -> Version Control -> Ignored Files.
Add files those you don't want to commit or include. Another way of doing it like the other answer suggested to do it with .gradle tools.
I'd recommend using https://www.gitignore.io/ for generating .gitignore file for your android project and put it in your root folder of the project.
https://www.gitignore.io/api/android gives a headstart for your android project(Modify this according to your requirement. But for most cases this should be out-of-the-box solution).
Also, to add to the point. This is expected behaviour of git and not related anyway to android studio/android.
Step 1: Remove file's from staging area using below command
git reset HEAD file
check this
similar post
Step 2: add release folder and other generated file's to your .gitignore
Ref:
If you have a gitignore file then add this line
# Built application files
*.apk
*.ap_
*.aab
# Files for the ART/Dalvik VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
out/
# Gradle files
.gradle/
build/
# Local configuration file (sdk path, etc)
local.properties
# Proguard folder generated by Eclipse
proguard/
# Log Files
*.log
# Android Studio Navigation editor temp files
.navigation/
# Android Studio captures folder
captures/
# IntelliJ
*.iml
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/assetWizardSettings.xml
.idea/dictionaries
.idea/libraries
.idea/caches
# Keystore files
# Uncomment the following lines if you do not want to check your keystore
files in.
#*.jks
#*.keystore
# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild
# Google Services (e.g. APIs or Firebase)
google-services.json
# Freeline
freeline.py
freeline/
freeline_project_description.json
# fastlane
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
fastlane/readme.md
or create a .gitignore file in your root folder of project

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/

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.

How to import Android Studio Project from Git

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.

Categories

Resources