Java.lang.IllegalStateException: You need to use Theme.AppCompat (or child) theme with this action. titanium

I am creating a custom theme for my Titanium application using this generator theme . But when I run my application, it crashes, and my log says what I need appCompact, even if I set the theme for sdk> sdk 11.

And my targeting version of Android is API 19, and the mini SDK version is API14, so I wonder why I need it appCompact.

Here is what my magazine says:

 [ERROR] :  TiApplication: (main) [512,512] Sending event: exception on thread: main msg:java.lang.RuntimeException: Unable to start activity ComponentInfo{a.s/org.appcelerator.titanium.TiActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.; Titanium 3.4.0,2014/09/25 16:42,b54c467
[ERROR] :  TiApplication: java.lang.RuntimeException: Unable to start activity ComponentInfo{a.s/org.appcelerator.titanium.TiActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
[ERROR] :  TiApplication:   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
[ERROR] :  TiApplication:   at android.app.ActivityThread.handleLaunchActivity(Activ
[ERROR] :  TiApplication:   at android.app.ActivityThread.access$800(ActivityThread.java:135)
[ERROR] :  TiApplication:   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
[ERROR] :  TiApplication:   at android.os.Handler.dispatchMessage(Handler.java:102)
[ERROR] :  TiApplication:   at android.os.Looper.loop(Looper.java:136)
[ERROR] :  TiApplication:   at android.app.ActivityThread.main(ActivityThread.java:5017)
[ERROR] :  TiApplication:   at java.lang.reflect.Method.invokeNative(Native Method)
[ERROR] :  TiApplication:   at java.lang.reflect.Method.invoke(Method.java:515)
[ERROR] :  TiApplication:   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
[ERROR] :  TiApplication:   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
[ERROR] :  TiApplication:   at dalvik.system.NativeStart.main(Native Method)
[ERROR] :  TiApplication: Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
[ERROR] :  TiApplication:   at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:108)
[ERROR] :  TiApplication:   at android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.java:57)
[ERROR] :  TiApplication:   at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:98)
[ERROR] :  TiApplication:   at org.appcelerator.titanium.TiBaseActivity.onCreate(TiBaseActivity.java:516)
[ERROR] :  TiApplication:   at org.appcelerator.titanium.TiActivity.onCreate(TiActivity.java:18)
[ERROR] :  TiApplication:   at android.app.Activity.performCreate(Activity.java:5231)
[ERROR] :  TiApplication:   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
[ERROR] :  TiApplication:   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
[ERROR] :  TiApplication:   ... 11 more
+4
source share
7 answers

ActionBarActivity, AppCompat. , Titanium, AppCompat, Activity ( , 11 ).

+6

ok, , ,

android:theme="@style/Theme.AppCompat"
+9

style-v11

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

styles-v14

 name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar"
+4

ActionBarActivity Activity FragmentActivity

+4

, , .

   <!-- 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>
+4
source

It’s a little awkward to admit that I encountered this error, but in the hope of saving someone by an hour or by pulling my hair, it was a strange ">" for me, which 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 skip if you have a very large manifest - the compiler does not complain.

+2
source

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

+1
source

All Articles