0

When initially trying make a copy of an Android Studio project, I duplicated the project folder in finder, renamed it, brought it up in AS using "Import Project," refactoring the package and editing the manifest. At first first it seemed to run on my device without any issue.

I later noticed, however, that every time I ran either the original or the duplicate app on my device, one would replace the other's icon on the home screen.

I found a solution that said not to use "Import Project" but instead to use "Open Project" to open the duplicate. Doing so solves the initial problem of the app replaced with the other app, but opened a whole new can of worms where some of the pointers in the duplicate project refer to files and file paths in the original project. Apparently this is a known bug. I have not confirmed this with Google, however.

Searching for solutions only lead to "you need to use "Import Project" not "Open Project," which of course takes me back to the original problem. Any ideas?

dbconfession
  • 1,147
  • 2
  • 23
  • 36
  • I've seen this question asked a million times in many ways. Might want to up-vote the question so people know that this is time there's a legit answer. – dbconfession Sep 02 '14 at 22:56

3 Answers3

1

Android uses the applicationId in the Gradle build file to set the package attribute in AndroidManifest.xml; this string is used by Android devices to disambiguate applications. If you install an app it will replace any other installation with that package ID. Change the value in Project Structure > Flavors > defaultConfig, or modify it directly in your build file.

Note that if you try to change it directly in AndroidManifest.xml, it will be overwritten at build time with what's in build.gradle; you need to modify it in the build file.

Scott Barta
  • 79,344
  • 24
  • 180
  • 163
  • that worked. Thank you. How come this doesn't update when a refactoring is done? Is this a bug or is there logic to it? – dbconfession Sep 02 '14 at 21:22
  • The application ID isn't the same thing as the package where your code appears. Just because you change one doesn't mean you need/want to change the other. – Scott Barta Sep 02 '14 at 21:26
  • so it's just a coincidence that the package and the application ID are in the same exact format? (not being sarcastic). – dbconfession Sep 02 '14 at 22:16
  • 1
    It uses Java package naming rules, so it comes out similar, but it doesn't need to be the same. – Scott Barta Sep 02 '14 at 22:50
0

Try deleting *.iml in duped dir then import.

ytRino
  • 1,450
  • 15
  • 28
-1

Instead of trying to copy the project outside of Eclipse, try copying it IN Eclipse, like this:

Copy and paste your project (ctrl+c and then ctrl+v)

Change the package name in your Manifest.

Rename your package name with refractor by right-clicking on the package.

Change your application name in your Manifest.

This will create a new source folder for the project and it will already have the new project in your Eclipse.

user1282637
  • 1,827
  • 5
  • 27
  • 56