java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. titanium

后端 未结 7 1755
北荒
北荒 2021-01-06 11:35

I\'m creating a custom theme for my Titanium application using this theme generator. But when I run my application it\'s crashing and my log says that I need appCompac

相关标签:
7条回答
  • 2021-01-06 11:45

    ok please try this,

    Add this attribute to your activity

    android:theme="@style/Theme.AppCompat"
    
    0 讨论(0)
  • 2021-01-06 11:52

    Delete all the styles in the library project. Specify Style folder only in main project not in library project. It worked for me :)

    0 讨论(0)
  • 2021-01-06 11:53

    You are using an ActionBarActivity, which requires an AppCompat theme. I'm not sure how you'd do this with Titanium, but you'd either need to switch to an AppCompat theme or use a regular Activity (which shouldn't be a problem if you're targeting 11 or above).

    0 讨论(0)
  • 2021-01-06 11:53

    It's a bit embarrassing to admit how I've encountered this error, but in a hope to save someone an hour or hair pulling - for me it was a stray ">" that I mistakenly copied into my AndroidManifest:

       <application
        android:name=".MyApplication"
        android:allowBackup="true"
        android:fullBackupContent="@xml/my_backup_rules">
        android:hardwareAccelerated="true"
        android:icon="@mipmap/icon_l"
        android:label="@string/app_name"
        android:requiredForAllUsers="true"
        android:supportsRtl="true"
        android:theme="@style/MyAppTheme">
    

    Too easy to miss if you have a very large manifest - the compiler doesn't complain.

    0 讨论(0)
  • 2021-01-06 12:00

    write the code in style-v11 folder

     name="AppBaseTheme" parent="Theme.AppCompat.Light"
    

    and in styles-v14 folder

     name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar"
    
    0 讨论(0)
  • 2021-01-06 12:03

    I know it's very only question but you should include parent theme into your style.

       <!-- Base application theme. Transparent theme -->
        <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
            <!-- Customize your theme here. -->
            <item name="colorPrimary">@color/colorPrimary</item>
            <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
            <item name="colorAccent">@color/colorAccent</item>
        </style>
    
    
        <style name="Transparent" parent="Theme.AppCompat.Light.DarkActionBar">
            <item name="android:windowIsTranslucent">true</item>
            <item name="android:windowBackground">@android:color/transparent</item>
            <item name="android:windowContentOverlay">@null</item>
            <item name="android:windowNoTitle">true</item>
            <item name="android:windowIsFloating">true</item>
            <item name="android:backgroundDimEnabled">false</item>
        </style>
    
    0 讨论(0)
提交回复
热议问题