简体   繁体   English

如何在 Android Studio 3+ 上更改项目名称

[英]How to change project name on Android Studio 3+

创建 Android 项目后,如何在不破坏任何内容的情况下更改其项目名称

Most answers addressing this question are somehow outdated and does not work with the Android Studio 3+ version.解决这个问题的大多数答案在某种程度上已经过时,并且不适用于 Android Studio 3+ 版本。 This is what works for me and should work if you wish to change the project name (name of the project root folder, usually located at the directory C:/.../AndroidStudioProjects on your computer), application ID (the name used to identify your app on Play Store).这对我有用,如果您希望更改项目名称(项目根文件夹的名称,通常位于您计算机上的目录 C:/.../AndroidStudioProjects)、应用程序 ID(用于在 Play 商店中识别您的应用)。

Note that you cannot change an app's application ID after it has been published to Play Store, except if you want to create another application using the same code (ie, changing the ID after Play Store publication would cause Play Store to assume the app is a different one than the one bearing the previous application ID even if they offer the same functionality)请注意,应用发布到 Play 商店后,您无法更改其应用 ID,除非您想使用相同的代码创建另一个应用(即,在 Play 商店发布后更改 ID 会导致 Play 商店假定该应用是与带有先前应用程序 ID 的应用程序 ID 不同,即使它们提供相同的功能)

Starting with the project name, say project name is MyFirstApp , Open Android Studio, locate the settings.gradle file of that project, change the value of this attribute rootProject.name= to the new name you want for the project.从项目名称开始,假设项目名称是MyFirstApp ,打开 Android Studio,找到该项目的 settings.gradle 文件,将此属性rootProject.name=的值更改为您想要的项目新名称。 Close Android Studio, locate the MyFirstApp folder within AndroidStudioProjects folder on your computer directory, right click on the folder and select rename from the dialog box.关闭 Android Studio,在您的计算机目录中的 AndroidStudioProjects 文件夹中找到MyFirstApp文件夹,右键单击该文件夹并从对话框中选择重命名。 Then enter the new name you prefer.然后输入您喜欢的新名称。 Open Android Studio, on the top left corner, click file>>open>>MyFirstApp.打开Android Studio,在左上角,点击文件>>打开>>MyFirstApp。 You should get a sync successful.您应该会成功同步。

To change application ID is easier, just change the attribute of : 1. applicationId in build.grade(Module) to the new application ID you want 2. app_name in strings.xml to the new application ID you want 3. Ensure the value of android:label in AndroidManifest.xml is set to "@string/app_name"要更改应用程序ID很容易,只需要改变的属性:1 applicationId在build.grade(模块),以新的应用程序ID,你想2. app_name中的strings.xml您要3.新的应用程序ID确认的价值AndroidManifest.xml 中的 android:label 设置为"@string/app_name"

To rename any other file in your project on Android Studio, simply right click on the file on the project directory (usually the pane on the top left of Android Studio), select refactor>>rename file.要在 Android Studio 上重命名项目中的任何其他文件,只需右键单击项目目录中的文件(通常是 Android Studio 左上角的窗格),选择重构>>重命名文件。 Ensure you keep these boxes checked search for references and search in comments and strings确保选中这些框search for referencessearch in comments and strings

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM