3

After renaming module in Android Studio i get error Project SDK is not defined.

How can I rename module from app to my-name whit out getting error.

The problem is with renaming, I believe.

I use Shift+Alt+R to rename the module. If I rename the directory I get this error. If I rename module, after restart there are no previous changes. the problem is not in setting SDK, the problem is that classes are no longer in package. The AS doesn't know that this module is android app because there is also previously created

4
  • this is the error that I get. The problem is with renaming, I believe. shift + alt + R to rename the module. If I rename the directory I get this error. If I rename module, after restart there are no previous changes. Commented Nov 25, 2014 at 7:37
  • No, I'm saying, why don't you just define your SDK? Commented Nov 25, 2014 at 7:55
  • its not problem in SDK. I edited post. please check. Commented Nov 25, 2014 at 7:57
  • If it's not an issue with the SDK, why did you get that error? Commented Nov 25, 2014 at 7:58

2 Answers 2

13

To raname a module, go to settings.gradle and rename the module to your new name. Then close Android Studio, and rename the folder using File Explorer. Now reopen Android studio and your module name will be updated.

Simply renaming using the refactor tool does not do the job.

Sign up to request clarification or add additional context in comments.

5 Comments

Re-starting Android Studio is not necessary - it is enough to call Build -> Clean Project
radistao, your correct! I was just pointing out that you should rename it in Finder or whatever the file explorer is for your PC. jsanmarb, i don't understand what you mean, does the above not work for you?
This is late 2017 and in my experience renaming modules using the IDE now works more or less flawlessly. You might need to manually update settings.gradle if that renamed module is included in other projects, or perform a project clean, but other than that, it works.
In my experience it fails to change the package name in the renamed modules AndroidManifest.xml. Just changing it manually works.
Need also to change the path in gradle file: implementation project(path: ':newName')
1

I think the problem is that the command for compiling is the same, and when the program tries to do compilation the unchanged name is passed in instead of the new name.

See Android Studio - How to Change Android SDK Path

File->Project Structure->SDK(under Platform Settings)->Android SDK

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.