Asked  7 Months ago    Answers:  5   Viewed   53 times

What files should be in my .gitignore for an Android Studio project?

I've seen several examples that all include .iml but IntelliJ docs say that .iml must be included in your source control.



Updated to Android Studio 3.0 Please share missing items in comments.

A late answer but this alternative answer was not right for us ...

So, here's our gitignore file:

#built application files
# files for the dex VM
# Java class files
# generated files
# Local configuration file (sdk path, etc)
# Windows thumbnail db
# OSX files
# Android Studio
#.idea/workspace.xml - remove # and delete .idea if it better suit your needs.

Since Android Studio 2.2 and up to 3.0, new projects are created with this gitignore file:


Deprecated - for older project format, add this section to your gitignore file:


This file should be located in the project's root folder and not inside the project's module folder.

Edit Notes:

  1. Since version 0.3+ it seems you can commit and push *.iml and build.gradle files. If your project is based on Gradle: in the new open/import dialog, you should check the "use auto import" checkbox and mark the "use default gradle wrapper (recommended)" radio button. All paths are now relative as @George suggested.

  2. Updated answer according to @128KB attached source and @Skela suggestions

Tuesday, June 1, 2021
answered 7 Months ago

This is a good start.

updated with Dave's suggestions.

Monday, August 2, 2021
answered 5 Months ago

In my case deleting the com_crashlytics_export_strings.xml file fixed this error.

<?xml version="1.0" encoding="utf-8" standalone="no"?>
  This file is automatically generated by Crashlytics to uniquely 
  identify individual builds of your Android application.

  Do NOT modify, delete, or commit to source control!
<string xmlns:ns0="" name="" ns0:ignore="UnusedResources,TypographyDashes" translatable="false">xxxxxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</string>
Thursday, August 12, 2021
answered 4 Months ago

Your refs/remotes/origin directory—this is a directory within in your local repository—has some sort of problem. (It's not clear to me what exactly went wrong, but your guess that it happened when Android Studio crashed seems likely to me as well.)

To fix it, you can probably use the sequence of commands below. Note that I don't recommend it in general—your Git service, whether that's Android Studio or ordinary command-line Git, is not supposed to crash and leave you with a broken repository, so you should never have to do this, it's just an emergency repair, something like putting duct tape all over your car1 after a tree fell on it, just enough to get you to a proper repair / replacement vehicle later:

$ cd $(git rev-parse --show-toplevel)  # if necessary
$ rm -rf .git/refs/remotes/origin      # remove all origin/*
$ mkdir .git/refs/remotes/origin       # create empty origin/
$ git fetch origin                     # repopulate origin/*

In any case it's likely that your git push has actually succeeded at this point, since what is failing is the update to your origin/master remote-tracking branch.

Your Git has just finished talking to another Git on origin, giving them (the users of origin) updates for their master, and origin has accepted those updates, and your Git is now recording the fact that, the last time it talked with origin, their master was set to some particular commit hash—the one you just pushed.

(Remember that your origin/* remote-tracking branches are just recording, for you, what your Git saw that their Git has for its branches. Your Git updates these when you run git fetch, where your Git talks to their Git and gets all of its branches. Your git also updates some—not all—on git push, when your Git talks to their Git and asks them to set one or more branches, to the hashes your Git hands them.)

1Except that as a Git mechanic, instead of just duct tape, baling wire, and chewing gum, my recommended parts are actually proper body panels, belts and hoses, and clamps. :-)

Tuesday, September 28, 2021
answered 3 Months ago

After running the

$amplify init

The Amplify CLI will prompt you for several questions, one of the question in the prompt is:

? Where is your Res directory:

for this you need to provide the relative path to you Res directory, like:

? Where is your Res directory:appsrcmainres

instead of providing the full path like:

? Where is your Res directory: D:EDUCATIONFinal_Year_ProjectDemo2appsrcmainres

As on writing this answer(18th April 2019), the amplify CLI is not optimized to figure this out on its own. We can hope to see this as an enhancement in the future versions, so it should resolve itself in the future versions.

Wednesday, December 1, 2021
Timur Mustafaev
answered 6 Days ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :