0

I am working with Android Studio 1.1.0 on a MacBook Pro with OS X 10.9.5. When I import projects (Eclipse) I find the source code is put under a folder named "app".

Ok, so far so good. The projects build and .apk files named app-debug.apk and app-debug-unaligned.apk are generated. They execute fine on the emulator and target device (Samsung Galaxy S5).

I wanted to rename the app folder as well as the .apk files. The project name is tcpcommclient. I wanted to change the module name "app" to "TCP_Client". (not sure if I am allowed to do that).

I found the following in stackoverflow:

Why is my APK name generic?

Which said if I changed the folder name (app) I should also change settings.gradle. I did and that didn't work. I keep getting:

  Error:Android Source Generator: [tcpcommclient] AndroidManifest.xml file not found

I looked through my project for instances of ":app" and found three of the:

workspace.xml
settings.gradle
app.imi

in which I changed to ":TCP_Client". I also notice that app.imi (should be manually renamed?) is still around under TCP_Client.

What also happens is that the folder "app" seems to be created by Android Studio even when I deleted it manually. Also another app.imi file is created there which contains the following text:

<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
  <component name="NewModuleRootManager" inherit-compiler-output="true">
    <exclude-output />
    <orderEntry type="sourceFolder" forTests="false" />
  </component>
</module>

It seems like somehow I have Android Studio configured for this project so that it wants to see the source and the AndroidManifest.xml under the "app" folder.

Is there a way to change the name "app" to another name (namely "TCP_Client") and have that be the name of the .apk file?

Thanks in advance. Jim

Community
  • 1
  • 1
JimCzek
  • 335
  • 1
  • 4
  • 17
  • Yep, same problem here. At the end I use "app" :( I tried to do a refactor with rename but there are errors when you close and open again the project sometimes. My suggestion is to keep "app". – greywolf82 Mar 08 '15 at 18:24
  • Thanks. I also tried excluding the "app" folder by using the ProjectStructure>ProjectSettings>Modules>tcpcommclient>Sources>Exluded setting (red folder) for the "app" folder. I am still told that the AndroidManifest.xml file is missing even though it doe exist under TCP_Client. – JimCzek Mar 08 '15 at 18:45

2 Answers2

0

To rename a module:

  • Rename the folder from app to TCP_Client
  • In settings.gradle, replace include ':app' by include ':TCP_Client'.

Then resync the project with the Gradle files.

nhaarman
  • 98,571
  • 55
  • 246
  • 278
  • This does not work. After resyncing, Studio cannot find any modules at all. – Kevin Krumwiede Mar 08 '15 at 18:51
  • 1
    Normally this solution must work but I think you missed something that I can't remember – TooCool Mar 08 '15 at 18:56
  • I tried exactly what was recommended. It didn't work. – JimCzek Mar 08 '15 at 19:06
  • 2
    @JimCzek Clean the cache, remove the .idea folder and reimport the project applying the settings suggested by Niek. – Gabriele Mariotti Mar 08 '15 at 19:08
  • @Gariele: Thanks! Starting with a new import of the project (removed old import from Studio and deleted folders on HD) here is what worked: I imported the project. Deleted .idea and gradle. Renamed "app" to "TCP_Client". Modified the settings.gradle as noted. Sync'd and Rebuilt. The .apk files are now renamed as desired. I'll do these step up-front when I import projects in the future. Jim – JimCzek Mar 08 '15 at 20:54
-3

This is because Android Studio is a stripped-down version of IntelliJ IDEA that only allows you to create Gradle projects, and the Gradle plugin is nowhere near ready for prime time.

The easiest thing to do is just use a mature product like IDEA or Eclipse. But if you must use Studio, it's useful to know that app is actually the name of the Gradle module that it creates without bothering to ask you for a name. If you want a different name, create another module with the name you want, then delete the app module.

Kevin Krumwiede
  • 9,868
  • 4
  • 34
  • 82
  • Android studio and gradle are great and very much ready for prime time, and with 1.1 it's getting even better :-) – Jonas Czech Mar 08 '15 at 18:47
  • I was able to get the module and .apk files renamed. Here is what I did and why: – JimCzek Mar 08 '15 at 18:58
  • I was able to get the module and .apk files renamed. Here is what I did and why: I took the app.imi file that was generated under TCP_Client and copied it to the app.imi file that was living under the"app" folder. I figured Android Studio was bound and determined to look for the imi file under the app folder (which it creates) so I might as well have it look at what appeared to be a valid imi file with the settings I wanted. I synced and rebuilt the project. After that, no app.imi file under the app folder and the apk file is named TCP_Client-debug.apk. – JimCzek Mar 08 '15 at 19:05
  • @JimCzek Does it open correctly after restarting Studio? That seems to be the sticking point with a lot of complicated "solutions" for basic functionality in Studio. – Kevin Krumwiede Mar 08 '15 at 19:15
  • @Kevin: I have to say I don't think I stopped Studio after every iteration in trying to find a solution. I'm going to go through the renaming process for a project which will be "TCP_Server". I'll try the recommended approach first again but make sure I quit Studio. I'll post the results here. Thanks. – JimCzek Mar 08 '15 at 19:21
  • @JimCzek Regardless, your solution seems a lot more complicated than the one I suggested, which works and doesn't require any manual fiddling with config files. – Kevin Krumwiede Mar 08 '15 at 19:46
  • @Kevin: I tried the rename recommendation (mentioned several other places) while Android studio was not running and then modified the settings.gradle. I got the same results. The app folder was there with the app.imi file as I noted in my original post. I then copied the app.imi file from TCP_Server to the app folder and after exiting and resync'ing it worked as it did with TCP_Client (and the extra app.imi under app is gone). I'm not claiming this is a general solution but seems to work at least in this case. Thanks. Jim – JimCzek Mar 08 '15 at 19:53