1

Scenario:

  1. I'm working through the exercises in an Android programming book.

  2. I finish "Chapter 10", so I "Close Project" and exit Android Studio, manually delete build/* and copy "chap10" to a new folder, "chap11".

  3. I start Android Studio > Open Existing Project > chap11.

    So far, so good. Everything looks fine.

  4. I start editing a .java source file or .xml layout file in chap11 ... and Android Studio overwrites the old files in the old directory instead (?!?)

Q: What causes this behavior?

Q: What can I do to make Android Studio "forget" everything about the old "chap10", and use ONLY filepaths from the new "chap11" instead?

I'm using Android Studio 3.5, Build: Aug 8, 2019.

paulsm4
  • 114,292
  • 17
  • 138
  • 190

1 Answers1

0

I found the answer here. After copying the directory, I delete all of the following (and let Android Studio recreate them on gradle build):

https://stackoverflow.com/a/24679853/421195

app/build/*
.gradle/*
.idea/*
*.iml
local.properties

I think almost everyone agrees about /build.

I got sick of constantly seeing messages about the various library.xml files that Gradle creates or deletes in /.idea. The build.gradle will run on the developers's local when they first check out the project, so why do those XML files need to be versioned? Android Studio will also generate the rest of /.idea when a developer creates a project using Check out from Version Control, so why does anything in that folder need to be versioned?

If the *.iml is versioned a new user will have to name the project exactly the same as it was when committed. Since this is also a generated file, why version it in the first place?

The local.properties files points to an absolute path on the file system for the SDK, so it definitely shouldn't be versioned.

paulsm4
  • 114,292
  • 17
  • 138
  • 190