Am trying to release my apk and just changed the com.example package name to my own com.[companynamehere].[appname] in the AndroidManifest.xml file and app/build.gradle file, however now my app stops working as soon as I run it.
Any idea what might be the problem? Is there anywhere else I need to change the package name?
I'm also using firebase and I generated a new google-services.json file with the new package name.
Update your package name in android>src>main>kotlin>Mainactivity.kt
Hope it will work. If it doesn't work then another solution is to search your old package name on the entire project and replace them with the new package name. In this case, VSCode will help you to do this just with a few clicks.
I have two version of an app that I want to run on the same phone.
I have changed my config.xml widget id and name, I have change package.json and ionic.config.json and I have changed manifest.json all to have a different name for the app, but still I get this error “Package conflicts with an existing package”
Is it possible changing the project name of a Flutter project? With project name I mean the name you provide when creating a flutter project flutter create name.
That depends on what you are trying to achieve. If you want to change the name of the app which is displayed in the mobile phones menu together with the app icon, you have to change the android:label in the android/app/src/main/AndroidManifest.xml (Code Sample 1) and the CFBundleName in the ios/Runner/Info.plist (Code Sample 2).
Last time I did this it took me ages to find out, why the name of the app was not changed in the list of currently running apps on Android. For that you also need to change the title of your MaterialApp (Code Sample 3).
For renaming it everywhere I would suggest to use search and replace in the project. If you do this, you have to choose a name without spaces or special characters. A project name 'new project' in the pubspec.yaml for example will break the build.
Code Sample 1:
<application
android:name="io.flutter.app.FlutterApplication"
android:label="New Name"
android:icon="#mipmap/ic_launcher">
Code Sample 2:
<key>CFBundleName</key>
<string>New Name</string>
Code Sample 3:
return new MaterialApp(
title: 'New Name'
...);
To change project name , you need to change it for all platforms .
You can use rename package to make it easy .
Run this command inside your flutter project root
flutter pub global run rename --appname "Application Name"
You can also specify the platform you want to apply the change
flutter pub global run rename --appname yourappname -t macOS // support also ios and android
or
Edit AndroidManifest.xml for Android and info.plist for iOS
Do a flutter clean and restart your application if you have a problem.
You can let flutter do this for you:
Using Terminal:
cd /path/to/existing/flutter_project
flutter create --project-name newprojname --org com.yourorgdomain .
Next change the name on line 1 of pubspec.yaml
Trash all generated folders to remove all references of the old project name.
NB - Some import statements will need to have their package references
updated manually to the new name. Review the project structure (in
your IDE) for any references to the old project name inside of IDE
generated files.
Recreate the trashed generated files by using flutter create . (including the space and period at the end) from within the project folder.
Now run flutter clean then debug as normal
Gotchas
You should expect that the project name still resides in all the generated folders for the various environments and in comments/strings. You can use a tool to search all files in the project or folder structure (e.g Cmd + Shift + F in Android Studio or ag {the_silver_searcher in Homebrew}) to find the old name and trash any generated folders including ios, windows, linux. After trashing the generated folders remember to re-create them by running flutter create .
To add to Rainer's answer, you may also have to change the com.example.myprojectname file under android/app/build.gradle
Also for the com.example.myprojectname, do not use underscores (ie:
com.example.my_project_name)
You may also have to find and replace the com.example.myproject name in the files project.pbxproj and MainActivity.java.
If you want to change the project name, simply change it in all these files.
build.gradle (app)
AndroidManifest.xml
MainActivity.java
Rebuild your app and you should be good to go.
1-flutter clean
2- Search and replace all OLD_PROJECT_NAME with NEW_PROJECT_NAME
3- Search for OLD_PROJECT_NAME in the project folder, and replace them with NEW_PROJECT_NAME one by one. Some of them are in the text files, make sure that you have changed them too.
If you are using Android Studio, follow these steps:
Right-click your project in the Project window (Alt+1 to show).
Click Refactor > Rename.
Enter new name.
This will rename the project's name on all required places except in the test directory.
Steps to rename your project: (For Editors that has search & replace across project feature)
Use VSCode's any other editor's search and replaceAll across entire project feature. But always turn on the match cases (for vscode: located on right side).
You have to do this two time as for the first you have to replace com.orgname.currentname with com.orgname.newname then
currentname with newname.
Rename the folders inside /android/app/src/main/kotlin/com/orgname/currentname to new /android/app/src/main/kotlin/com/orgname/newname.
If you're using only Java with flutter than just replace the kotlin with java.
rename the currentname.iml of your root project folder to newname.iml
Ctrl+Shift+R then Replace for one by one replace
or Replace All for all at a time. Be cautious , if your project name is similar with other variable or class name then don't do that. Before doing that check twice.
If you are using Android Studio, from the Menu > Edit > Find > Replace in files > Enter old and new name...
If you want to change the project name, simply change it in all these files.
build.gradle (app)
AndroidManifest.xml
MainActivity.java
Rebuild your app and you should be good to go.
I have followed this tutorial to enable push notification on android runtime but
I am getting failure 830 android/android.cfg: unknown asset error when i try to deploy bar package into alpa device.
What can be the reason of that?
The solution is to change the way of importing android.cfg file into the android project.
First of all,
add android.cfg file into root of the android project folder and
rename it as projectname.cfg. For example, if the application name
is SamplePushApp, the name of your cfg file must be SamplePushApp.cfg.
Secondly, sign your application using eclipse bar signer.
After that, check out if the android.cfg file is created under bar
file.
I am trying to create a LITE version of my iPhone app by using different targets. So I have duplicated the release target 'Checklists' and it will name it 'Checklists copy'. I have managed to change the name of the actual .app that is created but not the target name. Any ideas?
So the .app is named via the product name. The target name is an identifier for the build settings, which are actually built using a scheme. The name you see when selecting what to build is a scheme, and you can rename those by clicking on the bar and going to "manage schemes".
To rename the target you just click on the name and it will turn into an edit box.