是否有办法更改Flutter项目的Package Name ?
我想在flutter项目中更改包名和应用名。
是否有办法更改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
其他回答
即使我的答案不会被接受为正确答案,我只是觉得所有这些答案导致我有更多的问题,这里是我如何解决它
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。
首先,在终端中运行这个程序 Dart pub全局激活重命名 在Flutter项目根目录中运行此命令 bundleId .company.appname——目标android
这就是所有的东西,现在你改变了你的包名:)
根据官方的flutter文档,您只需要在app/build中更改ApplicationId。gradle目录。然后你只需要构建你的apk, manifest文件的包名将根据你在build.gradle中更改的ApplicationId进行更改。由于在构建apk和谷歌播放时的颤扑,都考虑从build.gradle中的ApplicationId。这个解决方案对我很有效。
来源:官方文件
若要在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
您可以在这里了解有关重命名包的更多信息
使用以下包,用单一命令更改应用程序包名称。它使这个过程非常简单和快速。
颤振pub运行change_app_package_name:main com.new.package.name
https://pub.dev/packages/change_app_package_name