[英]Change project name on Android Studio
I want to change the name of my project and module.我想更改我的项目和模块的名称。 But if I try to rename them Android Studio notify me some errors...但是如果我尝试重命名它们 Android Studio 会通知我一些错误......
eg I want to change the name from "MyApplication" to "AndroidApp" as shown in the image below.例如,我想将名称从“MyApplication”更改为“AndroidApp”,如下图所示。
In the first rectangle I want to change it in:在第一个矩形中,我想将其更改为:
AndroidApp ("G:...\Android\AndroidApp). AndroidApp ("G:...\Android\AndroidApp)。
In the second rectangle I want to change it in:在第二个矩形中,我想将其更改为:
AndroidApp [AndroidApp-AndroidApp] AndroidApp [AndroidApp-AndroidApp]
edit: This is the log:编辑:这是日志:
Gradle: Project 'AndroidApp' not found in root project 'MyApplicationProject'. Gradle:在根项目“MyApplicationProject”中找不到项目“AndroidApp”。
build.gradle: build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 18
buildToolsVersion "18.0.1"
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
}
dependencies {
compile 'com.android.support:support-v4:18.0.0'
}
settings.gradle:设置。gradle:
include ':MyApplication'
This did the trick for me:这对我有用:
If your settings.gradle
contains the below line, either delete it or update it to the new name.如果您的settings.gradle
包含以下行,请将其删除或更新为新名称。
rootProject.name = 'Your project name'
Edit:编辑:
Working in all versions!在所有版本中工作! Last test: Android Studio Chimpmunk Jun 2022 .最后一次测试: Android Studio Chimpmunk Jun 2022 。
您可以更改文件“.idea/.name”中标题栏中显示的名称。
Update: This is an out-dated response from 2013 and only works for v2.2.2 and below.更新:这是 2013 年的过时响应,仅适用于 v2.2.2 及以下版本。
Right-click on your root project directory右键单击您的根项目目录
Select Refactor -> Rename选择重构 -> 重命名
Select rename project and change the name there.选择重命名项目并在那里更改名称。
Also Select rename module and change it there as well.还选择重命名模块并在那里进行更改。 If you get an message saying module name already changed thats fine.如果您收到一条消息说模块名称已更改,那很好。
Now right-click on the project root folder again and select Open Module Settings.现在再次右键单击项目根文件夹并选择打开模块设置。
Under the Modules section remove whatever folders are associated to your old project name.在 Modules 部分下,删除与旧项目名称关联的所有文件夹。
Apply Settings and hit OK.应用设置并点击确定。
Restart Android Studio.重启安卓工作室。
Hope that helps!希望有帮助!
update July/2017: tested and worked 2017 年 7 月更新:测试和工作
->Change the Project Name<- ->更改项目名称<-
Change the name of your project by closing the Android Studio, go to your project folder, rename it…通过关闭 Android Studio 更改您的项目名称,转到您的项目文件夹,重命名它......
Delete the .idea folder and .iml file.删除.idea文件夹和.iml文件。 (To show hidden folders, press Cmd + Shift + . (dot) ) . (要显示隐藏文件夹,请按Cmd + Shift + .(点)) 。
Open the settings.gradle file with a text editor, like VSCode, and change the rootProject.name to your new project name.使用文本编辑器(如 VSCode)打开settings.gradle文件,并将rootProject.name更改为您的新项目名称。
Done!完毕! The project name has been changed!项目名称已更改! Just open your project with the Android Studio and Gradle will sync again.只需使用Android Studio打开您的项目, Gradle就会再次同步。
UPDATE :更新:
This answer is better.这个答案更好。
OLD ANSWER : 1. Right click your旧答案:1.右键单击您的
ackage name and Refactor -> Rename...
ackage 名称和Refactor -> Rename...
Rename directory
or Rename package
, choose Rename package
当询问您是否要Rename directory
或Rename package
时,请选择Rename package
Reopen project in Android Studio with new folder name使用新文件夹名称在 Android Studio 中重新打开项目
Cmd + Shift + f
for any instances of your old name in Android Studio, and change all of them to the new name. Cmd + Shift + f
用于 Android Studio 中旧名称的任何实例,并将它们全部更改为新名称。
Change the applicationId
in your build.gradle
更改build.gradle
中的applicationId
BONUS ROUND:奖金回合:
.gitignore
file if it was at the root of your project.如果.gitignore
文件位于项目的根目录,您可能需要更新它。 Note that when swapping branches after doing this, you'll potentially see a bunch of files showing up in working changes, but don't worry they should go away after you merge in your renamed branch with updated .gitignore
.请注意,在执行此操作后交换分支时,您可能会看到一堆文件显示在工作更改中,但不要担心在您将重命名的分支与更新的.gitignore
合并后它们会消失。 Don't manually remove these as it can cause issues in Android Studio.不要手动删除这些,因为它可能会导致 Android Studio 出现问题。Just find the name " android:label="AppName" " from the Android Manifest .只需从 Android Manifest 中找到名称“ android:label="AppName" ”。 Just rename the label name (eg: "AppName" here) all such android:label in the AndroidManifest.xml .只需在 AndroidManifest.xml 中重命名所有此类 android:label 的标签名称(例如:“AppName”)。 Just save it !只要保存它! When you run the app you will see the new Name运行应用程序时,您将看到新名称
Just go to res>values>strings.xml.只需转到 res>values>strings.xml。 One line says Somethig-your name一行写着Somethig-你的名字
<string name="app_name">Somethig-your name</string>
Just replace your original name to只需将您的原始名称替换为
<string name="app_name">Your Name</string>
Close Android Studio.关闭安卓工作室。
Rename the folder of the root of the project.重命名项目根目录的文件夹。 For example, change "MyApplication" to "Myblablabla".例如,将“MyApplication”更改为“Myblablabla”。
Delete the '.idea' folder.删除“.idea”文件夹。
Open Android Studio, and import the updated project.打开 Android Studio,并导入更新后的项目。
What worked for me is:对我有用的是:
GoTo去
setting.gradle
And you are done!你完成了!
1.Edit settings.gradle file, change rootProject.name 1.编辑settings.gradle文件,修改rootProject.name
rootProject.name = "FirebaseDemo"
include ':app'
2.Go to the project file folder, rename the file folder 2.进入项目文件夹,重命名文件夹
3.Delete .idea folder in your project and rebuild the project 3.删除项目中的.idea文件夹并重建项目
For one, I'd strongly suggest updating to the latest Android Studio (0.3.7 as of now);一方面,我强烈建议更新到最新的 Android Studio(截至目前为 0.3.7); there are tons of bug fixes.有大量的错误修复。
You're running into bug https://code.google.com/p/android/issues/detail?id=57692 , which is that if you try to use the UI to rename modules or your project, it doesn't update the build files.您遇到了错误https://code.google.com/p/android/issues/detail?id=57692 ,即如果您尝试使用 UI 重命名模块或项目,它不会更新构建文件。 Sorry, it's really broken right now.对不起,现在真的坏了。 I'd suggest changing the directory names directly in the filesystem, and updating your settings.gradle
file to reflect the changes.我建议直接在文件系统中更改目录名称,并更新您的settings.gradle
文件以反映更改。 Your project on disk should look something like this (with many more files than what's shown here):您在磁盘上的项目应该看起来像这样(文件比这里显示的要多):
projectFolder
|--settings.gradle
|--applicationModuleFolder
| |--build.gradle
| |--src
it uses projectFolder's name as the project name and applicationModuleFolder as the name of the module that your Android App lives in (the upper and lower outlined boxes in your screenshot, respectively).它使用 projectFolder 的名称作为项目名称和 applicationModuleFolder 作为您的 Android 应用程序所在的模块的名称(分别在屏幕截图中的上框和下框)。 I think the way your project is set up now, they both have the same name;我认为您现在的项目设置方式,它们都具有相同的名称; you can rename both to the same new name if you like, or you can give them different names;如果愿意,您可以将两者重命名为相同的新名称,也可以给它们起不同的名称; it doesn't matter.没关系。
Once they're renamed, edit your settings.gradle
file;重命名后,编辑您的settings.gradle
文件; it will look something like:它看起来像:
include ':applicationModuleFolder'
just change the name to your new name there as well.只需将名称更改为您的新名称。 Once these changes are made, click the Sync Project with Gradle Files button in the toolbar (if you're running a very old version of Android Studio, it may not have that button, so you can close the project and reopen it in that case) and it should pick up the changes.完成这些更改后,单击工具栏中的Sync Project with Gradle Files按钮(如果您运行的是非常旧版本的 Android Studio,它可能没有该按钮,因此您可以关闭项目并在这种情况下重新打开它) 并且它应该接受更改。
A very quick way to solve this as at November 2020 is by the following steps截至 2020 年 11 月,解决此问题的一种非常快速的方法是通过以下步骤
hit the shift key twice, a pop up will show search for a file named "settings.gradle" when it opens change the rootProject.name = "Old-name" to rootProject.name = "new name" then sync.按两次 shift 键,弹出窗口将显示搜索名为“settings.gradle”的文件,打开时将 rootProject.name =“Old-name”更改为 rootProject.name =“new name”,然后同步。
hit the shift key twice, a pop up will show search for a file named "string.xml", when it opens change <string "app_name">old-name to <string "app_name">new-name按两次 shift 键,弹出窗口将显示搜索名为“string.xml”的文件,当它打开时将 <string "app_name">old-name 更改为 <string "app_name">new-name
close android studio关闭安卓工作室
locate androidStudioProject directory on your machine, open it and find the project by its old name, rename it to the new name.在您的机器上找到 androidStudioProject 目录,打开它并按旧名称找到项目,将其重命名为新名称。
open Android Studio goto File > Open > "new name".打开 Android Studio 转到文件 > 打开 > “新名称”。 open it from there.从那里打开它。
this is currently working on Android Studio 4.1.1这目前适用于 Android Studio 4.1.1
You can try something like this in your settings.gradle
file:你可以在你的settings.gradle
文件中尝试这样的事情:
rootProject.name = "YOUR_PROJECT_NAME"
After restarting of Android Studio it will also change text in title bar to YOUR_PROJECT_NAME
.重新启动 Android Studio 后,它还会将标题栏中的文本更改为YOUR_PROJECT_NAME
。
Tested on Android Studio 2.2 RC2在 Android Studio 2.2 RC2 上测试
Just change the application id in build.gradle只需更改 build.gradle 中的应用程序 ID
applicationId "yourpackageName"
For changing application label, in manifest用于更改应用程序标签,在清单中
<application
android:label="@string/app_name"
... />
Video tutorial: https://youtu.be/7aQjiae2doU视频教程: https ://youtu.be/7aQjiae2doU
com.example.[NewFileName]
in path:将名称重构为路径中的com.example.[NewFileName]
:
app>java>com.example.[OldFileName]应用>java>com.example.[OldFileName]
<string name="app_name”>[NewFileName]</string>
in path:转到 strings.xml 并将代码更改为<string name="app_name”>[NewFileName]</string>
在路径中:
app>res>values>strings.xml应用>资源>值>strings.xml
applicationId "com.example.[NewFileName]”
in path:转到 build.gradle (Module: app) 并将路径中的代码更改为applicationId "com.example.[NewFileName]”
:
Gradle Scripts>build.gradle (Module: app) Gradle Scripts>build.gradle(模块:app)
rootProject.name='[NewFileName]'
in path:转到 settings.gradle(项目设置)并将代码更改为rootProject.name='[NewFileName]'
在路径中:
Gradle Scripts>build.gradle (Project Settings) Gradle Scripts>build.gradle(项目设置)
Sync now
prompt按立即Sync now
提示[NewFileName]
outside Android Studio将您的文件夹重命名为 Android Studio 外部的[NewFileName]
Build>Rebuild Project构建>重建项目
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 . Alt + 1进入[ Tool Window \ Project ],将该窗口左上角的层级更改为Project(另外两个是Packages和Android),然后您可以通过Shift + F6重命名Project名称。 Type in the new name and press OK.输入新名称,然后按 OK。
If you just want to change the app name which appears in the system, you can modify the android:title
in the manifest.xml .如果您只是想更改系统中出现的应用名称,您可以修改manifest.xml中的android:title
。
You can easily rename using refactor.您可以使用重构轻松重命名。
Write click on the project root folder and click refactor.写入单击项目根文件夹,然后单击重构。
Then click on the rename, there will be a popup, you can give new name there.然后点击重命名,会有一个弹出窗口,你可以在那里给新的名字。
What works for me is,对我有用的是,
Go To Build.gradle Change ApplicationId & sync project.转到 Build.gradle 更改 ApplicationId 并同步项目。
Right click on your project > Rename > Rename Package.右键单击您的项目 > 重命名 > 重命名包。
Run your app and boom.运行您的应用程序并繁荣。
Hope this works as did for me希望这对我有用
To change the apps name in Android Studio:要在 Android Studio 中更改应用名称:
Close the project in Android studio and get rid of it from the quick start side of the launcher ( Should be a mini next to the name).在 Android Studio 中关闭项目,然后从启动器的快速启动端将其删除(名称旁边应该是一个 mini)。
Close Android Studio.关闭安卓工作室。
Go into where your app file is located and rename it (Under My Documents Usually).进入您的应用程序文件所在的位置并重命名它(通常在我的文档下)。
Restart Android Studio, select add new project and navigate to the folder that was renamed.重新启动 Android Studio,选择添加新项目并导航到重命名的文件夹。
Changing the label of the launcher of the application / The applications actual name:更改应用程序启动器的标签/应用程序实际名称:
Eg: android:label="Developer Portal".例如:android:label="开发者门户"。
For me the following works:对我来说,以下作品:
Here's what I did in Android Studio Beta (0.8.14)这是我在 Android Studio Beta (0.8.14) 中所做的
And vola, my package name has now changed and builds successfully.和 vola,我的包名现在已经更改并成功构建。
changing following thing worked for me.改变以下事情对我有用。 settings.gradle-> rootProject.name='MyEvinApp'
change rootProject.name
will take android studio as project name settings.gradle-> rootProject.name='MyEvinApp'
更改rootProject.name
将 android studio 作为项目名称
Try to change android:label
in AndroidManifest.xml and reinstall/rerun app:尝试更改AndroidManifest.xml中的android:label
并重新安装/重新运行应用程序:
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
Here is how it all changes in seconds... in your "manifest.xml" find "android:label=" in front of it just type your new name inside "" for example: android:label="My new name"以下是它在几秒钟内发生的变化......在你的“manifest.xml”中找到“android:label=”,只需在“”中输入你的新名称,例如:android:label="My new name"
Its done!完成! your welcome ;)别客气 ;)
I just went into the manifest and changed android:label="...." to the name of the application.我刚刚进入清单并将 android:label="...." 更改为应用程序的名称。 Once Id changed this, the title and the actual app name changed to that :)一旦 Id 改变了这个,标题和实际的应用程序名称就改变了 :)
Hello RobertoAV96 ,你好罗伯托AV96 ,
I have provided three solutions here.我在这里提供了三个解决方案。 Choose whichever applies to your problem.选择适用于您的问题的那个。
If you want to just change the name of the project root folder name, you can do it from the explorer:如果您只想更改项目根文件夹名称的名称,可以从资源管理器中进行:
iml
file in this root folder to the name of the folder.将此根文件夹中的iml
文件重命名为该文件夹的名称。 That is if the project root folder's name was say demo_project
, there will be demo_project.iml
file inside it.也就是说,如果项目根文件夹的名称是demo_project
,那么里面会有demo_project.iml
文件。 If you changed this folder's name to say my_project
, then you have to change the name of the iml
file inside it to my_project.iml
.如果您将此文件夹的名称更改为my_project
,那么您必须将其中的iml
文件的名称更改为my_project.iml
。 Actually the refactor
option from the Studio
can do the same.实际上,来自Studio
的refactor
选项也可以做到这一点。
If you want to change the
app
folder's name, that is inside theroot folder
of the project, do the same in the explorer:如果要更改项目root folder
内的app
文件夹名称,请在资源管理器中执行相同操作:
app
folder to the name you like to have.将app
文件夹重命名为您喜欢的名称。[ INFO: The
APK
file, that is generated for this project, will acquire the same first name followed by the suffix that represents the mode you build the signedAPK
for, that is eitherdebug
orrelease
. [信息:为此项目生成的APK
文件将获取相同的名字,后跟代表您构建签名APK
的模式的后缀,即debug
或release
。 SignedAPK
is found in it's respective folder ofdebug
orrelease
.签名的APK
位于其各自的debug
或release
文件夹中。 The unsigned APK is located inoutput
folder ofbuild
directory, allbuild
,debug
andrelease
folders are found in the primaryapp
folder, or the folder you have renamed this folder to].未签名的 APK 位于build
目录的output
文件夹中,所有build
、debug
和release
文件夹都位于主app
文件夹中,或者您将此文件夹重命名为的文件夹]。
my_project_app
, open the folder and rename the app.iml
, to my_project_app.iml
after the name of the project.假设您为此文件夹指定的名称是my_project_app
,打开文件夹并将app.iml
重命名为项目名称后的my_project_app.iml
。settings.gradle
file.现在转到项目的根文件夹,找到settings.gradle
文件。The content of this file are the names of module folders that you include in the project, currently there is only one module, that is the main one :该文件的内容是您在项目中包含的模块文件夹的名称,目前只有一个模块,即主模块:
include ':app'
This is corresponding to the old name of the app
folder.这对应于app
文件夹的旧名称。
Hence you have to make the changes:因此,您必须进行更改:
include ':my_project_app'
That's it.而已。 Now you can reload the project in the studio
, and check the name of the APK
that is generated.现在您可以在studio
中重新加载项目,并检查生成的APK
的名称。
If you want to rename the package name, say
com.first.myproject
tocom.alpha.myproject
:如果要重命名包名称,com.first.myproject
改为com.alpha.myproject
:
src-->main-->java
, your package is com-->first-->myproject
.再次转到资源管理器:在src-->main-->java
的文件夹层次结构中,您的包是com-->first-->myproject
。 Make sure your Studio
is closed.确保您的Studio
已关闭。first
to alpha
. first
将第二个文件夹重命名为alpha
。Studio
now.现在打开Studio
。 Choose Replace in Path
in the first package inside the java
folder, in the Android
mode of the left panel tree .在左侧面板树的Android
模式下,选择java
文件夹内第一个包中的Replace in Path
。 This one is the package that you changed from the Explorer
, that is: com.alpha.myproject
instead of com.first.myproject
.这个是您从Explorer
更改的包,即: com.alpha.myproject
而不是com.first.myproject
。 Change the instances of the string import com.first.myproject;
更改字符串import com.first.myproject;
in files to import com.alpha.myproject;
在文件中import com.alpha.myproject;
. . Check for just the string occurrence of com.first.myproject
, and safely change it to com.alpha.myproject
.只检查com.first.myproject
的字符串出现,然后安全地将其更改为com.alpha.myproject
。com.first.myproject
, in build.gradle
inside your main app
module , and safely change it to com.alpha.myproject
.在主app
模块内的com.first.myproject
中检查build.gradle
的字符串出现,并安全地将其更改为com.alpha.myproject
。com.alpha.myproject
afresh and unpublish com.first.myproject
, affecting lots of users:- you have to broadcast to the users using push notification, in the latest version of old existing APK
, that the new Application version will be released with different name, and you have to publish this new APK
, restarting from version name 1.0
.如果您已经在 Play 商店中发布了您的应用程序,那么您必须重新设置一个不同的项目com.alpha.myproject
并取消发布com.first.myproject
,这会影响很多用户:- 您必须使用推送通知向用户广播,在旧的现有APK
的最新版本中,新的应用程序版本将以不同的名称发布,您必须发布这个新的APK
,从版本名称1.0
重新开始。 This destroys objective of having the application slot at play-store for the old APK
.这破坏了在旧APK
的 play-store 中拥有应用程序插槽的目标。 So you have to consult your client that what should be the name of their application package before starting the project.因此,在开始项目之前,您必须咨询您的客户,他们的应用程序包的名称应该是什么。Studio
to remove unnecessary resources from your project.您可以在Studio
中发出命令以从项目中删除不必要的资源。 You can manually deal with all the warnings
that LINT produces.您可以手动处理LINT产生的所有warnings
。Happy coding and Happy app publishing.快乐的编码和快乐的应用发布。 :-) :-)
The way it worked for me in order to replace the old name of my project for a new one (everywhere in my codebase) is the following:为了将我的项目的旧名称替换为新名称(在我的代码库中的任何地方),它对我的工作方式如下:
NOTE: This worked for Android Studio 2.1.2注意:这适用于 Android Studio 2.1.2
关闭 android studio 并在文件资源管理器中重命名 .iml 文件即可
Changing the name in res>values>strings.xml will change the app name that is shown in the apps menu after installation更改 res>values>strings.xml 中的名称将更改安装后应用程序菜单中显示的应用程序名称
Renaming the android studio project folder (when android studio is closed) will likely satisfy many developers重命名 android studio 项目文件夹(当 android studio 关闭时)可能会让很多开发者满意
These instructions below worked (first time) for me in Android Studio 2.3.下面的这些说明(第一次)在 Android Studio 2.3 中对我有用。 They involve creating a new app in Android Studio, then closing it and doing all the work in a file explorer and a text editor.它们涉及在 Android Studio 中创建一个新应用,然后关闭它并在文件浏览器和文本编辑器中完成所有工作。
Refactor and Rename a Android Studio Project or App 重构和重命名 Android Studio 项目或应用程序
Note: Requires a text editor which can do a global search-and-replace in a directory structure.注意:需要一个可以在目录结构中进行全局搜索和替换的文本编辑器。 The instructions propose Sublime Text
, which I easily installed and ran.说明提出了Sublime Text
,我很容易安装并运行它。
It produced a new app which installed and ran beside the existing app.它生成了一个新应用程序,该应用程序在现有应用程序旁边安装并运行。 It still had the same screen name, which was fixed by editing Android:label="MyNewApp"
in the manifest.它仍然具有相同的屏幕名称,这是通过在清单中编辑Android:label="MyNewApp"
的。
it will work fine for me它对我来说很好用
Change Following.
Step 1: Make sure ApplicationId And PackageName will Same.第 1 步:确保 ApplicationId 和 PackageName 相同。 example :例子 :
android {
defaultConfig {
applicationId "com.example.myapplication"
}
}
and package name the same. package="com.example.myapplication"
Step 2 delete iml file in my case :第 2 步在我的情况下删除 iml 文件:
Go To Project> >C:\Users\ashif\Documents\MyApplication .iml file // delete
if you forget Project Path Then Go To android Studio Right Click on app and go to Show in Explorer you get your Project and remove .iml file
Step 3 Close Project步骤 3关闭项目
Step 4 Now Copy Your old Project and Paste Any other Root or copy Project Folder and paste Any other Dir.第 4 步现在复制您的旧项目并粘贴任何其他根目录或复制项目文件夹并粘贴任何其他目录。
Example C:\Users\ashif\Documents/MyApplication
Step 5第 5 步
Now open Android Studio and open Existing Project
C:\Users\ashif\Documents/MyApplication
Try it will work试一试会奏效
This approach 100% working这种方法 100% 有效
Just do these simple step:只需执行以下简单步骤:
TL;DR: TL;博士:
You may only follow the last part Renaming , maybe only images in it... ;-)您可能只关注最后一部分Renaming ,也许只关注其中的图像...... ;-)
There is no such thing as Android Studio's “Project name” .没有Android Studio 的“项目名称”之类的东西。 But they are other names, entered during creating a new project:但它们是其他名称,在创建新项目时输入:
In general, people want to change these 3 names, mostly to be derived from the Gradle's root project name in the same way as it is proposed in the New Project dialog window.通常,人们希望更改这 3 个名称,主要是从 Gradle 的根项目名称派生而来,其方式与“新建项目”对话框 window 中建议的方式相同。
So my answer will cover this case.所以我的回答将涵盖这种情况。
We may to follow the same steps as Android Studio does when creating a new project.我们可以按照与 Android Studio 在创建新项目时相同的步骤进行操作。
If you chose File → New → New Project... (and then a project template), the first field in the New Project dialog window is the “Name” field with offered name My Application .如果您选择File → New → New Project... (然后是项目模板),New Project 对话框 window 中的第一个字段是提供名称My Application的“Name”字段。
The 2 next fields uses this (default or changed) name to derive the default for 2 other strings, so there are 3 important strings , for example接下来的 2 个字段使用此(默认或更改的)名称来派生其他 2 个字符串的默认值,因此有3 个重要字符串,例如
Moreover,而且,
So, there are 4 things which we have to ensure during renaming to other name – I will use the name My Renamed Project as a base for new names.因此,在重命名为其他名称期间,我们必须确保 4 件事——我将使用名称My Renamed Project作为新名称的基础。
Let's begin with the last, probably the simplest one:让我们从最后一个开始,可能是最简单的一个:
Please, no new build from this moment until the full renaming finishes.拜托,从这一刻起,直到完全重命名完成之前,没有新版本。
Now, begin renaming by previously specified 3 points:现在,按之前指定的 3 个点开始重命名:
My Application :我的申请:
In the leftmost position of the title bar of the Android Studio Window, you see the same text as I selected in the settings.gradle
file:在 Android Studio Window 的标题栏最左边的 position 中,您看到的文本与我在settings.gradle
文件中选择的文本相同:ZC88ED1A7CD68923
Change this text to the new name ( My Renamed Application ).将此文本更改为新名称(我的重命名应用程序)。 The yellowish bar will appear near the top.黄色条将出现在顶部附近。
Click the “Sync Now” in the right-hand part of it:单击右侧的“立即同步”:
You will immediately see the change in the title bar:您将立即在标题栏中看到更改:
You probably want to change the application name to the same name, too, so change it in the strings.xml
resource file (the change will then reflect in the AndroidManifest.xml
file, which is important):您可能也想将应用程序名称更改为相同的名称,因此请在strings.xml
资源文件中进行更改(更改将反映在AndroidManifest.xml
文件中,这很重要):
Before renaming:改名前:
After renaming:改名后:
com.something. com.something。 myapplication :我的应用程序:
Change the applicationID
in the build.gradle
(module level) file - the new name, derived from “My Renamed Application” will be without spaces, all lowercase, ie myrenamedapplication
:更改build.gradle
(模块级)文件中的applicationID
- 源自“My Renamed Application”的新名称将不包含空格,全部小写,即myrenamedapplication
:
Before changing:更改前:
After changing:更改后:
The yellowish bar will appear again near the top.黄色条将再次出现在顶部附近。
Click the “Sync Now” in the right-hand part of it:单击右侧的“立即同步”:
Now close the Android Studio, and rename the folder现在关闭 Android Studio,并重命名文件夹
MyApplication
(probably located in the folder C:\Users\someuser\AndroidStudioProjects\
) (可能位于文件夹C:\Users\someuser\AndroidStudioProjects\
中)
to至
MyRenamedApplication
(the name, derived from “My Renamed Application”, is without spaces). (该名称源自“我的重命名应用程序”,没有空格)。
Although this step is optional, it is highly recommended to keep things tidy.尽管此步骤是可选的,但强烈建议保持整洁。
Note:笔记:
Opening the renamed project with File → Open Recent will of course fail, so for the first time after renaming, open it with File → Open .用File → Open Recent打开重命名的项目当然会失败,所以第一次重命名后,用File → Open 打开。
To just rename the project:要重命名项目:
To change the package name:要更改包名称:
The easiest and fastest solution is here: https://stackoverflow.com/a/35057550/4908798最简单和最快的解决方案在这里: https ://stackoverflow.com/a/35057550/4908798
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.