Renaming .Android project to .Droid in VS 2017

System.AshSystem.Ash Ash NarayanAUMember ✭✭

Ok so a lot of online guides/videos I've come across seem to end up with a .Droid project when they create a new Xamarin cross platform solution in VS. Something to do with namespace clashes if you use .Android. When I create such a solution, I end up with a .Android project.

I've tried to manually change the project name using this method: Proper way to rename solution (and directories) in Visual Studio. But it doesn't work (see my comment to the accepted answer).

I've also tried this: How do I rename a Project Folder from within Visual Studio?. Same problem.

The problem seems to be that these methods only seem to change a folder name. The names of the files within these folders and the names of files/folders they themselves reference internally, still remain unchanged, causing havoc.

So, question...

1) Is there a default I can set in VS2017, so that I always end up with a .Droid project instead of a .Android?

If not,

2) What are the steps I need to take to make this change manually? This would need to guarantee me that every filename within the Android project changes accordingly as well. For eg, MyApp.Android.csproj would need to be changed to MyApp.Droid.csproj, and all references to MyApp.Android within files (such as AndroidManifest.xml and AssemblyInfo.cs) would need to be changed as well. Basically anything MyApp.Android would now need to say MyApp.Droid.

Best Answers

Answers

  • prashantvcprashantvc Prashant Cholachagudda USXamarin Team Xamurai
    edited June 9
    1. Unfortunately, no. You can edit the default project template located at C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Xamarin\Xamarin\[Xamarin Version]\T\PT\Cross-Platform\ (path could be slightly different on your machine). More information here about editing project templates

    2. Change the project name, and change the assembly name and default namespace in project properties

  • System.AshSystem.Ash Ash Narayan AUMember ✭✭

    Thanks.

    I tried your suggestion for 2. It seemed to change a lot of things except:
    a) MyApp/MyApp.Android folder name has stayed the same
    b) MyApp/MyApp.Android/Properties/AndroidManifest.xml still refers to MyApp.Android
    c) MyApp/MyApp.Android/Properties/AssemblyInfo.cs still refers to MyApp.Android

  • System.AshSystem.Ash Ash Narayan AUMember ✭✭

    Changing the 'Application name' field on the 'Android Manifest' tab of the Android project properties fixed (b).

    However, (a) and (c) remained unchanged.

  • System.AshSystem.Ash Ash Narayan AUMember ✭✭
    @PierceBoggan So did I have to make a change at all after creating a brand new solution with a .Android project? Or was whatever I did unnecessary?
  • System.AshSystem.Ash Ash Narayan AUMember ✭✭

    Just to make sure that is the case, I created a new solution named Test, and indeed the code files within Test.Android reference namespace Test.Droid :)
    So I guess I'll just leave the solution the way it is when it's first created.
    Thanks.

  • ShantimohanElchuriShantimohanElchuri Shantimohan Elchuri USMember ✭✭✭✭

    @System.Ash said:
    Just to make sure that is the case, I created a new solution named Test, and indeed the code files within Test.Android reference namespace Test.Droid :)
    So I guess I'll just leave the solution the way it is when it's first created.
    Thanks.

    I see that a bit weird. So I checked it.

    The project properties are set as:

    1. Application->Assembly Name: xxx.Android
    2. Application->Default Namespace: xxx.Droid

    That's how the code is surviving. But I don't why Xamarin keeps switching the project name between .Android and .Droid in various versions. So far I was not minding it as I don't worry as long as it is not breaking my project. But it is annoying to note it. And troublesome if I am reconstructing a project from scratch, few times as I had to do.

  • PierceBogganPierceBoggan Pierce Boggan USForum Administrator, Xamarin Team, Developer Group Leader Xamurai
    edited June 16

    @ShantimohanElchuri said:

    @System.Ash said:
    Just to make sure that is the case, I created a new solution named Test, and indeed the code files within Test.Android reference namespace Test.Droid :)
    So I guess I'll just leave the solution the way it is when it's first created.
    Thanks.

    I see that a bit weird. So I checked it.

    The project properties are set as:

      >
    1. Application->Assembly Name: xxx.Android
    2. >
    3. Application->Default Namespace: xxx.Droid
    4. >

    That's how the code is surviving. But I don't why Xamarin keeps switching the project name between .Android and .Droid in various versions. So far I was not minding it as I don't worry as long as it is not breaking my project. But it is annoying to note it. And troublesome if I am reconstructing a project from scratch, few times as I had to do.

    We will be unifying this to just be .Android in the future. In Visual Studio, this is already the default behavior. In 15.4, this should begin being the default in Visual Studio for Mac. It also shouldn't affect any existing applications, only File -> New, and even then it does not change anything but the project/assembly name itself.

Sign In or Register to comment.