I have created the app using Flutter create testapp.
Now, I want to change the app name from "testapp" to "My Trips Tracker". How can I do that?
I have tried changing from the AndroidManifest.xml, and it got changed, but is there a way that Flutter provides to do that?
Android
Open AndroidManifest.xml (located at android/app/src/main)
<application
android:label="App Name" ...> // Your app name here
iOS
Open info.plist (located at ios/Runner)
<key>CFBundleDisplayName</key>
<string>App Name</string> // Your app name here
and/or
Don't forget to stop and run the app again.
UPDATE: From the comments this answer seems to be out of date
The Flutter documentation points out where you can change the display name of your application for both Android and iOS. This may be what you are looking for:
Preparing an Android App for Release
Preparing an iOS App for Release
For Android
It seems you have already found this in the AndroidManifest.xml as the application entry.
Review the default App Manifest file AndroidManifest.xml located in
/android/app/src/main/ and verify the values are correct,
especially:
application: Edit the android:label in the application tag to reflect the final name of the
app.
For iOS
See the Review Xcode project settings section:
Navigate to your target’s settings in Xcode:
In Xcode, open Runner.xcworkspace in your app’s ios folder.
To view your app’s settings, select the Runner project in the Xcode project
navigator. Then, in the main view sidebar, select the Runner target.
Select the General tab. Next, you’ll verify the most important
settings:
Display Name: the name of the app to be displayed on the home screen
and elsewhere.
There is a plugin called flutter_launcher_name.
Write file pubspec.yaml:
dev_dependencies:
flutter_launcher_name: "^0.0.1"
flutter_launcher_name:
name: "yourNewAppLauncherName"
And run:
flutter pub get
flutter pub run flutter_launcher_name:main
You can get the same result as editing AndroidManifest.xml and Info.plist.
You can change it in iOS without opening Xcode by editing the project/ios/Runner/info.plist <key>CFBundleDisplayName</key> to the String that you want as your name.
FWIW - I was getting frustrated with making changes in Xcode and Flutter, so I started committing all changes before opening Xcode, so I could see where the changes show up in the Flutter project.
Review the default app manifest file, AndroidManifest.xml, located in <app dir>/android/app/src/main
Edit the android:label to your desired display name
There are several possibilities:
1- The use of a package:
I suggest you to use flutter_launcher_name because of the command-line tool which simplifies the task of updating your Flutter app's launcher name.
Usage:
Add your Flutter Launcher name configuration to your pubspec.yaml file:
dev_dependencies:
flutter_launcher_name: "^0.0.1"
flutter_launcher_name:
name: "yourNewAppLauncherName"
After setting up the configuration, all that is left to do is run the package.
flutter pub get
flutter pub run flutter_launcher_name:main
If you use this package, you don't need modify file AndroidManifest.xml or Info.plist.
2- Edit AndroidManifest.xml for Android and info.plist for iOS
For Android, edit only android:label value in the application tag in file AndroidManifest.xml located in the folder: android/app/src/main
Code:
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:name="io.flutter.app.FlutterApplication"
android:label="Your Application Name" //here
android:icon="#mipmap/ic_launcher">
<activity>
<!-- -->
</activity>
</application>
</manifest>
Screenshot:
For iOS, edit only the value inside the String tag in file Info.plist located in the folder ios/Runner .
Code:
<plist version="1.0">
<dict>
<key>CFBundleName</key>
<string>Your Application Name </string> //here
</dict>
</plist>
Screenshot:
Do a flutter clean and restart your application if you have a problem.
A few of the answers here suggest using the package flutter_launcher_name, but this package is no longer being maintained and will result in dependency issues within new Flutter 2.0 projects.
The plugin flutter_app_name (https://pub.dev/packages/flutter_app_name) is a nearly identical package that has sound null safety and will work with Flutter 2.0.
Set your dev dependencies and your app's name
dev_dependencies:
flutter_app_name: ^0.1.1
flutter_app_name:
name: "My Cool App"
Run flutter_app_name in your project's directory
flutter pub get
flutter pub run flutter_app_name
Your launcher will now have the name of "My Cool App".
You can change it in iOS without opening Xcode by editing file *project/ios/Runner/info.plist. Set <key>CFBundleDisplayName</key> to the string that you want as your name.
For Android, change the app name from the Android folder, in the AndroidManifest.xml file, android/app/src/main. Let the android label refer to the name you prefer, for example,
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
<application
android:label="test"
// The rest of the code
</application>
</manifest>
You can change the Application name, by updating the name for both Android and iOS
for Android
just open AndroidManifest.xml file by,
go to inside android>app>src>main>AndroidManifest.xml
like this:-
so my application name is a "demo" so, I will update the label value.
same as for iOS
just open Info.plist file by,
go to inside ios>Runner>Info.plist
like this:-
And change this string value.
One problem is that in iOS Settings (iOS 12.x) if you change the Display Name, it leaves the app name and icon in iOS Settings as the old version.
For Android, change the app name from the Android folder. In the AndroidManifest.xml file, in folder android/app/src/main, let the android label refer to the name you prefer, for example,
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
<application
`android:label="myappname"`
// The rest of the code
</application>
</manifest>
You can easily do this with rename package, It helps you to change your Flutter project's AppName and BundleId for different platforms, currently available for IOS, Android, macOS and Web
To install the package run the following command:
pub global activate rename
To rename the App, use the following command:
pub global run rename --appname "Your App Name"
That's It!
You can check the documentation of the package for full details because it has some nice features to choose the target platform and more.
As of 2019-12-21, you need to change the name [NameOfYourApp] in file pubspec.yaml. Then go to menu Edit → Find → Replace in Path, and replace all occurrences of your previous name.
Also, just for good measure, change the folder names in your android directory, e.g. android/app/src/main/java/com/example/yourappname.
Then in the console, in your app's root directory, run
flutter clean
in case you are releasing for multi-localizations (languages).
for Android:
in your app folder at
[appname]\android\app\src\main\res
add locale folders for example:
values-ar
valuse-en
then inside each folder add a new strings.xml that contains the app name in that language.
for ar
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<string name="app_name">ادارة الديون</string>
</resources>
for en
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<string name="app_name">debt management</string>
</resources>
The last thing you can do is go to your AndroidManifest.xml file
and set the android:label to the new files you have created.
android:label="#string/app_name"
I saw indeed the manual solution (to go to IOS and Android). But I found out a plugin which enables changing name from one single location:
https://pub.dev/packages/flutter_launcher_name
Just do the following:
Add to pubspec.yaml
dev_dependencies:
flutter_launcher_name: "^0.0.1"
flutter_launcher_name:
name: "yourNewAppLauncherName"
Run in Terminal:
flutter pub get
flutter pub run flutter_launcher_name:main
Done.
First
Rename your AndroidManifest.xml file
android:label="Your App Name"
Second
Rename Your Application Name in Pubspec.yaml file
name: Your Application Name
Third
Change Your Application logo
flutter_icons:
android: "launcher_icon"
ios: true
image_path: "assets/path/your Application logo.formate"
Fourth
Run
flutter pub pub run flutter_launcher_icons:main
If you like to automate stuff from command line like me, you can use this
appName="TestApp"
declare -a androidAppTypes=(
"main"
"debug"
"profile"
)
# Change app name for Android
for appType in ${androidAppTypes[#]}
do
xmlstarlet ed -L -u '/manifest/application/#android:label' -v "$appName" android/app/src/$appType/AndroidManifest.xml
done
# Change app name for Android
plutil -replace CFBundleDisplayName -string "$appName" ios/Runner/Info.plist
The way of changing the name for iOS and Android is clearly mentioned in the documentation as follows:
Build and release an Android app
Build and release an iOS app
But, the case of iOS after you change the Display Name from Xcode, you are not able to run the application in the Flutter way, like flutter run.
Because the Flutter run expects the app name as Runner. Even if you change the name in Xcode, it doesn't work.
So, I fixed this as follows:
Move to the location on your Flutter project, ios/Runner.xcodeproj/project.pbxproj, and find and replace all instances of your new name with Runner.
Then everything should work in the flutter run way.
But don't forget to change the name display name on your next release time. Otherwise, the App Store rejects your name.
I have a Parse account that I'm using to store user data for my Android application. Because I'm using source control, I don't want to leave my secret key embedded in the code. Is there a way to have a "config" file that I would keep out of source control, that can then host the key? If that's not feasible, what are the best practices of handling such a situation?
Yes, you can create a folder outside of source control, put a file called app.properties in there, put your key in that properties file and add the folder to your build path. Then use a properties loader to load it from the classpath.
If you have many developers or more than one dev machine, you can set the local properties location as a variable in your build path so that each developer can configure their own.
One option is to put the key in an environment variable and then read it during your build.
in your pom.xml declare a property (secret.key)
<properties>
<secretKey>${env.SECRET_KEY}</secretKey>
<properties>
further down enable "filtering" on your resources
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
In resources maintain a "config.properties" to read with the variable ready for substitution:
secret_key=${secretKey}
Filtering in maven will replace ${secret.key} with the value from your environment variable.
If you are using gradle for your build with Android studio see section 16.6.6.2 on filtering files.
Within build.gradle add the following
import org.apache.tools.ant.filters.FixCrLfFilter
import org.apache.tools.ant.filters.ReplaceTokens
task copyProductionConfig(type: Copy) {
from 'source'
include 'config.properties'
into 'build/targetpath/config'
expand([
secretKey: System.getenv("SECRET_KEY")
])
}
In gradle you can also request input when you run gradlew using
Console console = System.console()
def password = console.readPassword("Enter Secret Key: ")
And then apply it to the appropriate config or source files.
We have a unique situation where we are deploying a Xamarin.Android app to China to 33 app stores. Hence, our solution has 33 application projects, and we setup Jenkins (running on Windows) to package and sign all our apks (otherwise it would be crazy to make builds).
We also need to modify android:versionCode and android:versionName in the manifest file, by using the ${SVN_REVISION} value from Jenkins. Is there a way to pass these values command line to MSBuild?
Normally we would hand edit this value, but it's not possible because of so many application projects.
Our build parameters right now look like this in Jenkins:
/p:Configuration=Release;AndroidKeyStore=True;AndroidSigningKeyStore=ourkeystore.keystore;AndroidSigningStorePass=ourpassword;AndroidSigningKeyAlias=ouralias;AndroidSigningKeyPass=ourpassword /t:SignAndroidPackage
Add this to the end of your *.csproj file, before the ending </Project> tag:
<Target Name="BeforeBuild" Condition=" '$(JENKINS)' == '1' ">
<XmlPoke XmlInputPath="Properties\AndroidManifest.xml" Namespaces="<Namespace Prefix='android' Uri='http://schemas.android.com/apk/res/android' />" Query="manifest/#android:versionCode" Value="$(SVN_REVISION)" />
<XmlPoke XmlInputPath="Properties\AndroidManifest.xml" Namespaces="<Namespace Prefix='android' Uri='http://schemas.android.com/apk/res/android' />" Query="manifest/#android:versionName" Value="2.0.$(SVN_REVISION)" />
</Target>
I have Jenkins configured to pass JENKINS=1 and SVN_REVISION. When it goes to build, it modifies AndroidManifest.xml before the build.
I don't know if this will work on xbuild on a Mac or not, depends on if XmlPoke is implemented. I should do a blog post on this.
No. You'll have to manipulate the android:versionCode and android:versionName yourself. Personally, I use a rake task to handle this particular detail.
My application uses a large number of MapView screens and I'm trying to figure out how to manage the API key between the debug environment and production. Apparently, there is no way to change the debug application key in Eclipse so I must use a debug map API key in that environment. Conversely, there is no way to export a package for beta testing without a production application key so I must change the map API key in every view in order to create a working package.
My first idea was to do this:
All MapView.xml files have this:
android:apiKey="#string/googleMapsAPIKey"
And then in strings.xml I put this:
<string name="googleMapsPIKey">#string/debugGoogleMapsAPIKey</string>
<string name="debugGoogleMapsAPIKey">TheMagicKeyString</string>
If this worked, it would allow me to change a single line in strings.xml and all the MapViews would get updated in the rebuild. But it didn't work. I guess strings.xml can't make references into itself. Any other ideas?
Thanks
I recommend a simpler approach that involves taking advantage of an unlikely, but more specific asset folder to house your debug key. To set this up, create a file res/values/maps-apikey.xml with the following contents:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="maps_apikey">[productionApiKey]</string>
</resources>
Then each developer locally will add a file derived from this one in res/values-v1/maps-apikey.xml where their debug API key is provided. At runtime, the Android system will favor the more specific version res/values-v1/maps-apikey.xml for all versions of Android (since all are at least on API level 1 or higher).
Source control systems like git and svn allow you to add an "ignore" file which directs the tools to ignore this res/values-v1/maps-apikey.xml file so that each developer does not accidentally commit it to the repository. To do this for git, simply add a file res/.gitignore which contains only the line values-v1 then commit this file.
To release your software, simply delete the res/values-v1/maps-apikey.xml file before exporting a release. The resulting APK will then reference the version in res/values/maps-apikey.xml which is your correct production key.
you are doing the right thing but not the right way I think. Declare your string in strings.xml like this :
<string name="googleMapsAPIKey">TheMagicKeyString</string>
<!-- You can add this at the end as comment to keep a copy of another key for instance, to exchange it between debug and production-->
Note that you didn't give the same name at your 2 strings... One is called debug and not the other.
I'm using maven and the maven-android-plugin, with a res-overlay directory that is only used in the release configuration.
Consequently, I have a res/values/google_api_key.xml file containing the debug key and a res-overlay-production/values/google_api_key.xml file containing the production key, and the latter overrides the former in the production release.
I'm also using Eclipse ADT, but this doesn't know about the release configuration, so it's happy to see the debug key and I can use the Android XML editors to set up my map views.
I'm using maven-android-plugin and I'm using a sneaky token replacement mechanism to do this.
I'm using the "morseflash" sample, and added this to the maven-resources plugin configuration:
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>resources</goal>
</goals>
</execution>
</executions>
<configuration>
<delimiters>
<delimiter>${*}</delimiter>
<delimiter>>08*<</delimiter>
</delimiters>
</configuration>
</plugin>
The resources plugin allows you to define weird delimiters for search/replace. The default delimiter is ${*}, but I added >*< so it would match XML element content. (Actually I used >08*<; I'll explain why in a moment.)
Then, in my strings.xml, I wrote this:
<string name="googleMapsAPIKey">08DEBUGKEYABCDEFBLAHBLAHBLAH</string>
And defined a Maven property in the release profile, like this:
<profile>
<id>release</id>
<!-- via this activation the profile is automatically used when the release is done with the maven release
plugin -->
<activation>
<property>
<name>performRelease</name>
<value>true</value>
</property>
</activation>
<properties>
<DEBUGKEYABCDEFBLAHBLAHBLAH>>08RELEASEKEYABCDEFBLAHBLAHBLAH<</DEBUGKEYABCDEFBLAHBLAHBLAH>
</properties>
<-- ... -->
</profile>
That creates a Maven property named after the debug Maps key, whose value is the release debug key.
Unfortunately, Maven properties are not allowed to start with numbers. My debug key and my release key both started with 08Wfj... So I used the delimiter >08*< and made sure to include >08 in my replacement string.
I think this is a good way to do it! With Sephy's correction it should work perfectly.
On top of that, if you want to switch keys automatically between the debug & release builds, you can have a look at this post I just wrote: http://blog.cuttleworks.com/2011/02/android-dev-prod-builds/. It helped me stop worrying about configuration when building for different environments.
Try something like this:
String debugMapKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
String releaseMapKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
String mapKey = BuildConfig.DEBUG ? debugMapKey : releaseMapKey;
MapView mv = new MapView(this, mapKey);
You can set custom debug keystore in Prefs window -> Android->Build.
In the google developer console you can create one key for multiple sha1 codes
https://stackoverflow.com/a/13881624/1433372
i'm trying to get android running on a gumstix overo system.
since i'm not planning to use the final "product" as a phone, i asked my self if it is possible to exclude applications like the phone/dialer-app from the kernel build-process (any config parameter probably?)
Just remove (or comment) these lines:
<project path="packages/apps/Phone" name="platform/packages/apps/Phone" />
<project path="packages/apps/VoiceDialer" name="platform/packages/apps/VoiceDialer" />
(and others if needed) from the platform manifest (default.xml) :
https://android.googlesource.com/platform/manifest/+/master/default.xml
Removing the app declarations in the repo manifest did not work for me, as there are other libraries that reference them that then fail to compile. The build system approach to this problem is to create/modify your product definition makefile to not include the specific apps.
So, for the overo you probably already have a products/overo.mk product file. You can manually set the PRODUCT_PACKAGES variable to which applications you want to ship. You will also want to take a look at the PRODUCT_POLICY variable, as it defines sets of applications for your product type.
It can take some fiddling to get everything to build correctly, due to interdependencies between applications, but the Android build output does a pretty good job of explaining the problems when they arise.