James
James

Reputation: 102

Custom theme crashing app on startup

I am trying to define a custom theme for my app with the following:

<style name="AppTheme" parent="@android:style/Theme.AppCompat">
    <!--Custom theme options go here-->
</style>

When running the app on my S4 (as developer) it crashes instantly. I've also tried:

<style name="AppTheme" parent="@android:style/Theme.Holo.Light">
    <!--Custom theme options go here-->
</style>

But this gives me he error

Cannot resolve symbol '@android:style/Theme.AppCompat'

Gradle info as follows:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "example.android.magic"
        minSdkVersion 16
        targetSdkVersion 22
        versionCode 3
        versionName "1.1.1"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'com.google.android.gms:play-services-ads:7.5.0'
}

I'm using Android Studio 1.2.2

Upvotes: 0

Views: 61

Answers (2)

BladeCoder
BladeCoder

Reputation: 12929

Theme should be

@style/Theme.AppCompat

Or shorter notation without the style prefix:

Theme.AppCompat

because it's not part of Android, it's part of the library in your project.

Upvotes: 1

orrett3
orrett3

Reputation: 1038

Change @android:style/Theme.AppCompat to Theme.AppCompat

Upvotes: 1

Related Questions