flutter 一键打出不同包名、应用名、版本名、签名、应用图标、版本号的安装包
在Flutter中,可以通过修改项目根目录下的pubspec.yaml
文件和android
和ios
目录下的配置文件来实现不同的包名、应用名、版本名、签名和应用图标、版本号。
以下是一个简化的例子,展示如何在pubspec.yaml
中设置不同的包名和应用名,以及如何在android
和ios
目录中分别设置应用图标和版本信息。
pubspec.yaml
示例:
name: MyApp
description: A new Flutter application.
# The following defines the version and build number for the application.
# The version number comes from the pubspec.yaml file.
version: 1.0.0+1
# The following sets the application identifier (package name).
# This is typically used as an internal name, and must be unique on the store.
# The "com.example" part is a reverse domain name style to help prevent naming conflicts.
# The "my_app" part is the actual name of the app.
# You can change these to your own values.
# 包名
package_name: com.example.myapp
# The following defines the application's name.
# This is the name that users see.
# You can change these to your own values.
# 应用名
app_name: My App
# The following section is for setting up icons and launcher images.
# You can replace these with your own icons and images.
# android和ios目录中会有更详细的设置
# 版本号和版本名
# 这些信息会显示在用户设备上的应用信息中
android/app/build.gradle
示例:
android {
compileSdkVersion 30
defaultConfig {
// 应用ID
applicationId "com.example.myapp"
minSdkVersion 23
targetSdkVersion 30
versionCode 1
versionName "1.0.0"
}
// ...
}
// 签名配置
signingConfigs {
release {
storeFile file('my-release-key.keystore')
storePassword 'password'
keyAlias 'MyReleaseKey'
keyPassword 'password'
}
}
// 应用图标和启动图标配置
android {
// ...
defaultConfig {
// ...
// 应用图标
applicationIcon "app/src/main/res/mipmap-xxhdpi/ic_launcher.png"
}
// ...
}
ios/Runner/Info.plist
示例:
<dict>
<!-- ... -->
<!-- 应用名 -->
<key>CFBundleName</key>
<string>My App</string>
<!-- 应用显示名 -->
<key>CFBundleDisplayName</key>
<string>My App</string>
<!-- 应用图标 -->
<key>CFBundleIconFiles</key>
<array>
<string>Icon-App-76x76@2x.png</string>
<string>Icon-App-120x120@2x.png</string>
<string>Icon-App-152x152@2x.png</string>
<!-- ... -->
</array>
<!-- 版本信息 -->
<key>CFBundleShortVersionString</key>
<string>1.0.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<!-- ... -->
评论已关闭