Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 263 Vote(s) - 3.46 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to change package name in flutter?

#11
Even if my answer wont be accepted as the correct answer, I just feel all these answers above caused me to have more problems here is how I fixed it

1. Get Sublime Text (crazy, right? No, just follow my steps)
2. Click on file and select open folder, then choose the folder of the project you are working on
3. Now click on Find from the Tabs, and select find in files or just do <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>F</kbd> (for Windows users, for mac users you already know the drill)
4. Now copy and paste exactly the name of the package you want to change in the Find section and paste in the replace section what you would like to replace the package name with.
5. Click on FIND (do not click on REPLACE just yet).
6. Now clicking on Find lists all available package name in your project which matches your search criteria, if you are satisfied with this then repeat from no. 3 but this time click on REPLACE.
7. Rebuild your project and have fun

Conclusion: a simple find and replace program is all you need to sort this problem out, and I strongly recommend Sublime Text 3 for that.
Reply

#12
After trying all of the above. Simple work for me to rename package flutter with
**Android Studio**:

Step 1:

Mac: `Command + Shift + R`

Linux/Windows: `Ctrl + Shift + R`


After change to new package and press `Replace All` and wait **Android Studio** run finish.

[![flutter rename package in Android Studio][2]][2]

Step 2:

Next, go to `AndroidManifest.xml`:

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

and copy `package name` and do the same Step 1 to rename `package` in `AndroidManifest` and `build.gradle`.

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 {
Change the directory name.
For details see the following link [this][1]:

From:

`android\app\src\main\java\com\example\name`

To:

`android\app\src\main\java\your\new_package\name`


[1]:

[To see links please register here]

[2]:
Reply

#13
Change App Package Name with ```single command``` by using following package. It makes the process very easy and fast.

>flutter pub run change_app_package_name:main com.new.package.name

[To see links please register here]

Reply

#14
the right to change path for default way for both Android and Ios.

**for Android**

open AndroidManifest.xml,

- go to this path.

app/src/main/AndroidManifest.xml

- select on package name, and right click,

[![enter image description here][1]][1]

- after click on rename, rename popup(dialog) show.

[![enter image description here][2]][2]

- enter the new package name here,

[![enter image description here][3]][3]

- after changes name text, click on refactor button.

**__________________________________________________________________________**





for **Ios**

- select ios folder from drawer, and right click on these,






[![enter image description here][4]][4]

- select,and double click on Runner in drawer,and then select General






[![enter image description here][5]][5]

- and then, change your Bundle Identifier(Package Name).
- after changes Bundle Identifier(Package Name), Your Package Name is
changed for Ios.

[1]:

[2]:

[3]:

[4]:

[5]:
Reply

#15
If you don’t like changing files in such a way then alternative way would be to use this package.

[To see links please register here]


```
rename --bundleId com.newpackage.appname
pub global run rename --appname "Your New App Name"
```

Using this, you simply run these 2 commands in your terminal and your app name and identifiers will be changed.pub global run
Reply

#16
For those like me that doesn't like to change specific files, I've used

[To see links please register here]

.

Using this, you simply run these commands in your terminal and your app name and identifiers will be changed.pub global run

Installing: `pub global activate rename`

And then, Run this command inside your flutter project root.

`pub global run rename --bundleId com.example.android.app --target android`
Reply

#17
**For Android App Name**

Change the label name in your `AndroidManifest.xml` file:

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

**For Package Name**

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">

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"
}

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 {


Change the directory name:

From:

android\app\src\main\java\com\example\name

To:

android\app\src\main\java\your\package\name


---------------------------------------------
**EDITED : 27-Dec-18**

for **package name** just change in build `build.gradle` only

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


**For iOS**

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

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


**UPDATE**

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
```
Reply

#18
## Change App Package Name easily using `change_app_package_name` package

just add the above package in dev dependencies

dev_dependencies:
flutter_test:
sdk: flutter
change_app_package_name: ^0.1.2

and run the following command, replace "com.new.package.name" with your new package name

flutter pub run change_app_package_name:main com.new.package.name
### [Package Link on Pub Dev][1]
[![screenshot of Package][2]][2]


[1]:

[To see links please register here]

[2]:


Reply

#19
To change **package name** in flutter , you have to do it for **all platforms**.

**To make it easier**, I suggest you to use [**rename**][1] package .

Just run this command inside your flutter project root.

pub global run rename --bundleId com.onat.networkApp



> Here, com.onat.networkApp is your package name

To target a specific platform use the "-t" option.
e.g:

pub global run rename --bundleId com.example.android.app -t android


You can learn more about **rename** package [here][1]


[1]:

[To see links please register here]

Reply

#20
Changing name manually doesn't seem to work, throws gradle errors, well in my case it does throw error.

So I usually create a new flutter project.

I use below mentioned command to create a new flutter app

flutter create --org com.yourdomain appname

your project will have the package name as -> `com.yourdomain.appname`

<hr>


if you just want to keep your package name as `com.appname` then make some changes as below

flutter create --org com appname

to add java instead of `kotlin` for `android` add `-a java`

flutter create -a java --org com.yourdomain appname


<hr>

**EDIT**

<hr>

If you have already created a project you can use [change_app_package_name][1] package to change the package name.

flutter pub run change_app_package_name:main com.package.appname



[1]:

[To see links please register here]

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through