是否有办法更改Flutter项目的Package Name ?
我想在flutter项目中更改包名和应用名。
是否有办法更改Flutter项目的Package Name ?
我想在flutter项目中更改包名和应用名。
当前回答
首先,在终端中运行这个程序 Dart pub全局激活重命名 在Flutter项目根目录中运行此命令 bundleId .company.appname——目标android
这就是所有的东西,现在你改变了你的包名:)
其他回答
您可以通过谷歌:https://developer.android.com/studio/build/application-id.html查看此官方文档
应用程序ID应该在构建中更改。gradle,包名可以在AndroidManifest.xml中修改。
但是,在更改包名时应该谨慎。
另外,在重新上传应用程序时,应该小心,因为它与之前上传的应用程序的ID相匹配。
这是我如何重命名包为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
如果你还没有开始这个项目,这是最好的方法。
flutter create --org com.yourdomain appname
如果您已经创建了该项目,请在dev_dependencies中安装此包并运行此命令。
flutter pub run change_app_package_name:main com.new.package.name
这将改变所有复杂的东西,改变包的名字在android。右键点击flutter的iOS文件夹,用Xcode打开。
在Xcode >中选择Runner >在general选项卡中你可以改变bundle Identifier。
如果您已经创建了一个项目,并且不知道更改包名的复杂性,那么这是最简单的方法。
使用此插件(2022年)
https://pub.dev/packages/change_app_package_name
使用
flutter pub run change_app_package_name:main com.new.package.name
Old Package Name: com.example.oldname
Updating build.gradle File
Updating Main Manifest file
Updating Debug Manifest file
Updating Profile Manifest file
Project is using kotlin
Updating MainActivity.kt
Creating New Directory Structure
Deleting old directories
更改Flutter Project的所有AndroidManifest.xml文件,——> package="your.name.app" (app / src /调试/ AndroidManifest.xml)和 (app/src/main/AndroidManifest.xml)和(app/src/profile/AndroidManifest.xml)
好看!!