The new app was generated from a project template by VS2019 and that template is now quite old. The final piece of creating the new app is to upgrade the dependencies. Public class MainActivity : AppCompatActivity The display on the home screen/launcher controlled by Label= in the code file for the MainActivity like this 1 I actually specify the app display name twice, the android:label in the AndroidManifest.xml file, shown above, sets the app name for display in settings and the app info screen. So the actual names are specified in the VS2029 project properties UI for the app package nameĪnd in the strings.xml resources for the app display name 1 In debug it script actually just appends debug to the existing value depending on the build type. The configuration is passed in and it sets the package attribute as well as the android:label without affecting the rest of the file. I have to use $(ProjectDir) and be relative as for some reason the $(SolutiontDir) does not work with the Xamarin tooling. The powershell script is stored in the enclosing solution folder. PowerShell -File "$(ProjectDir).\Update-PackageName.ps1" $(ProjectDir) $(ConfigurationName) This script is called from the bottom of the csproj file like this 1 package If ( $ ConfigurationName - eq "Release" - and $ package. Param ( $ ProjectDir, $ ConfigurationName ) Write - Host "ProjectDir: $ProjectDir" Write - Host "ConfigurationName: $ConfigurationName" $ ManifestPath = $ ProjectDir + "Properties\AndroidManifest.xml" Write - Host "ManifestPath: $ManifestPath" $ xdoc = Get - Content $ ManifestPath $ package = $ xdoc. To automatically edit this file as part of the build I used a Powershell script 1 The package name is set in the AndroidManifest.xml. Its done differently in the Xamarin project. This is especially useful as it enables both debug and release versions to be installed on the same device. If you have setup app development in Android Studio you will know that Gradle makes it pretty easy to have different display names and package names for different flavours off the app, for instance debug and release.ĪpplicationId "" The result was placed in the colors.xml in the usual place, note that I added ic_app_background for the app icon which was generated in a separate file by VS2019. I used the wonderful to generate the colour scheme. It is a real benefit that the project structure is pretty much identical to that of a regular Java/Kotlin Android Studio project. I wanted to replace the app icon and colour palette with my own so I copied my png and scaleable graphics into the solution. I wanted the minimum amount of generated code so I went for a blank app. ![]() ![]() To get started I created an empty solution called PodcastUtilities and in that solution I created a new Xamarin Android App Create Application ProjectĪs I said before I am using VS2019, as it was the most recent stable version available when I started. ![]() This is the second part of that journey which describes the steps I took to get the basic Visual Studio Solution setup. In a previous post I started to describe my new project PodcastUtilities for Android using Xamarin Android.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |