[英]How to refactor Android package name on Android Studio, by adding a section?
I have an android application, with a package name that I want to change to allow for an update to be published to Google Play 我有一个Android应用程序,我想要更改包名称以允许更新发布到Google Play
This is on Android Studio, and I want to change the name from com.company.name
to com.something.company.name
However I could not find any resources to add the extra .something.
这是在Android Studio上,我想将名称从com.company.name
更改为com.something.company.name
但是我找不到任何资源来添加额外的.something.
to the package, only to rename existing parts. 到包,只重命名现有的部分。
Is there any method of doing so? 有没有这样做的方法?
You talking two separate things now. 你现在说两件事。 One is packageId
which is unique ID for your application (as used in Google Play). 一个是packageId
,它是您的应用程序的唯一ID (在Google Play中使用)。 And another thing is Java package name . 另一件事是Java包名 。 These two are not related really and do not have to stay in sync. 这两者实际上并不相关,也不必保持同步。
To change the packageId
just edit your Manifest file or go Project Strucure
dialog ( F4 ) then to app
tab, and either edit defaultConfig
's Application Id
or edit each flavour ( dev
, prod
etc, accordingly), if you want Id to differ in each flavor. 要更改packageId
只需编辑您的Manifest文件或进入Project Strucure
对话框( F4 )然后转到app
选项卡,然后编辑defaultConfig
的Application Id
或编辑每个flavor( dev
, prod
等),如果你想要Id的不同每种味道。
If you need to change your base package name do the following: 如果需要更改基本包名称,请执行以下操作:
Press Ctrl+Shift+R to open replace all window on Android Studio and replace all com.company.name
to com.something.company.name
. 按Ctrl + Shift + R打开替换Android Studio上的所有窗口,并将所有com.company.name
替换为com.something.company.name
。
Open com
folder on your file explorer and create a folder named something
and move company
folder and all its contents to your new something
folder. 在文件资源管理器上打开com
文件夹并创建一个名为something
文件夹,并将company
文件夹及其所有内容移动到新的something
文件夹中。
Rebuild your project. 重建您的项目。
src/main
在Project Tree src/main
选择要重命名的包 AndroidManifest.xml
and make sure the package
attribute contains the updated value. 找到AndroidManifest.xml
并确保package
属性包含更新的值。 You may need to edit this manually. 您可能需要手动编辑。 src/test
and src/androidTest
directories and they are not renamed automatically, repeat the above steps for these directories. 如果您有src/test
和src/androidTest
目录并且它们未自动重命名,请对这些目录重复上述步骤。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.