如何在颤振中更改包名称? [英] How to change package name in flutter?

查看:27
本文介绍了如何在颤振中更改包名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么办法可以修改 Flutter 项目的包名吗?

Is there any way to change Package Name of Flutter project?

我想在flutter项目中修改包名和应用名.

I want to change package name and application name in flutter project.

推荐答案

For Android App Name

在您的 AndroidManifest.xml 文件中更改标签名称:

Change the label name in your AndroidManifest.xml file:

 <application
    android:name="io.flutter.app.FlutterApplication"
    android:label="TheNameOfYourApp"   

对于包名

在你的 AndroidManifest.xml 文件中更改包名(在其中 3 个文件夹中:main、debug 和 profile,根据你要部署的环境)文件:

Change the package name in your AndroidManifest.xml (in 3 of them, folders: main, debug and profile, according what environment you want to deploy) file:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="your.package.name">

也在你的 build.gradle 文件中的 app 文件夹中

Also in your build.gradle file inside app folder

defaultConfig {
    applicationId "your.package.name"
    minSdkVersion 16
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

最后,在你的MainActivity.java类中更改包(如果MainActivity.java不可用,检查MainActivity.kt)

Finally, change the package in your MainActivity.java class (if the MainActivity.java is not available, check the MainActivity.kt)

    package your.package.name;

    import android.os.Bundle;
    import io.flutter.app.FlutterActivity;
    import io.flutter.plugins.GeneratedPluginRegistrant;
    public class MainActivity extends FlutterActivity {

更改目录名称:

来自:

  androidappsrcmainjavacomexample
ame

致:

  androidappsrcmainjavayourpackage
ame
  


18 年 12 月 27 日

对于包名只需在构建build.gradle中更改

defaultConfig {
    applicationId "your.package.name"
    minSdkVersion 16
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

iOS

ios/Runner 目录中的 Info.plist 文件更改包标识符.

Change the bundle identifier from your Info.plist file inside your ios/Runner directory.

<key>CFBundleIdentifier</key>
<string>com.your.packagename</string>

更新

为了避免重命名包和包标识符,您可以在终端中使用以下命令启动您的项目:

To avoid renaming the package and bundle identifier, you can start your project using this command in your terminal:

flutter create --org com.yourdomain appname

这篇关于如何在颤振中更改包名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆