是否有办法更改Flutter项目的Package Name ?
我想在flutter项目中更改包名和应用名。
是否有办法更改Flutter项目的Package Name ?
我想在flutter项目中更改包名和应用名。
当前回答
对于像我这样不喜欢更改特定文件的人,我使用了https://pub.dev/packages/rename。
使用这个,你只需要在你的终端上运行这些命令,你的应用名称和标识符就会被改变。酒吧全球运营
正在安装:pub全局激活重命名
然后,在颤振项目根目录中运行此命令。
pub全局运行rename——bundleId com.example.android.app——目标android
其他回答
在Android系统中,修改应用程序id为
> build.gradle
文件和iOS更改
项目设置中的> bundle名称。
在Vs Code,我所做的是搜索和替换它,它工作!就像一个符咒。
com.example.appName
重新启动vs代码。
手动更改名称似乎不起作用,抛出gradle错误,在我的情况下,它确实抛出错误。
所以我通常会创建一个新的颤振项目
我使用下面提到的命令创建一个新的扑动应用程序
flutter create --org com.yourdomain appname
您的项目的包名将是-> com.yourdomain.appname
如果你只是想保持你的包名称为com。然后对Appname进行如下更改
flutter create --org com appname
为android添加Java而不是kotlin添加-a Java
flutter create -a java --org com.yourdomain appname
EDIT
如果您已经创建了一个项目,您可以使用change_app_package_name包来更改包的名称。
flutter pub run change_app_package_name:main com.package.appname
即使我的答案不会被接受为正确答案,我只是觉得所有这些答案导致我有更多的问题,这里是我如何解决它
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。
若要在flutter中更改包名,必须对所有平台执行此操作。
为了使它更容易,我建议您使用重命名包。
只需在flutter项目根目录中运行此命令。
pub global run rename --bundleId com.onat.networkApp
这里,com.onat.networkApp是包名
要瞄准特定的平台,请使用“-t”选项。 例句:
pub global run rename --bundleId com.example.android.app -t android
您可以在这里了解有关重命名包的更多信息