Flutter修改应用名称和替换图标

  • Flutter修改应用名称和替换图标已关闭评论
  • 445 views
  • A+
所属分类:flutter

Flutter 在新建过程中的 project name 即为默认的应用名称,但是往往不一定最终使用该名称,这里说说怎么修改吧

修改名称

flutter修改ios和Android是分开修改的,

Android修改如下:

找到android->app->src->main->res下AndroidManifest.xml,内容如下:

<application
    android:name="io.flutter.app.FlutterApplication"
    android:label="demo"
    android:icon="@mipmap/ic_launcher">
    <activity
        android:name=".MainActivity"
        android:launchMode="singleTop"
        android:theme="@style/LaunchTheme"
        android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
        android:hardwareAccelerated="true"
        android:windowSoftInputMode="adjustResize">
        <!-- This keeps the window background of the activity showing
             until Flutter renders its first frame. It can be removed if
             there is no splash screen (such as the default splash screen
             defined in @style/LaunchTheme). -->
        <meta-data
            android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
            android:value="true" />
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>
</application>

其中,android:label="demo"这一行,将demo修改成你需要的名字就可以了,例如:支付宝等等

IOS修改如下:

找到ios->Runner下的Info.plist,内容如下:

<dict>
 <key>CFBundleDevelopmentRegion</key>
 <string>$(DEVELOPMENT_LANGUAGE)</string>
 <key>CFBundleExecutable</key>
 <string>$(EXECUTABLE_NAME)</string>
 <key>CFBundleIdentifier</key>
 <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
 <key>CFBundleInfoDictionaryVersion</key>
 <string>6.0</string>
 <key>CFBundleName</key>
 <string>demo</string>
 <key>CFBundlePackageType</key>
 <string>APPL</string>
 <key>CFBundleShortVersionString</key>
 <string>$(FLUTTER_BUILD_NAME)</string>
 <key>CFBundleSignature</key>
 <string>????</string>
 <key>CFBundleVersion</key>
 <string>$(FLUTTER_BUILD_NUMBER)</string>
 <key>LSRequiresIPhoneOS</key>
 <true/>
 <key>UILaunchStoryboardName</key>
 <string>LaunchScreen</string>
 <key>UIMainStoryboardFile</key>
 <string>Main</string>
 <key>UISupportedInterfaceOrientations</key>
 <array>
 <string>UIInterfaceOrientationPortrait</string>
 <string>UIInterfaceOrientationLandscapeLeft</string>
 <string>UIInterfaceOrientationLandscapeRight</string>
 </array>
 <key>UISupportedInterfaceOrientations~ipad</key>
 <array>
 <string>UIInterfaceOrientationPortrait</string>
 <string>UIInterfaceOrientationPortraitUpsideDown</string>
 <string>UIInterfaceOrientationLandscapeLeft</string>
 <string>UIInterfaceOrientationLandscapeRight</string>
 </array>
 <key>UIViewControllerBasedStatusBarAppearance</key>
 <false/>
</dict>

其中<string>demo</string>这一行中demo修改成你需要的名称就ok了。

修改图标

Android修改如下:

找到android->app->src->main->res下mipmap文件夹,将对应得logo放到相应的文件夹,如下图:

Flutter修改应用名称和替换图标

图片文件名跟AndroidManifest.xml中android:icon="@mipmap/ic_launcher">对应起来。

IOS修改如下:

找到ios->Runner->Assets.xcassets->AppIcon.appiconset下,放入对应得图片,然后跟Contents.json中的内容对应即可

  • 安卓客户端下载
  • 微信扫一扫
  • weinxin
  • 微信公众号
  • 微信公众号扫一扫
  • weinxin
avatar