是否有办法更改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

其他回答

这是我如何重命名包为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

使用change_app_package_name Package轻松更改应用程序包名称

只需在开发依赖项中添加上述包

dev_dependencies:
  flutter_test:
    sdk: flutter
  change_app_package_name: ^0.1.2

并运行以下命令,将“com.new.package.name”替换为新的包名

flutter pub run change_app_package_name:main com.new.package.name

包链接在酒吧开发

关于Visual Studio代码

在“文件”中编辑> Replace

Android工作室

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

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

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

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

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

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

我认为这不是解决这个问题的正确办法。但是您可以用您想要的包名创建一个新项目,然后从现有项目中将所有源文件复制到新项目中。

**注意:你也必须复制pubspec的所有内容。在firebase和其他api的情况下,这个解决方案可能有点冗长。