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

  • Question

  • User106920 posted

    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

    Thursday, March 5, 2015 8:47 PM

All replies

  • User85826 posted

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

    Thursday, May 21, 2015 12:23 PM
  • User135812 posted

    Did that solve the problem?

    Tuesday, October 6, 2015 3:10 PM
  • User98607 posted

    Try this one, error must be solved :

    parent="Theme.AppCompat.Light.NoActionBar"

    Tuesday, October 6, 2015 6:43 PM
  • User157739 posted

    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.

    Wednesday, January 6, 2016 8:21 PM
  • User97779 posted

    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

    Friday, February 5, 2016 1:11 PM
  • User97779 posted

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

    Friday, February 5, 2016 9:01 PM
  • User193836 posted

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

    Wednesday, March 2, 2016 8:35 AM
  • User209348 posted

    @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:

    Friday, July 29, 2016 4:31 AM
  • User243375 posted

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

    For those who still have the problem, I fixed it changing in AndroidManifest.xml:

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android">
        <uses-sdk android:minSdkVersion="15" />
        <application android:label="YOURPROJECTNAME" android:icon="@drawable/icon"></application>
    </manifest>
    

    by

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android">
        <uses-sdk android:minSdkVersion="15" />
        <application android:label="YOURPROJECTNAME" android:icon="@drawable/icon" android:theme="@style/MainTheme"></application>
    </manifest>
    
    Wednesday, August 31, 2016 5:26 PM
  • User189201 posted

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

    Saturday, October 1, 2016 5:00 AM
  • User275516 posted

    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

    Wednesday, November 23, 2016 3:00 PM
  • User142704 posted

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

    Tuesday, January 10, 2017 11:10 AM
  • User282668 posted

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

    Monday, May 15, 2017 6:15 AM
  • User312982 posted

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

    Tuesday, January 23, 2018 8:22 AM
  • User288585 posted

    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">
    

    Tuesday, February 6, 2018 1:05 PM
  • User366563 posted

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

    Worked for me

    Friday, March 23, 2018 5:46 AM
  • User294608 posted

    @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

    Tuesday, March 27, 2018 9:57 AM
  • User367173 posted

    @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!!

    Tuesday, April 10, 2018 7:15 PM
  • User347645 posted

    @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

    Tuesday, June 12, 2018 1:27 PM
  • User43729 posted

    @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.

    Tuesday, July 3, 2018 10:52 AM
  • User371959 posted

    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)

    Wednesday, August 8, 2018 2:14 AM