Reputation: 4930
This should be a really simple question :)
I have a project that works fine. Now I wanted to rename it and to change the path of the projectfolder. First it seemd simple: right click -> "move" and "refactor/rename".
After moving and renaming my project folder and my apk modul there was not the same project-structur as before. My project libs have been included twice. I looked in the '.iml' files and saw that the previous path was included - so I changed this. After this I could compile my project over the command line but not with the IDE. There I got this error:
NullPointerException: no project directory specified
Whats the default way to move and rename a project? I solved my problem by making a new project and copying all files, but it would be very cool to know the solution of this "problem".
EDIT:
Origin Project-Structure:
MyProject
--- libraries
--- MyApp
After Moving:
MyProject
--- MyProject (new path)
--- MyProject (old path)
I think I have to do more than just copy the project. Somehow I have to specify the "new" project, havn't I?
Upvotes: 36
Views: 62002
Reputation: 9832
In Android Studio, I found both of the following to work OK for a project which has been copied|moved|renamed.
Approach: Import
Approach: Sync Project with Gradle Files
Both have the same outcome.
Import
is one less step. Import
is conveniently located on the welcome screen and File > New menu.
Sync Project with Gradle Files
is a somewhat more obscure menu item. However, Sync Project with Gradle Files
is a good fallback if you click open when intending to Import
.
Upvotes: 6
Reputation: 103
In my case, after moving the project to another folder what worked was:
Upvotes: 0
Reputation: 1682
For Android 3.3.2+
Be sure to select the folder with the project name
Uninstall the app from your device
Important!!
Turn off Instant Run to avoid the apk install process from looking for existing slices (the cache clean does not do this, apparently). This is from the SO answer here. File > Preferences > Build, Execution,Deployment > Instant Run > Uncheck the enabled box
Top menu bar -- File > Invalidate Caches / Restart (I invalidate only)
That should do the trick
Upvotes: 1
Reputation: 14610
For Android Studio 3, it seems this should be enough:
I could not deploy to the emulator after moving and renaming a project. Doing the steps above solved it.
Upvotes: 4
Reputation: 71
This is what I do to copy/move a project. I am using Android Studio version 2.3.2
Here are some example statements that need to be changed:
<entry file="file://$PROJECT_DIR$/app/src/main/java/com/NEW_SITE_NAME/NEW_SITE_PACKAGE)/MainActivity.java">
<option name="name" value="NEW_ROOT_DIRECTORY_NAME" />
<option name="KEY_STORE_PATH" value="C:\... YOUR KEYSTORE PATH ...\keystore.jks" />
<option name="KEY_ALIAS" value="newrootdirectoryname" />
<option name="name" value="NEW_ROOT_DIRECTORY_NAME" />
There are other statements and many statements are identical. You should be able to get the idea. The key to doing this correctly is using the same naming methodology already in place in the existing workspace.xml file. If you utilize search and replace this is fairly simple process and takes only a few minutes.
Hope this helps someone!
Upvotes: 1
Reputation: 1
What works for me:
1. Moving Project:
Close Android Studio .You can try to copy and paste the project normally. If there is Path error due to path to long. What I do normaly is compressing the project to rar file. copy paste to new location and extract It. For winrar use extract here as the actual root folder is inside the rar
2. Rename the project:
Rename the root folder to your new project name.
3. Open In Android Studio
Notice that when you open android studio, it will open the old project file by default. Close the project by going to File>Close Project. Then open your new project.
Upvotes: 0
Reputation: 29
I just successfully moved my C:\ project into my portable M:\ drive.
I know it's a bit of a drag, but this is the only working method I have found to move a project from one destination to another and still have a viable work product.
PS: I was searching for this query about an hour ago, with no success. After getting a positive result myself I thought I would share the result with the community... even if the thread is two years old and already marked as answered. After all, it may help the next person who is searching for a quick result, like I was.
Upvotes: 0
Reputation: 1
In Android studio 1.5
This will update move and rename the project path.
Upvotes: 0
Reputation: 5205
Move project files as you like and then:
Tools -> Android -> Sync Project with Gradle Files
Upvotes: 15
Reputation: 91
To move the project in your filesystem using Android Studio 1.1.0:
Upvotes: 9
Reputation: 16243
In Android studio 0.8.+, you can click F6
to move it.
If you use 1.0.2 or higher, make sure you select the Project view for the Refactor -> Move menu option to become available.
Thanks to @DavidsAlias for pointing this out.
Upvotes: 22
Reputation: 64632
Close the project in Android Studio (File -> Close Project). Move the project and rename it by moving its home folder/directory. Open the new project from Android Studio (File -> Open)
Upvotes: 52