question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Rising from 1.3.0-alpha02 to 1.3.0-alpha03 causes `You need to use a Theme.AppCompat theme (or descendant) with this activity` error

See original GitHub issue

Description: Did just rise material from com.google.android.material:material:1.3.0-alpha03 to com.google.android.material:material:1.3.0-alpha03

and got this run-time error:

2020-10-07 09:09:45.238 24547-24547/no.norva24.norva24reportertest2 E/AndroidRuntime: FATAL EXCEPTION: main
    Process: no.norva24.norva24reportertest2, PID: 24547
    java.lang.RuntimeException: Unable to start activity ComponentInfo{no.norva24.norva24reportertest2/no.norva24.norva24reportertest2.ui.activities.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3449)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7656)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
     Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
        at androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor(AppCompatDelegateImpl.java:843)
        at androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor(AppCompatDelegateImpl.java:806)
        at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:693)
        at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:195)
        at no.norva24.norva24reportertest2.ui.activities.MainActivity.onCreate(MainActivity.kt:102)
        at android.app.Activity.performCreate(Activity.java:8000)
        at android.app.Activity.performCreate(Activity.java:7984)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3422)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601) 
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85) 
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) 
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loop(Looper.java:223) 
        at android.app.ActivityThread.main(ActivityThread.java:7656) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) 

alpha02 does not produce this error.

Expected behavior: Compile and run as expected, but did not.

Source code: Instead of attaching all my project i attach the dependency trees, if you see any conflicts:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    ext.kotlin_version = '1.4.10'
    //ext.kotlin_version = '1.4.0'
    //ext.kotlin_version = "1.4.0-rc"
    //ext.kotlin_version = "1.4-M2"
    repositories {
        google()
        jcenter()
        mavenCentral()
        maven { url = "https://dl.bintray.com/kotlin/kotlin-eap/" }
        maven { url = "https://kotlin.bintray.com/kotlinx/"}
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.2.0-alpha12'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.3.0"
        classpath 'com.google.gms:google-services:4.3.4'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.3.0'
        classpath 'com.google.firebase:perf-plugin:1.3.2'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral()
        maven { url = "https://dl.bintray.com/kotlin/kotlin-eap/" }
        maven { url = "https://kotlin.bintray.com/kotlinx/" }

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
plugins {
    id 'com.android.application'
    id 'kotlin-android'
    id 'kotlin-kapt'
    id 'kotlin-android-extensions'
    id 'androidx.navigation.safeargs.kotlin'
    id 'com.google.gms.google-services'
    id 'com.google.firebase.crashlytics'
    id 'com.google.firebase.firebase-perf'
}

android {

    signingConfigs {
        debug
        release 
    }

    if(project.hasProperty("AndroidProject.signing")
        && new File(project.property("AndroidProject.signing").toString()).exists())
    {
        def Properties props = new Properties()
        def propFile = new File(project.property("AndroidProject.signing").toString())
        if(propFile.canRead())
        {
            props.load(new FileInputStream(propFile))
            if(props!=null)
            {
                if(props.containsKey('RELEASE_STORE_FILE') &&
                        props.containsKey('RELEASE_STORE_PASSWORD') &&
                        props.containsKey('RELEASE_KEY_ALIAS') &&
                        props.containsKey('RELEASE_KEY_PASSWORD') &&
                        props.containsKey('DEBUG_STORE_FILE') &&
                        props.containsKey('DEBUG_STORE_PASSWORD') &&
                        props.containsKey('DEBUG_KEY_ALIAS') &&
                        props.containsKey('DEBUG_KEY_PASSWORD'))
                {
                    android.signingConfigs.release.storeFile = file(props['RELEASE_STORE_FILE'])
                    android.signingConfigs.release.storePassword = props['RELEASE_STORE_PASSWORD']
                    android.signingConfigs.release.keyAlias = props['RELEASE_KEY_ALIAS']
                    android.signingConfigs.release.keyPassword = props['RELEASE_KEY_PASSWORD']
                    android.signingConfigs.debug.storeFile = file(props['DEBUG_STORE_FILE'])
                    android.signingConfigs.debug.storePassword = props['DEBUG_STORE_PASSWORD']
                    android.signingConfigs.debug.keyAlias = props['DEBUG_KEY_ALIAS']
                    android.signingConfigs.debug.keyPassword = props['RELEASE_KEY_PASSWORD']
                }
                else
                {
                    throw new Exception("Missing properties in:"+propFile.toPath())
                }
            }
        }
        else
        {
            throw new FileNotFoundException("Property file not found: "+propFile.toPath())
        }
    }


    def versionPropsFile = file('version.properties')
    def versionMajor = 0
    def versionMinor = 2
    def versionBuild
    def versionAppDatabase = 24

    if(versionPropsFile.canRead())
    {
        Properties versionProps = new Properties()
        versionProps.load(new FileInputStream(versionPropsFile))
        versionBuild = versionProps['VERSION_BUILD'].toInteger()
    } else {
        throw new FileNotFoundException("Could not read version.properties or its internals ! ")
    }

    ext.autoIncrementBuildNumber =
            {
                if(versionPropsFile.canRead())
                {
                    Properties versionProps  = new Properties()
                    versionProps.load(new FileInputStream(versionPropsFile))
                    versionBuild = versionProps['VERSION_BUILD'].toInteger()+1
                    versionProps['VERSION_BUILD'] = versionBuild.toString()
                    versionProps.store(versionPropsFile.newWriter(),null)
                }
                else
                {
                    throw new FileNotFoundException("Could not read version.properties or its contents ! ")
                }
            }

    gradle.taskGraph.whenReady {
        taskGraph ->
            if(taskGraph.hasTask(assembleDebug))
            {
                autoIncrementBuildNumber()
            }
            else if (taskGraph.hasTask(assembleRelease))
            {
                autoIncrementBuildNumber()
            }
            else if (taskGraph.hasTask(bundleDebug))
            {
                autoIncrementBuildNumber()
            }
            else if (taskGraph.hasTask(bundleRelease))
            {
                autoIncrementBuildNumber()
            }
    }

    compileSdkVersion 30
    buildToolsVersion "30.0.2"

    defaultConfig {
        applicationId "no.norva24.norva24reportertest2"
        minSdkVersion 21
        targetSdkVersion 30
        versionCode 11
        versionName versionMajor+"."+versionMinor+"."+versionCode+"."+versionAppDatabase+"."+versionBuild

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

        buildConfigField("long","TIMESTAMP", System.currentTimeMillis()+"L")
        buildConfigField("int","APPDATABASEVERSION","${versionAppDatabase}")
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            resValue("string", "google_maps_key","-omitted-")
        }
        debug {
            resValue("string", "google_maps_key","-omitted-")
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
    packagingOptions{
        exclude("META-INF/jersey-module-version")
    }
    buildFeatures {
        dataBinding = true
        compose = false
        viewBinding = true
    }
}

dependencies {

    //Kotlin
    //Stdlib
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

    //Coroutines
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9'


    //Androidx
    //Core
    //implementation 'androidx.core:core-ktx:1.4.0-alpha01'
    implementation 'androidx.core:core-ktx:1.5.0-alpha04'

    //AppCompat
    implementation 'androidx.appcompat:appcompat:1.3.0-alpha02'
    //implementation 'androidx.appcompat:appcompat:1.2.0'

    //CameraX
    implementation 'androidx.camera:camera-camera2:1.0.0-beta10'
    implementation 'androidx.camera:camera-lifecycle:1.0.0-beta10'
    implementation 'androidx.camera:camera-view:1.0.0-alpha17'

    //ConstraintLayout
    implementation 'androidx.constraintlayout:constraintlayout:2.0.1'

    //Navigation
    implementation 'androidx.navigation:navigation-fragment-ktx:2.3.0'
    implementation 'androidx.navigation:navigation-ui-ktx:2.3.0'

    //Fragment
    implementation 'androidx.fragment:fragment-ktx:1.3.0-beta01'

    //Lifecycle
    implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.0-beta01'
    implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.0-beta01'

    //Legacy
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'

    //Room
    implementation 'androidx.room:room-runtime:2.3.0-alpha02'
    kapt 'androidx.room:room-compiler:2.3.0-alpha02'
    implementation 'androidx.room:room-testing:2.3.0-alpha02'
    implementation 'androidx.room:room-ktx:2.3.0-alpha02'

    //Preference
    implementation 'androidx.preference:preference-ktx:1.1.1'

    //Local Broadcast Manager
    implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.1.0-alpha01'

    //RecyclerViewStyling
    implementation 'androidx.recyclerview:recyclerview:1.2.0-alpha06'

    //Microsoft
    //Identity
    implementation ('com.microsoft.identity.client:msal:2.0.1')
            {exclude group: 'com.microsoft.device.display'}

    //Graph
    implementation 'com.microsoft.graph:microsoft-graph:2.2.0'


    //Google
    //Material
    implementation 'com.google.android.material:material:1.3.0-alpha03'

    //Guava, to avoid conflict on ListenableFuture on jetified-guava-20.0 (com.google.guava:guava:20.0)
    // and jetified-listenablefuture-1.0 (com.google.guava.listenablefuture:1.0)
    // https://stackoverflow.com/questions/56639529/duplicate-class-com-google-common-util-concurrent-listenablefuture-found-in-modu
    //implementation 'com.google.guava:guava:28.2-android'
    implementation 'com.google.guava:guava:29.0-jre'

    //Firebase
    //Analytics
    implementation 'com.google.firebase:firebase-analytics-ktx:17.5.0'

    //Crashlytics
    implementation 'com.google.firebase:firebase-crashlytics-ktx:17.2.2'

    //Performance analysis
    implementation 'com.google.firebase:firebase-perf:19.0.9'

    //Play-Services
    //Maps
    implementation 'com.google.android.gms:play-services-maps:17.0.0'

    //Maps utilities
    implementation 'com.google.maps.android:android-maps-utils:2.0.3'

    //Location
    implementation 'com.google.android.gms:play-services-location:17.1.0'

    //Square Open Source
    //Retrofit2
    implementation 'com.squareup.retrofit2:retrofit:2.9.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.9.0'

    //OkHttp3
    implementation 'com.squareup.okhttp3:logging-interceptor:4.9.0'
    implementation 'com.squareup.okhttp3:okhttp:4.9.0'


    //Tests
    testImplementation 'junit:junit:4.13'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}

Android API version: API30

Material Library version: 1.3.0-alpha03

Device: Emulator API30: Pixel 4 API 30

To help us triage faster, please check to make sure you are using the latest version of the library.

We also happily accept pull requests.

RG

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
stpatrick2016commented, Dec 5, 2020

Having the same issue when upgrading from alpha03 to alpha04. Pretty much the same setup as of original poster.

0reactions
drchencommented, Mar 18, 2022

I’ll close this issue for now due to no further info available. Please feel free to reopen it if this is still happening.

Read more comments on GitHub >

github_iconTop Results From Across the Web

You need to use a Theme.AppCompat theme (or descendant ...
The reason you are having this problem is because the activity you are trying to apply the dialog theme to is extending ActionBarActivity...
Read more >
You need to use a Theme.AppCompat theme (or ... - YouTube
You need to use a Theme. AppCompat theme (or descendant ) with this activity is common problem encounter in Android App development.
Read more >
Need to use a Theme.AppCompat theme (or descendant) with ...
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. at ...
Read more >
You need to use a Theme.AppCompat theme (or ... - GitHub
You need to use a Theme.AppCompat theme (or descendant) with the design library #14 ... performCreate(Activity.java:5582) at android.app.
Read more >
How I resolved the “You need to use a Theme.AppCompat ...
AppCompat theme (or descendant) with this activity” Issue ... github actions and downloaded via firebase app distribution, with this error:
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found