Adhish Thite
Adhish Thite

Reputation: 463

Android App with basic Material Design force closes on start

I am pretty new to Android, am learning Android through some tutorials.

Recently, I came across a nice website which showed a perfect implementation of Tabs usage.

The link is : http://www.android4devs.com/2015/01/how-to-make-material-design-sliding-tabs.html

I copy pasted the exact same code in my Android Studio. The project ZIP is attached here: https://drive.google.com/open?id=0B7Q0z2lM1VTRR3JjSXFPQk1vNkE&authuser=0 ,as it would a tremendous amount of code.

This is a very simple app with no major implementation at all.

The problem is the App crashes on opening. I don't know why. There is no reason for it to crash because I have copy pasted the entire code through the tutorial.

Please help me.

Logs are:

03-14 07:52:12.702    1814-1814/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.adhish.materialtest3, PID: 1814
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.adhish.materialtest3/com.adhish.materialtest3.MainActivity}: java.lang.IllegalStateException: This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead.
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
            at 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)
     Caused by: java.lang.IllegalStateException: This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead.
            at android.support.v7.app.ActionBarActivityDelegateBase.setSupportActionBar(ActionBarActivityDelegateBase.java:165)
            at android.support.v7.app.ActionBarActivity.setSupportActionBar(ActionBarActivity.java:92)
            at com.adhish.materialtest3.MainActivity.onCreate(MainActivity.java:31)
            at android.app.Activity.performCreate(Activity.java:5933)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
            at 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)
03-14 07:52:12.706      499-828/? W/ActivityManager﹕ Force finishing activity com.adhish.materialtest3/.MainActivity
03-14 07:52:13.086      191-191/? E/EGL_emulation﹕ tid 191: eglCreateSyncKHR(1181): error 0x3004 (EGL_BAD_ATTRIBUTE)
03-14 07:52:13.272      499-529/? W/art﹕ Long monitor contention event with owner method=android.graphics.Bitmap com.android.server.wm.WindowManagerService.screenshotApplications(android.os.IBinder, int, int, int, boolean) from WindowManagerService.java:6033 waiters=0 for 245ms
03-14 07:52:13.281      499-555/? W/art﹕ Long monitor contention event with owner method=void com.android.server.am.ActivityManagerService.crashApplication(com.android.server.am.ProcessRecord, android.app.ApplicationErrorReport$CrashInfo) from ActivityManagerService.java:12038 waiters=0 for 544ms
03-14 07:52:13.282      499-499/? W/art﹕ Long monitor contention event with owner method=void com.android.server.am.ActivityManagerService.crashApplication(com.android.server.am.ProcessRecord, android.app.ApplicationErrorReport$CrashInfo) from ActivityManagerService.java:12038 waiters=1 for 540ms
03-14 07:52:13.299      499-524/? W/ViewRootImpl﹕ Dropping event due to no window focus: KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_ALT_RIGHT, scanCode=100, metaState=META_ALT_ON|META_ALT_RIGHT_ON, flags=0x8, repeatCount=6028, eventTime=370910, downTime=58849, deviceId=1, source=0x301 }
03-14 07:52:13.301      499-524/? W/ViewRootImpl﹕ Dropping event due to no window focus: KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_ALT_RIGHT, scanCode=100, metaState=META_ALT_ON|META_ALT_RIGHT_ON, flags=0x8, repeatCount=6029, eventTime=372034, downTime=58849, deviceId=1, source=0x301 }

Upvotes: 0

Views: 923

Answers (1)

Pooja
Pooja

Reputation: 2467

You can solve this error by setting

<item name="windowActionBar">false</item> 

to your styles.xml

Or you can use Theme.AppCompat.Light.NoActionBar instead of Theme.AppCompat.Light.DarkActionBar in your styles.xml

Upvotes: 2

Related Questions