Cannot resolve symbol Theme.MaterialComponents.Light.NoActionBar (Android Studio)
Asked Answered
A

3

11

I've got an error for 'Theme.MaterialComponents.Light.NoActionBar' in styles.xml (the 'Theme.MaterialComponents.Light.NoActionBar' is colored red because of error) after several gradle update. My component are also not well arranged according to my idea of designing.

I've already clean and rebuild project, invalidate caches/restart, update the gradle (maybe not the correct answer) and there's no answer for this. I just think maybe I'm the only one that have this problem maybe for my beginner level problem :')

styles.xml

`

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/hitam</item>
    <item name="colorAccent">@color/colorAccent</item>

</style>

`

Project gradle

repositories {
    google()
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.4.2'
    classpath 'com.google.gms:google-services:4.2.0'

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

'

App gradle

      apply plugin: 'com.android.application'
      apply plugin: 'com.google.gms.google-services'

      android {
          compileSdkVersion 29
          defaultConfig {
          applicationId "blablabla"
          minSdkVersion 23
          targetSdkVersion 29
          versionCode 1
          versionName "1.0"
          testInstrumentationRunner               "androidx.test.runner.AndroidJUnitRunner"

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    buildToolsVersion '29.0.1'
}

compileOptions {

    sourceCompatibility JavaVersion.VERSION_1_6
    targetCompatibility JavaVersion.VERSION_1_6

    sourceCompatibility JavaVersion.VERSION_1_7
    targetCompatibility JavaVersion.VERSION_1_7

    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8

}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.google.ar.sceneform.ux:sceneform-ux:1.10.0'
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'com.google.firebase:firebase-core:17.0.1'
    implementation 'com.google.firebase:firebase-auth:18.1.0'
    implementation 'com.google.firebase:firebase-database:18.0.0'
    implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'
}

apply plugin: 'com.google.gms.google-services'
buildToolsVersion = '29.0.1'

          }

`

I expect the error is not visible when there's like no one in this earth that have this error. PLEASE HELP T_T

Alterant answered 31/7, 2019 at 3:55 Comment(3)
Hi "kindkind", welcome to StackOverflow! Please consider providing a Minimal, Reproducible Example of the problem you're facing so that we can help you troubleshoot the issue.Conductivity
Also, why are you setting the target and source compatibility of Java to multiple versions?Conductivity
I already forgot why i write that code but it solved my other coding and once it solved, i considered it to be successful hahaAlterant
P
26

The Material Components themes are included in the Material Components for Android library.

Since you are using androidx library just add this dependency in you app/build.gradle file.

dependencies {
    // ...
    implementation 'com.google.android.material:material:x.x.x'
    // ...
  }

Currently (April 29, 2022) the latest stable version is

implementation 'com.google.android.material:material:1.5.0'

Here you can find all the info the setup.

Peti answered 31/7, 2019 at 6:34 Comment(3)
Hi @Alterant if this or any answer has solved your question please consider accepting it by clicking the check-mark. This indicates to the wider community that you've found a solution and gives some reputation to both the answerer and yourself. There is no obligation to do thisPeti
Ohh right, I deleted it because I didn't know I needed it, thanks.Zelmazelten
My fix was upgrading that implementation to the latest version.Delvecchio
C
0

The reason why the MaterialComponents theme does not show is because you did not include the required Material Components library in your app/build.gradle:

dependencies {
    implementation 'com.google.android.material:material:<version>'
}

The currently available versions are listed on the project's GitHub releases.

Conductivity answered 31/7, 2019 at 5:59 Comment(0)
D
0

Add the dependency on Android’s Material in /android/app/build.gradle:

dependencies {
    // ...
    implementation 'com.google.android.material:material:<version>'
    // ...
}

To find out the latest version, visit Google Maven.

Set the theme in /android/app/src/main/res/values/styles.xml:

//<style name="LaunchTheme" parent="Theme.AppCompat"> - remove
<style name="LaunchTheme" parent="Theme.MaterialComponents.NoActionBar"> - add
Dola answered 31/5, 2021 at 1:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.