java - Android Studio 1.1.0 You need to use a Theme.AppCompat theme (or descendent) crush -


using: android studio 1.1.0 api 21 (android 5.0.1)

crush exception:

04-09 19:06:59.089    1892-1892/com.example.abrate.myapplication e/androidruntime﹕ fatal exception: main process: com.example.abrate.myapplication, pid: 1892 java.lang.runtimeexception: unable start activity componentinfo{com.example.abrate.myapplication/com.example.abrate.myapplication.mainactivity}: java.lang.illegalstateexception: need use theme.appcompat theme (or descendant) activity.         @ android.app.activitythread.performlaunchactivity(activitythread.java:2298)         @ android.app.activitythread.handlelaunchactivity(activitythread.java:2360)         @ android.app.activitythread.access$800(activitythread.java:144)         @ android.app.activitythread$h.handlemessage(activitythread.java:1278)         @ android.os.handler.dispatchmessage(handler.java:102)         @ android.os.looper.loop(looper.java:135)         @ android.app.activitythread.main(activitythread.java:5221)         @ java.lang.reflect.method.invoke(native method)         @ java.lang.reflect.method.invoke(method.java:372)         @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:899)         @ com.android.internal.os.zygoteinit.main(zygoteinit.java:694)  caused by: java.lang.illegalstateexception: need use theme.appcompat theme (or descendant) activity.         @ android.support.v7.app.actionbaractivitydelegate.oncreate(actionbaractivitydelegate.java:152)         @ android.support.v7.app.actionbaractivitydelegatebase.oncreate(actionbaractivitydelegatebase.java:149)         @ android.support.v7.app.actionbaractivity.oncreate(actionbaractivity.java:123)         @ com.example.abrate.myapplication.mainactivity.oncreate(mainactivity.java:13)         @ android.app.activity.performcreate(activity.java:5937)         @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1105)         @ android.app.activitythread.performlaunchactivity(activitythread.java:2251)               @ android.app.activitythread.handlelaunchactivity(activitythread.java:2360)             at android.app.activitythread.access$800(activitythread.java:144)             at android.app.activitythread$h.handlemessage(activitythread.java:1278)             at android.os.handler.dispatchmessage(handler.java:102)             at android.os.looper.loop(looper.java:135)             at android.app.activitythread.main(activitythread.java:5221)             at java.lang.reflect.method.invoke(native method)             at java.lang.reflect.method.invoke(method.java:372)             at com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:899)             at com.android.internal.os.zygoteinit.main(zygoteinit.java:694) 

activity_main.xml

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" android:paddingbottom="@dimen/activity_vertical_margin" tools:context=".mainactivity">  <textview android:text="@string/hello_world" android:layout_width="wrap_content"     android:layout_height="wrap_content" /> 

mainactivity.java

    package com.example.abrate.myapplication;  import android.support.v7.app.actionbaractivity; import android.os.bundle; import android.view.menu; import android.view.menuitem;   public class mainactivity extends actionbaractivity {      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_main);     }       @override     public boolean oncreateoptionsmenu(menu menu) {         // inflate menu; adds items action bar if present.         getmenuinflater().inflate(r.menu.menu_main, menu);         return true;     }      @override     public boolean onoptionsitemselected(menuitem item) {         // handle action bar item clicks here. action bar         // automatically handle clicks on home/up button, long         // specify parent activity in androidmanifest.xml.         int id = item.getitemid();          //noinspection simplifiableifstatement         if (id == r.id.action_settings) {             return true;         }          return super.onoptionsitemselected(item);     } } 

androidmanifest.xml

    <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android"     package="com.example.abrate.myapplication" >      <application         android:allowbackup="true"         android:icon="@mipmap/ic_launcher"         android:label="@string/app_name"         android:theme="@android:style/theme.holo.light" >         <activity             android:name=".mainactivity"             android:label="@string/app_name" >             <intent-filter>                 <action android:name="android.intent.action.main" />                  <category android:name="android.intent.category.launcher" />             </intent-filter>         </activity>     </application>  </manifest> 

i don't know how fix issue, use theme.holo.light application , in android developers site (http://developer.android.com/guide/topics/ui/actionbar.html) written if api 11 or higher mainactivity.java should import "android.app.actionbar" , not "android.support.v7.app.actionbar", how fix issue? should go ahead using theme.appcompat or trying solve problem , use "android.app.actionbar" , theme.holo?

this android:theme="@android:style/theme.holo.light" in manifest needs appcompat

it written if api 11 or higher mainactivity.java should import "android.app.actionbar" , not "android.support.v7.app.actionbar"

this case (but not requirement there cases not possible) when had holo theme there material theme


Popular posts from this blog