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

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


当前回答

这是我如何重命名包为ios和android

Go to build.gradle in app module and rename applicationId "com.company.name" Go to Manifest.xml in app/src/main and rename package="com.company.name" and android:label="App Name" Go to Manifest.xml in app/src/debug and rename package="com.company.name" Go to Manifest.xml in app/src/profile and rename package="com.company.name" Go to app/src/main/kotlin/com/something/something/MainActivity.kt and rename package="com.company.name" Go to app/src/main/kotlin/ and rename each directory so that the structure looks like app/src/main/kotlin/com/company/name/ Go to pubspec.yaml in your project and change name: something to name: name, example :- if package name is com.abc.xyz the name: xyz Go to each dart file in lib folder and rename the imports to the modified name. Open XCode and open the runner file and click on Runner in project explorer. Go to General -> double click on Bundle Identifier -> rename it to com.company.name Go to Info.plist click on Bundle name -> rename it to your App Name. close everything -> go to your flutter project and run this command in terminal flutter clean

其他回答

您可以通过谷歌:https://developer.android.com/studio/build/application-id.html查看此官方文档

应用程序ID应该在构建中更改。gradle,包名可以在AndroidManifest.xml中修改。

但是,在更改包名时应该谨慎。

另外,在重新上传应用程序时,应该小心,因为它与之前上传的应用程序的ID相匹配。

我有两个manifest.xml文件在我的应用程序部分,所以我需要改变包的名称

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

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

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

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

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

关于Visual Studio代码

在“文件”中编辑> Replace

Android工作室

1. 右键单击您的项目>替换路径

2. 写你的旧包和新包>替换全部

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

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"

最后一步是运行颤振干净