我已经使用Flutter create testapp创建了应用程序。 现在,我想将应用程序名称从“testapp”更改为“My Trips Tracker”。我该怎么做呢?
我已经尝试从AndroidManifest.xml进行更改,它已经更改,但是Flutter提供了一种方法来做到这一点吗?
我已经使用Flutter create testapp创建了应用程序。 现在,我想将应用程序名称从“testapp”更改为“My Trips Tracker”。我该怎么做呢?
我已经尝试从AndroidManifest.xml进行更改,它已经更改,但是Flutter提供了一种方法来做到这一点吗?
当前回答
第一个 重命名AndroidManifest.xml文件
android:label="Your App Name"
第二个 在Pubspec中重命名应用程序名称。yaml文件 名称:您的应用程序名称
第三 更改应用程序标志
flutter_icons:
android: "launcher_icon"
ios: true
image_path: "assets/path/your Application logo.formate"
第四 运行
flutter pub pub run flutter_launcher_icons:main
其他回答
查看默认的应用清单文件AndroidManifest.xml,位于<app dir>/android/app/src/main 编辑android:标签为您想要的显示名称
你可以通过编辑文件*project/ iOS /Runner/info.plist在iOS中修改它,而不需要打开Xcode。设置<key>CFBundleDisplayName</key>为你想要作为你的名字的字符串。
对于Android,在AndroidManifest.xml文件中的Android文件夹中更改应用程序名称,Android /app/src/main。让android标签引用你喜欢的名称,例如,
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
<application
android:label="test"
// The rest of the code
</application>
</manifest>
自2019年12月21日起,您需要更改pubspec.yaml文件中的名称[NameOfYourApp]。然后转到“路径”中的“编辑→查找→替换”菜单,替换之前出现的所有名字。
另外,为了更好地衡量,更改android目录下的文件夹名称,例如android/app/src/main/java/com/example/yourappname。
然后在控制台中,在应用程序的根目录中运行
flutter clean
如果你像我一样喜欢从命令行自动化一些东西,你可以使用这个
appName="TestApp"
declare -a androidAppTypes=(
"main"
"debug"
"profile"
)
# Change app name for Android
for appType in ${androidAppTypes[@]}
do
xmlstarlet ed -L -u '/manifest/application/@android:label' -v "$appName" android/app/src/$appType/AndroidManifest.xml
done
# Change app name for Android
plutil -replace CFBundleDisplayName -string "$appName" ios/Runner/Info.plist
一个问题是,在iOS设置(iOS 12.x)中,如果你改变了显示名称,它会让iOS设置中的应用程序名称和图标保持旧版本。