Android Studio keeps adding additional files to GitHub - android

I'm using Android Studio 2.2.2, using the built in VCS tool. For some reason, Android Studio automatically adds a bunch of extra xml files and folders that I did not add nor edit.
More specifically, it's adding the following files when I don't want it to:
/_windows
IntelliLang.xml
debugger.xml
diff.xml
vcs.xml
web-browsers.xml
This makes making pull requests downright impossible as the master branch doesn't have these files, and none of my other group members seem to have this problem either.
Any help in removing / configuring Android Studio to stop this pesky bug?
--
edit: I am already using a gitignore file already. The weird thing is that my additional files are in the wrong folder too. Basically, my root folder, has a subfolder for my app. All the junk files are created in my root folder for some reason by Android Studio.
/root/
/_windows
IntelliLang.xml
debugger.xml
diff.xml
vcs.xml
web-browsers.xml
/my_android_app/
gitignore for my app
/files actually needed for my project

Turns out this feature is called "Settings Repository", and it's intended to save IDE settings automatically. I guess I might accidentally agree on some popup from IDEA which look like add files to the git repository, so this started working.
FIX: Open Preferences → Tools → Settings Repository → Delete. I also disabled Auto-Sync. Dunno where it's going to save if I delete everything, but I switch it off to be extra safe..

Use gitIgnore file.. i am currently using this .
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
.externalNativeBuild
/captures
check if the same works for you or not ..
if you want to know the details please check here

If the IDE you are using is adding files that it requires, but which you don't want to be included in your repository, then this is a good candidate for additions to your .gitingore file.
Are you currently using a .gitignore file?
More information can be found here:
https://git-scm.com/docs/gitignore
You basically add an entry for each file or folder you want to ignore, and as a result, git will no longer try to include these files in commits going forward.
There is a good resource here:
https://github.com/github/gitignore
For creating a default .gitignore file. You would pick the .gitignore template that closely matches the type of development that you are doing, and customize from there. For example, I always start with the default Visual Studio template.
Probably the best suggestion would be to use the template .gitignore file for Android Development which is located here:
https://github.com/github/gitignore/blob/master/Android.gitignore
NOTE: I would copy the contents of this linked file into this answer, however, these template .gitignore files are always changing, as new recommendations are being added. It is best to keep referring to the source file for the most up to date version.
It doesn't explicitly ignore the files that you have mentioned, but it could be that those files are created within a folder that is being ignored.

Related

GitHub Desktop won't detect changes when I make a build apk?

I'm building a voice recording app and right now I'm backing up all of my code to GitHub and a memory stick. Whenever I make it build it saves it into the file directory that GitHub desktop it's backing up, but it won't detect some of my files. Such as: app.iml and app-debug.apk.
Has anyone else had this problem and if you have fixed it could you tell me how?
Those files shouldn't be committed or relied on since you will need to rebuild the project anyway when you do a fresh checkout. Your code might be different than your compiled code depending of how you added them. Check out this thread that talks about javascript Should compiled JavaScript files be committed to Git repo?
Sounds like Git ignoring files and directories specified in the .gitignore file in the root of your repository directory.
See lines from one of my repositories:
*.iml
..
..
/build
Your apk file is just the latest build of your code, so the source code saved to GitHub is the backup.

android studio settings.gradle duplicated, not recognized.

My android studio project is ostensibly error-free and (usually) builds just fine. But as seen in the following picture, there is a set of files that shows up twice in the file tree:
...once at the same level as the root project folder, and once within the project folder. NOTE: The actual files on the file system are ONLY located within the project folder.
In Android Studio, when I try to edit the settings.gradle within the project folder, it tells me "This folder does not belong to a Gradle project. Make sure it is registered in settings.gradle.", as shown here:
So, I try to instead edit the settings.gradle outside the project folder. In that case the Non-Project Files Access window comes up: this file is not part of my project. As shown here:
Who knew Android Studio was designed by Franz Kafka! But seriously, has anybody seen this? Or do you have any thoughts? Because of this issue, I can't add any new libs, so it is quite a show-stopper.
You may be interested to know that there in my git repo, there are existing versions of several auto-generated files including app.iml and project.iml and some other files from .idea/. When I git checkout back to the ones in the repo, the duplicate-file-trees briefly disappear. (I am still unable to access/edit settings.gradle, though).
If you want more information let me know. Thanks!

How to force Android Studio to use relative paths?

Every project created in Android Studio 1.0.2 contains several files that reference the project's own absolute path. I can't even move my own project directory if I want to, let alone share the project with other developers.
Excluding files in app/build, these are the files containing absolute paths:
.idea/workspace.xml
.idea/modules.xml
.idea/libraries/support_v4_21_0_3.xml
.idea/libraries/appcompat_v7_21_0_3.xml
.idea/gradle.xml
.gradle/2.2.1/taskArtifacts/taskArtifacts.bin
.gradle/2.2.1/taskArtifacts/fileSnapshots.bin
app/app.iml
How do I force Android Studio to use relative paths for everything?
Edit: By experimenting with vanilla IDEA, I've narrowed down the origin of these absolute paths to a specific type of module, which Android Studio apparently always uses without offering you a choice. But I'm still no closer to understanding how to eradicate them.
In IDEA 14.0.2, if you create an empty project or an Android project with an "Application Module", the project does not contain any absolute paths. If you create a project with a "Gradle: Android Module", then it contains absolute paths in the same files as an Android Studio project.
Edit #2: Created IDEA-134587
In general, don't consider any of the .iml files or the contents of the .idea folder to be part of the project, and don't share any of those files, don't check them into source control, and don't move them with the project. Think of them as cache files.
The Gradle files are the source of truth, so if you're having troubles with absolute paths, close the project, delete the non-shareable files, and re-import it from the Gradle build scripts.
I ran into the exact same problem, but the solution suggested above contradicts JetBrains' advice as well as this answer. Also, my co-worker working from the same source code (with unexpanded paths) and Android Studio version wasn't having the problem, so I kept banging my head against the wall.
We eventually solved the problem when we realized that many of the paths I used included symlinks. In my case, I had a symlink set up for ~/work so that it pointed to /some/drive/with/space. Within Android Studio all of my source was referred to from ~/work/source rather than /some/drive/with/space/source. When I changed everything so that Android Studio referred to things with their actual paths, the $PROJECT_DIR$ and $MODULE_DIR$ variables magically started working and my .iml files were no longer getting corrupted. YMMV.
TL;DR: Don't use symlinks in your project paths!
Also, be sure to not keep the files within .gradle as part of your shared project.
Also, one set of files that you might want to share though are your files under .idea/copyright though as that allows you to have shared copyright settings.
So a possible .gitignore file might be:
.gradle
.idea
!.idea/copyright/[YourCopyrightFile].xml
!.idea/copyright/profile_settings.xml
*.iml
build
local.properties
Hmm. I just don't see the same absolute paths in those files, I only see references to MODULE_DIR and PROJECT_DIR, such as:
./app/app.iml: <excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
or:
./.idea/workspace.xml: <entry file="file://$PROJECT_DIR$/.idea/libraries/appcompat_v7_21_0_2.xml">
I wonder if this is Linux issue only, or something in your settings?

Android studio - should the entire .idea directory be in git ignore?

I saw a lot of examples for .gitignore files for AndroidStudio, some have .idea in them, and some don't.
Is there a good reason not to add the entire .idea dir to .gitignore?
If it should not be completely ignored, are there specific files inside .idea (such as .iml) that should be in .gitignore?
You can take a look at this page :
IntelliJ doc about project configuration files
In the "Directory-based format", a particular line is interesting :
The .idea directory contains a set of configuration files (.xml). Each file contains only a portion of configuration data pertaining to a certain functional area which is reflected in the name of a file, for example, compiler.xml, encodings.xml, modules.xml.
Almost all of the files contain information core to the project itself, such as names and locations of its component modules, compiler settings, etc. Thus, these files may (and should) be kept under version control.
However, I properly HATE to make project IDE-dependent (I am currently working on a project made with NetBeans and it hurts to use it with Eclipse which becomes the standard of my company).
So, to answer your question :
If you do not use something like Maven or Gradle to manage dependencies and build : keep the directory under version control. This way, the correct configuration of the project and dependencies will be available for everyone. In the counterpart, all developers will have to set their environment exactly the same way that you define it in the config files.
If you do use something like Maven or Gradle : correctly configure these tools and do not keep the directory under version control. Actually, all the information contained inside config files should be stored in Maven/Gradle files. Then let your developers configure their IDE depending of their environment. This way, using Eclipse, IntelliJ, Linux, Windows ... will not be a problem anymore.
OK, so after some "Yes" and "No" answers, I am adding a "Yes and no" answer :)
The problem is that .idea is used for both project build configuration (dependencies declaration) and project settings (inspections, etc.).
You definitely don't want to use your IDE for your build configuration, but you might want to share the settings among the team. That's why you need to ignore only a part of the .idea content (like the libraries folder and the modules.xml file), but keep others in the version control (e.g. the copyright, dictionaries and inspectionProfiles folders and files under .idea like dynamic.xml, codeStyleSettings.xml, etc.).
The concept of keeping the project configuration in VC is valid. I did this with my team because all of our developers happened to use PHPStorm for our projects and so it made sense to keep a common configuration ... in concept. We wanted to use the same dictionary files, the same coding standard rules, and the same plugin configurations.
The reason why I qualify this with "in concept" is because there were issues with JetBrains' .idea folder that led to us not being able to use it. These were probably issues that could have been avoided or fixed, but it was unclear to us how to do it right, and we think that's a fault of JetBrains because as developers we do not have time nor desire to search for solutions on how to make our IDE work correctly.
That being said, the issues were had are the following:
Symlinking project folders doesn't work right.
When I set up my projects, I symlink them into my home directory. What we discovered was that the project was set-up to use the exact symlink rather than just treating it like a concrete directory. This means that if another developer keeps his project in a different place, or simply does not use symlinks, the entire directory will be missing from the project navigator because it is quite literally looking for the symlink. What's worse is that I could never find this path value in the configuration. We were unable to find the exact config in the files constituting our .idea folder.
Definition files are partitioned to users by default. This means if I want to add a word to my dictionary, it will be listed as a definition for me, jgreathouse, but other users will have their own definition section. The flagged words will still show up as a spelling mistake for other users. This is not desireable. The reason I add it to my definition file is because the IDE is wrong. I want these definitions to be intuitively shared with other users.
Colleagues kept overwriting the configurations because their IDE would overwrite the configurations with their config currently in Memory. What I mean is that, a developer would be working, and merge their repository from origin, which would contain a project configuration change, instead of their IDE changing configurations, or even giving them a choice, it would automatically overwrite the .idea configuration with the current in-memory configuration of their IDE. In my opinion this makes the .idea configuration unusable as a shared configuration. In order to work around this, the developer would literally have to shut down that instance of their IDE, pull the repo, and re-open their IDE. It makes no sense to keep a shared configuration if the IDE instantly overwrites it with the configuration currently in memory. It's like not having a shared configuration at all.
I've done these types of shared IDE configurations in VC before with Visual Studio and Netbeans and it was always fine; but with .idea it feels simply unusable which is disappointing. I wish JetBrains would get on top of it and make it a better user experience.
As a complement to the explanations in this question GitHub's .gitignore template for Android includes the following files:
# IntelliJ
*.iml
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/assetWizardSettings.xml
.idea/dictionaries
.idea/libraries
# Android Studio 3 in .gitignore file.
.idea/caches
.idea/modules.xml
# Comment next line if keeping position of elements in Navigation Editor is relevant for you
.idea/navEditor.xml
Notice also this entry from JetBrains guidelines on How to manage projects under Version Control Systems about sharing IDE project files with other developers:
What needs to be shared:
All files under the .idea directory in the project root except the
items that store user-specific settings: workspace.xml
usage.statistics.xml shelf directory

Android eclipse project is broken

After switching to my release branch the project had a missing gen file so I added the gen file from java build path.
Now the assets and the res folders are show like gray packages and not folders and I get the errors like res/values/ is missing.
How to return to the standard android project structure in eclipse?
Is there a standard way of returning to the standard Android project. I have become tired to fix project properties and I have tried to clean and restart eclipse It seams that some project metadata is saved the wrong way.
Thanks .
/gen/ folder is automatically generated during compilation. You should include that and /bin/ and also /.properties/ to .gitignore to avoid having to fix properties all the time and also minimise the amount of unnecessary data stored in your repo.

Categories

Resources