Following some links here I tried to rename a project. I went to c:\path\to\AndroidStudioProject and renamed the folder there, then found the .idea file and changed that. Now the project loads but java files are missing! However, on clicking java (in the bar at the top), then com I can see them each with a small red j. I then looked in module Gradle build where there were 3 files, one with the new name and 2 older ones which stated that they did not belong so I deleted them, copying the compile info into the new one. Naturally on doing a Sync Now I get a bunch of errors. Why does this have to be such a complex operation? Can anyone assist?
Asked
Active
Viewed 1,650 times
1 Answers
0
After you rename the folder, open the project in Android Studio. From there, right click something that needs to be renamed (e.g., module, package names, etc.) and use Refactor->Rename
from the context menu. Keep doing this until everything that can be refactored is.
You will need to manually change the value of applicationId
in the app-level build.gradle
. Obviously, things like @string/app_name
will also have to be changed manually. I recommend making these manual adjustments from inside Android Studio rather than directly editing the files. That way you'll know immediately if you break something.

Paul Ratazzi
- 6,289
- 3
- 38
- 50
-
Problem is that there is no build.gradle _(module)_ file anymore, only a _(project)_ one. I will look again and get back later. – Archdeacon Mar 12 '15 at 14:21
-
I am getting weird messages telling me I can only edit comments for 5 minutes, hence this one: Here is the error message: `Error:(7, 0) Gradle DSL method not found: 'compile()' Possible causes:The project 'Test' may be using a version of Gradle that does not contain the method. Gradle settings The build file may be missing a Gradle plugin. Apply Gradle plugin` What plugin? This is most confusing. – Archdeacon Mar 12 '15 at 14:41
-
See this: http://stackoverflow.com/questions/26851230/android-gradle-build-error9-0-gradle-dsl-method-not-found-compile. Are you sure you put things back in the right `build.gradle`? – Paul Ratazzi Mar 12 '15 at 14:53
-
I followed that link and removed some compile lines leaving only those below but get another error `dependencies { classpath 'com.android.tools.build:gradle:1.0.0' }` . The build.gradle(module) is missing. How can I create another one? This is the new error: ` Error:FAILURE: Build failed with an exception. * What went wrong: Task 'generateDebugSources' not found in project ':app'.` – Archdeacon Mar 12 '15 at 15:29
-
Make sure the `build.gradle` files are in the right folders. Use Explorer to open the project folder. The top should contain a `build.grade` containing a comment about being the top level build file. It should not have any `compile` lines, just the `classpath`. Drill into the `app` folder and make sure it contains another `build.gradle`. That one should have an `android{}` block with `defaultConfig{}`, and a `dependencies{}` block with `compile` lines. It should start with `apply`. Sounds like the second one of these (in the `app` folder) is not in the right place or is missing something. – Paul Ratazzi Mar 12 '15 at 15:58
-
We are slowly progressing. I have copied the relevant files from another project into the correct places and it all loads BUT I then get a message _Language level changed. Language level changes will take effect on project reload. Reload now? OK/Cancel_ This line of code now gives an error _Collection = new ArrayList<>(); Diamond types are not supported at this language level_. So how do I change the language level please? – Archdeacon Mar 12 '15 at 22:57
-
1Fixed. I just had to reload Android Studio. Thank you, Paul, for your help. Never will I fiddle with Gradle again! – Archdeacon Mar 12 '15 at 23:22
-
Really glad you got the last one taken care of because I had no clue! Nice to hear you're back in business. – Paul Ratazzi Mar 13 '15 at 00:11