如何在 Android Studio 中正确更改现有项目名称?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22371108/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 05:53:00  来源:igfitidea点击:

How do I properly change my existing project name in Android Studio?

androidandroid-studio

提问by Azurespot

I tried to change my project name in Android Studio by the usual Refactor->Rename method, but since it did not really change it, it only made an add-on to the title OldName[NewName], I tried to just change the directory name itself. Since I will need that changed too. But then after I did that, I tried re-opening Android Studio and now it is freezing with the Waiting for ADBpopup. Which I then have to use Activity Monitor to force quit Android Studio.

我试图通过通常的 Refactor->Rename 方法在 Android Studio 中更改我的项目名称,但由于它并没有真正更改它,它只是对 title 进行了附加OldName[NewName],我尝试仅更改目录名称本身。因为我也需要改变。但是在我这样做之后,我尝试重新打开 Android Studio,现在它被Waiting for ADB弹出窗口冻结了。然后我必须使用活动监视器来强制退出 Android Studio。

So, is there a proper way to change the name of your existing Android Studio project so that it really changes the name everywhere? Or are there a few steps to take to make sure it is changed everywhere? I also would then want my package renamed, since it took the name of my app name at creation. Thanks for your help.

那么,有没有一种正确的方法来更改您现有的 Android Studio 项目的名称,以便它真的在任何地方更改名称?或者是否需要采取一些步骤来确保它随处更改?我还希望我的包重命名,因为它在创建时采用了我的应用程序名称。谢谢你的帮助。

回答by Andrey

In Android Studio you can change the name of the Android project in the file:

在 Android Studio 中,您可以在文件中更改 Android 项目的名称:

.idea/.name

location of file

文件位置

Then File -> Invalidate caches/Restart

然后 File -> Invalidate caches/Restart

Upd:

更新:

Things have changed, so now just in the

事情发生了变化,所以现在就在

settings.gradle

file change or create the line

文件更改或创建行

rootProject.name = 'Your project name'

回答by Jocheved

The name of your application is not related to your Eclipse project name, open your res/values/strings.xml and modify app_name item to change your application name. You should change the name of your application from androidManifest.xml

您的应用程序名称与您的 Eclipse 项目名称无关,打开您的 res/values/strings.xml 并修改 app_name 项以更改您的应用程序名称。您应该从 androidManifest.xml 更改应用程序的名称

android manifest

安卓清单

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >

strings.xml

字符串.xml

<string name="app_name">newnameofapp</string>

By changing the package name also a method... try

通过更改包名也是一种方法......试试

Right click on the project -> Android Tools -> Rename Application package

回答by Khan

idea/.name 

Change the file content then restart android studio. Works for me.

更改文件内容然后重新启动android studio。为我工作。

回答by u4358758

Go to [Tool Window\Project] by Alt+1, and change the level on the top-left corner of this window to Project (the other two are Packages and Android), then you can rename the Project name by Shift+F6. Type in the new name and press OK.

通过+进入【Tool Window\ Project】,将这个窗口左上角的 level 改为 Project(另外两个是 Packages 和 Android),然后可以通过+重命名 Project 名称。输入新名称,然后按 OK。Alt1ShiftF6

If you just want to change the app name which appears in the system, you can modify the android:titlein the manifest.xml.

如果你只是想改变出现在系统中的应用程序的名称,你可以修改android:titlemanifest.xml文件

回答by jim

I think the best way to do it is to import the project into Eclipse. Change project name and refactor paths in Eclipse. It is easy in Eclipse. Then import the project into android-studio.
Yes, it seems that IJ has some interesting functionality (including refactoring) but some functionality does not work. It works in Eclipse and I hope that google is listening and will provide SDK for Eclipse again. Or at least explain why they dropped Eclipse and went to IJ. I just hope that the reason is not that AS was "invented" in google but Eclipse was not. (NIH syndrome).

我认为最好的方法是将项目导入 Eclipse。在 Eclipse 中更改项目名称和重构路径。在 Eclipse 中很容易。然后将项目导入android-studio。
是的,似乎 IJ 有一些有趣的功能(包括重构),但有些功能不起作用。它在 Eclipse 中工作,我希望谷歌正在倾听并再次为 Eclipse 提供 SDK。或者至少解释一下他们为什么放弃 Eclipse 而转向 IJ。我只是希望原因不是 AS 是在 google 中“发明”的,而 Eclipse 不是。(NIH 综合征)。