是否有办法更改Flutter项目的Package Name ?

我想在flutter项目中更改包名和应用名。


当前回答

简单的方法,在编辑器中搜索例如vs CODE your.package.name例如com.example.application通过所有文件。

3个AndroidManifest文件(profile, debug, main) 1 build.gradle 1 java 或者kt文件

这些会弹出

替换所有这些,瞧。如果你已经构建了你的项目,build目录中会弹出许多文件,你可以忽略这些文件,不需要更改它们

其他回答

更改pubspec中的name属性。Yaml(第一行)

对于apk的名称,修改AndroidManifest.xml中的android:label

即使我的答案不会被接受为正确答案,我只是觉得所有这些答案导致我有更多的问题,这里是我如何解决它

Get Sublime Text (crazy, right? No, just follow my steps) Click on file and select open folder, then choose the folder of the project you are working on Now click on Find from the Tabs, and select find in files or just do Ctrl + Shift + F (for Windows users, for mac users you already know the drill) Now copy and paste exactly the name of the package you want to change in the Find section and paste in the replace section what you would like to replace the package name with. Click on FIND (do not click on REPLACE just yet). Now clicking on Find lists all available package name in your project which matches your search criteria, if you are satisfied with this then repeat from no. 3 but this time click on REPLACE. Rebuild your project and have fun

结论:一个简单的查找和替换程序就可以解决这个问题,我强烈推荐Sublime Text 3。

Android和Ios的默认路径更改的权利。

为安卓

AndroidManifest.xml开放,

走这条路。

/ src /游戏/应用AndroidManifest . xml

选择软件包名称,然后右键单击,

点击重命名后,重命名弹出(对话框)显示。

在这里输入新的包名,

更改名称文本后,单击重构按钮。

__________________________________________________________________________

为Ios

从抽屉中选择ios文件夹,右键点击这些文件夹,

选择,并双击运行在抽屉,然后选择一般

然后,改变你的包标识符(包名)。 更改包标识符(包名)后,您的包名为 为Ios更改。

在Android系统中,修改应用程序id为

> build.gradle

文件和iOS更改

项目设置中的> bundle名称。

最快和最干净的方法来改变你的包名!

警告:

如果你已经编辑了android/, ios/和windows/文件夹的内容,你需要确保在继续之前在某个地方备份了这些更改。

1. 删除颤振项目根目录下的文件夹:

android / ios / windows / 构建/

假设你想把com.oldcompany.oldproject重命名为com.newcompany.newproject。

2. 从项目的根目录启动以下命令:

flutter create --org com.newcompany --project-name newproject .

PS:为了确保一切都正确设置,您可以通过运行以下命令在文件中搜索您的包名称

grep --color -r com.oldcompany.oldproject *
grep --color -r com.newcompany.newproject *