-2

I have been attempting to run this application from this repository https://github.com/tekinarslan/AndroidMaterialDesignToolbar But each time it crashes with the following message

    07-26 11:36:39.864    4405-4405/com.tekinarslan.material.sample E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.tekinarslan.material.sample/com.tekinarslan.material.sample.SampleActivity}: java.lang.IllegalArgumentException: AppCompat does not support the current theme features
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
        at android.app.ActivityThread.access$600(ActivityThread.java:130)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:137)
        at android.app.ActivityThread.main(ActivityThread.java:4745)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:511)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
        at dalvik.system.NativeStart.main(Native Method)
 Caused by: java.lang.IllegalArgumentException: AppCompat does not support the current theme features
        at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:360)
        at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:246)
        at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106)
        at com.tekinarslan.material.sample.SampleActivity.onCreate(SampleActivity.java:36)
        at android.app.Activity.performCreate(Activity.java:5008)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
        at android.app.ActivityThread.access$600(ActivityThread.java:130)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:137)
        at android.app.ActivityThread.main(ActivityThread.java:4745)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:511)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
        at dalvik.system.NativeStart.main(Native Method)

The following is the build.gradle file

apply plugin: 'com.android.application'

android {
compileSdkVersion 22
buildToolsVersion "22.0.1"

defaultConfig {
    applicationId "com.tekinarslan.material.sample"
    minSdkVersion 16
    targetSdkVersion 22
    versionCode 1
    versionName "1.2"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:22.1.1'
compile 'com.android.support:appcompat-v7:22.1.1'


}

And this is the styles.xml file

<resources>

<style name="AppTheme" parent="AppTheme.Base"/>

<style name="AppTheme.Base" parent="Theme.AppCompat">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="android:windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
    <item name="drawerArrowStyle">@style/DrawerArrowStyle</item>

</style>

<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
    <item name="spinBars">true</item>
    <item name="color">@android:color/white</item>
</style>
</resources>

It shows the same message even after I replace ActionBarActivity with AppCompatActivity in the SampleActivity.java file..Please help

1 Answers1

0

Replacing android:windowNoTitle with just windowNoTitle fixes the issue.

Had similar problem and https://blog.xamarin.com/android-tips-hello-material-design-v7-appcompat/

fixed using suggestion given in this link.

<!--If you are using revision 22.1 please use just windowNoTitle. Without android:-->
    <item name="windowNoTitle">true</item>

If your intention is to not use actionbar at all and use only toolbar, you can use Theme.AppCompat.NoActionBar as parent. (This I have tried on your git code and it works).

Ramesh
  • 1,287
  • 1
  • 9
  • 14
  • got your code and saw the error and updated the answer – Ramesh Jul 26 '15 at 07:53
  • I have no idea why it isn't working for me. What are the specifications you have used on Android Studio? Actually I am completely new to android. – Aritra Bhattacharyya Jul 26 '15 at 08:06
  • I just cloned your source code and removed "android:" prefix of windowNoTitle and it worked. same way when I made parent Theme.AppCompat.NoActionBar also it worked. But you app still crashing on launch as SimpleFragment has one more crash for tintCheckbox. – Ramesh Jul 26 '15 at 08:24
  • When you say 'worked' you mean it ran on emulator. right? – Aritra Bhattacharyya Jul 26 '15 at 08:50
  • I had run it on my phone. When i say it worked, i meant your toolbar problem is resolved. But on launch it still crashes because your sample fragment has some other problem with tintCheckbox. – Ramesh Jul 26 '15 at 08:52