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

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


当前回答

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

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。

其他回答

我已经对现有的包名进行了全局搜索,并使用新的包名更改了所有字段。然后改变

应用程序- > src - - > >主要yourOldFolderName

按新包名命名的文件夹名。之后,将所有导入的包名更改为新的包名。这需要大量的手工工作,但这是值得的,没有任何问题。

注意:注意包名前的空格,它可能会给出内置错误

捷径:

全局搜索- ctrl+shift+f

更换包装

文件搜索- ctrl+f

修改导入包名称

如果你不喜欢以这种方式改变文件,那么另一种方式是使用这个包。

https://pub.dev/packages/rename

rename --bundleId com.newpackage.appname
pub global run rename --appname "Your New App Name"

使用这个,你只需要在你的终端上运行这两个命令,你的应用名称和标识符就会被改变。酒吧全球运营

更新您必须将包名更改为所需的包名 五个位置。

1.) src/profile/AndroidManifest.xml
2.) src/debug/AndroidManifest.xml
3.) src/main/AdroidManifest.xml
4.) app/build.gradle
     build.gradle .
       defaultConfig {
           applicationId
       }
5.) MainActivity.java or MainActivity.kt on "package"

最后一步是运行颤振干净

对于像我这样不喜欢更改特定文件的人,我使用了https://pub.dev/packages/rename。

使用这个,你只需要在你的终端上运行这些命令,你的应用名称和标识符就会被改变。酒吧全球运营

正在安装:pub全局激活重命名

然后,在颤振项目根目录中运行此命令。

pub全局运行rename——bundleId com.example.android.app——目标android

更改Flutter Project的所有AndroidManifest.xml文件,——> package="your.name.app" (app / src /调试/ AndroidManifest.xml)和 (app/src/main/AndroidManifest.xml)和(app/src/profile/AndroidManifest.xml)

好看!!