Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Sudden error: "expected color but got (raw string)" in Android

ganesh96ganesh96 Member ✭✭✭

Hi!

I've updated Visual Studio to version 16.7.1 and ever since I did that I get an error which was not there before:

This only happens with Android. Line 4 in styles.xml is this:

I read something about updating from packges.config to PackagesReferences might help, but I'm unable to find the migration option in my solution (right-click on References does not show the migrate option).

Does someone wthat is wrong here and how to solve this?

Best regards

Best Answer

Answers

  • LandLuLandLu Member, Xamarin Team Xamurai

    Did it occur on a new blank application?
    Normally, we could fix this by a complete clean up like:
    delete bin/obj folders.

  • ganesh96ganesh96 Member ✭✭✭
    edited August 17
    No. It happened on an existing app.

    I removed the bin and obj folder, did a Clean Solution in VS and then performed a Build Solution. The error still occured.
  • LandLuLandLu Member, Xamarin Team Xamurai

    I haven't encountered this issue before.
    We need a repo to look into this error.
    If it is not convenient to share your project on this public forum, you could open a support ticket here:
    https://support.microsoft.com/en-us/supportforbusiness/productselection?sapId=211dd84f-3474-c3c5-79bf-66db630c92a6.

  • ganesh96ganesh96 Member ✭✭✭

    I created a new app to see how it looks in styles.xml. I see some comments I didn't had before:

    It seems the version update to Xamarin.Forms 4.6 is causing the issue. Any ideas? I will use the support link as well.

  • LandLuLandLu Member, Xamarin Team Xamurai

    The latest version of Xamarin Forms has reached 4.8:
    https://docs.microsoft.com/en-us/xamarin/xamarin-forms/release-notes/
    You could have a try with it.
    What have you set in the MainTheme.Base?
    An empty MainTheme should not throw this sort of error.

  • ganesh96ganesh96 Member ✭✭✭
    edited August 20

    Maybe you can see the issue with the full styles.xml:

            <?xml version="1.0" encoding="utf-8" ?>
            <resources>
    
              <style name="MainTheme" parent="MainTheme.Base">
              </style>
              <!-- Base theme applied no matter what API -->
              <style name="MainTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
                <!--If you are using revision 22.1 please use just windowNoTitle. Without android:-->
                <item name="windowNoTitle">true</item>
                <!--We will be using the toolbar so no need to show ActionBar-->
                <item name="windowActionBar">false</item>
                <!-- Set theme colors from https://aka.ms/material-colors -->
                <!-- colorPrimary is used for the default action bar background -->
                <item name="colorPrimary">#2196F3</item>
                <!-- colorPrimaryDark is used for the status bar -->
                <item name="colorPrimaryDark">#1976D2</item>
                <!-- colorAccent is used as the default value for colorControlActivated
                     which is used to tint widgets -->
                <item name="colorAccent">#2196F3</item>
                <!-- You can also set colorControlNormal, colorControlActivated
                     colorControlHighlight and colorSwitchThumbNormal. -->
                <item name="windowActionModeOverlay">true</item>
    
                <item name="android:datePickerDialogTheme">@style/AppCompatDialogStyle</item>
    
                <item name="android:colorActivatedHighlight"></item>
              </style>
    
              <style name="AppCompatDialogStyle" parent="Theme.AppCompat.Light.Dialog">
                <item name="colorAccent">#FF4081</item>
              </style>
    
              <style name="MyTheme.Splash" parent ="Theme.AppCompat.Light.NoActionBar">
                <item name="android:windowBackground">@drawable/splash_screen</item>
                <item name="android:windowNoTitle">true</item>
                <item name="android:windowFullscreen">true</item>
                <item name="android:windowContentOverlay">@null</item>
                <item name="android:windowActionBar">true</item>
              </style>
    
            </resources>    
    
  • ganesh96ganesh96 Member ✭✭✭

    Okay it most certainly NOT an issue with Xamarin Forms 4.6 or 4.8. I have another laptop with the exact same solution and the only difference is the Visual Studio version.

  • ganesh96ganesh96 Member ✭✭✭

    That's it! Thanks a lot! :)

Sign In or Register to comment.