How to change Android application name in Xamarin.Forms?
Asked Answered
S

4

31

I am working with Xamarin.Forms in Visual Studio For Mac and I have created a very basic Xamarin.Forms application.

I have checked Android and iOS targets. I got 3 projects:

  • A common project
  • An iOS specific project
  • And a Droid specific project.

The Android specific application has a ".Droid" suffix in application name.

So I decided to right click on droid project, and to remove this suffix in "Assembly name" field.

I got an exception where I run the app (at startup). If I change Assembly name again to put the droid suffix, it does not work anymore.

You can try this with a blank project with the latest version of Xamarin.Forms.

I do not understand why?

Shinberg answered 18/6, 2017 at 10:19 Comment(0)
T
78

The problem is that you are changing the assembly name of your application, not the name.

If you want to change the application name in Xamarin.Forms Android you have two options:

  • Go to your MainActivity and change the Label property:

enter image description here

  • Or remove the Label of the MainActivity and add the name in the Manifest.xml via UI or code:

enter image description here enter image description here


On iOS you must change it in Info.plist.

enter image description here

Thermobarometer answered 18/6, 2017 at 10:24 Comment(5)
I have only "myappname" in Manifest.xml. i do not understand why i see a ".Droid" suffix under the icon app...Shinberg
In fact I have this problem with blank forms app project template. I work with xamarin for macShinberg
Visual studio for macShinberg
Please clear old comments so we don't have a lot of text here. Its better for future users. I've updated my answer, please read it.Thermobarometer
Footnote: If you have a splash activity seems you need to change the [Activity(label = "Your new App Name".... as well, hope this helps.Bora
W
15

Other answer works fine. But I am adding more details .

Application name is picked from AndroidManifest.xml file i.e. <application android:label=@string/app_name , which in turn refers to values>strings.xml file . Do not hard code app name here. Its good practice separate all strings used in strings.xml file.

App name image

strings.xml

<resources>
  <string name="app_name">App Name</string>
</resources>

Label property overrides this and sets the app title , apk name to Label value set inside MainActivity.

Its preferable to delete Label value from MainActivity.cs's assembly directive [Activity (as it overrides this manifest value at debug time) change the value in strings.xml so that its global and consistent.

Image 2

Winton answered 5/12, 2017 at 22:39 Comment(0)
J
2

For android make the change in android folder, mainactivity.cs

[Activity(Label = "Myappname", Icon = "@mipmap/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]

Fos iOS make the following in change in the info.plist

Bundle display name to Myappname

Janiculum answered 12/8, 2020 at 5:52 Comment(0)
N
1
   //Change the Xamarin Forms Android Application Name

   [Activity(Label = "ApplicationName", Icon = "@mipmap/icon", Theme = 
   "@style/splashscreen", LaunchMode = LaunchMode.SingleTop, MainLauncher = true, 
    ScreenOrientation = ScreenOrientation.Portrait,ConfigurationChanges = 
    ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | 
   ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize )]



  //In IOS , we can change the name of Application in info.plist
                 
                 Double click in info.plist , change Application Name
Neither answered 31/5, 2022 at 13:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.