2

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

5er
  • 2,506
  • 7
  • 32
  • 49
  • 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. – 5er Nov 25 '14 at 07:37
  • No, I'm saying, why don't you just define your SDK? – HarryCBurn Nov 25 '14 at 07:55
  • its not problem in SDK. I edited post. please check. – 5er Nov 25 '14 at 07:57
  • If it's not an issue with the SDK, why did you get that error? – HarryCBurn Nov 25 '14 at 07:58

2 Answers2

12

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.

AidenFry
  • 248
  • 3
  • 12
  • 1
    Re-starting Android Studio is not necessary - it is enough to call Build -> Clean Project – radistao Jul 06 '15 at 06:46
  • 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? – AidenFry Jul 13 '15 at 15:31
  • 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. – rupps Oct 29 '17 at 18:35
  • In my experience it fails to change the package name in the renamed modules `AndroidManifest.xml`. Just changing it manually works. – Jake Lee Jun 26 '18 at 09:12
  • Need also to change the path in gradle file: implementation project(path: ':newName') – Moti Dec 19 '18 at 08:20
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

Community
  • 1
  • 1
Emilgardis
  • 480
  • 4
  • 11