You need to use a Theme.AppCompat theme (or descendant) with this activity.

Hi, I'm getting the error in thread title, however, I AM using the Theme.AppCompat, so I don't understand why I should have this error. My files are as follows:

AndrodidManifest.xml

 `android:theme="@style/AppTheme"`

values/styles.xml

<resources>

    <style name="AppTheme" parent="AppTheme.Base"/>

    <style name="AppTheme.Base" parent="Theme.AppCompat">

         <!-- colorPrimary is used for the default action bar background -->
        <item name="colorPrimary">@color/colorPrimary</item>

        <!-- colorPrimaryDark is used for the status bar -->
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>

        <!-- colorAccent is used as the default value for colorControlActivated,
             which is used to tint widgets -->
        <item name="colorAccent">@color/colorAccent</item>

    </style>

</resources>

values-v21/styles.xml

    <resources>
        <style name="AppTheme" parent="Theme.AppCompat">
        </style>       
    </resources>

I've tried many variations but nothing seems to work. I am using Xamarin.Android.Support.v7.AppCompat -Version 21.0.3.0.

Is this a bug?

Thanks
Mike

Posts

  • AndreyKozhynAndreyKozhyn USMember ✭✭

    Had the same error, what did help is to delete Resources.Designer.cs file, build project, include generated Designer file into a project.

  • KariemMadaniKariemMadani NLMember

    Did that solve the problem?

  • BerayBentesenBerayBentesen TRUniversity ✭✭✭✭

    Try this one, error must be solved :

    parent="Theme.AppCompat.Light.NoActionBar"

  • Caleb.MorrisCaleb.Morris USMember

    Were you able to solve this problem?
    Neither parent="Theme.AppCompat.Light.NoActionBar" nore any extension of Theme.AppCompat has resulted in the correct theme for below API 21.

  • KorayemKorayem EGMember ✭✭
    edited February 2016

    According to this article, you need to install a Xamarin.Android.Support.v7.AppCompat/ to bring compatibility to older versions of Android, as low as Android API 10

  • KorayemKorayem EGMember ✭✭

    Also if you're using Xamarin forms, make sure MainActivity.cs inherits from FormsApplicationActivity

  • GVxGVx USMember ✭✭✭

    @JosephKandi said:
    Just perform a Build -> Clean All and run again. That solved my issues when i added a CoordinatorLayout

    This worked for me... thanks! :smile:

  • LeoReadingLeoReading USMember

    @alextn you just saved me a lot of headaches. Thanks for posting back with the solution!

  • VijayPawar.0297VijayPawar.0297 USMember ✭✭

    Hi, I followed BerayBentesen's Step

    1) open Main.xaml layout in design mode and change the theme to which you wish
    2) goto AndroidManifest.xml file and now change parent="Theme.AppCompat.Light.NoActionBar" or any other in Theme in Theme.AppCompat

    this helped me. Thank you All

  • pradeepArutlapradeepArutla USUniversity ✭✭

    The fix mentioned by 'Korayem' worked for me. If you're using Xamarin forms, make sure MainActivity.cs inherits from FormsApplicationActivity

  • SnehalJadhav.7507SnehalJadhav.7507 USMember ✭✭

    I solved this issue by adding Apptheme theme into manifest file.

  • MatijaMatija USMember ✭✭

    I needed to update the Xamarin.Forms version first and then perform Clean All which solved the problem.

  • SanjayShriSanjayShri USMember

    Here are the steps:

    1. Go to Property-->Androidmanifest.xml
      It will open the file in IDE

    Enter the value in the Application theme as @style/MagicTheme

    Save it

    1. Now go to Resources-->Values -- Add a file by style.xml
    2. write the below code in style.xml

    <style name="Theme" parent="MagicTheme.Base">
    

    @drawable/SOMEPNGFILENAME true false @null true

  • @JosephKandi said:
    Just perform a Build -> Clean All and run again. That solved my issues when i added a CoordinatorLayout

    Worked for me

  • MuhammadKhalidMuhammadKhalid USMember

    @JosephKandi said:
    Just perform a Build -> Clean All and run again. That solved my issues when i added a CoordinatorLayout

    This also worked for me
    Thanks @JosephKandi

  • @JosephKandi said:
    Just perform a Build -> Clean All and run again. That solved my issues when i added a CoordinatorLayout

    This worked for me.
    Thank you!!

  • UmairEmUmairEm GBMember ✭✭

    @JosephKandi said:
    Just perform a Build -> Clean All and run again. That solved my issues when i added a CoordinatorLayout

    THIS WORKS!

    I think Xamarin generates the android manifest file at build time and it stays in debug/obj/android/ folder, cleaning the solution would get rid of it and makes everything back to "working" again.

    However, if you are actually not using AppCompat theme (or any of its sub) then you need to fix that.

    Thank you

  • JamesClossJamesCloss GBMember ✭✭

    @AndreyKozhyn said:
    Had the same error, what did help is to delete Resources.Designer.cs file, build project, include generated Designer file into a project.

    Thanks for the suggestion - this also worked for me.

  • bt_ncbt_nc Member

    If you are using VS 2017 this worked for me:

    Tools --> NuGet Package Manager --> Package Manager Console

    Paste this into the PM console: Install-Package Xamarin.Android.Support.v7.AppCompat -Version 27.0.2

    Then go to Project --> [YOURPROJECTNAME] Properties --> Android Manifest and make sure that the Target Android version is set to Android 8.1 (API Level 27 - Oreo)

Sign In or Register to comment.