如何在颤振中更改包名称?
有什么办法可以修改 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