问题描述
是否可以更改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.
推荐答案
对于Android应用名称
更改AndroidManifest.xml
文件中的标签名称:
Change the label name in your AndroidManifest.xml
file:
<application
android:name="io.flutter.app.FlutterApplication"
android:label="TheNameOfYourApp"
用于程序包名称
更改您的AndroidManifest.xml
文件中的软件包名称:
Change the package name in your AndroidManifest.xml
file:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="your.package.name">
也位于应用程序文件夹中的build.gradle
文件中
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 {
更改目录名称:
发件人:
android\app\src\main\java\com\example\name
收件人:
android\app\src\main\java\your\package\name
已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
这篇关于如何在flutter中更改包名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!