aapt: error: resource android:color/system_neutral1_1000 not found

Total
0
Shares
aapt: error: resource android:color/system_neutral1_1000 not found

You will get aapt: error: resource android:color/system_neutral1_1000 not found when you are using Material-1.5.0-alpha03 or later and using compiledSdkVersion less than 31.

Problem

According to Material Component release notes,

  1. Make sure to update your app’s compileSdkVersion to 31 when using this version of the library.
  2. If using the new DynamicColors.java util class to apply dynamic colors on Android 12, make sure to update your app to depend on AndroidX Core version 1.6.0 or later (e.g., androidx.core:core:1.6.0) (#2353).

This release supports dynamic colors. Dynamic colors are introduced in Android S where themes and UI can dynamically update based on device wallpapers, preferences and colors.

Solution

If you are using Material Components version 1.5.0-alpha03 or later then it is necessary to set compileSdkVersion to 31 or later in gradle file. Otherwise you will get aapt: error: resource android:color/system_neutral1_1000.

Solution 1: Downgrading Material Component

You may simply downgrade version 1.5.0-alpha03 to either 1.4.0 or 1.5.0-alpha02

- implementation 'com.google.android.material:material:1.5.0-alpha03'
+ implementation 'com.google.android.material:material:1.5.0-alpha02'

Or,

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

Solution 2: Upgrading compileSdkVersion

If you need to use alpha03 or later version of material:1.5.0 then you may upgrade compileSdkVersion to 31 or later –

android {
    compileSdkVersion 31
    buildToolsVersion '30.0.2'
    ....
}
compileSdkVersion 31 in build.gradle

After using any of these solutions, you won’t get aapt: error: resource android:color/system_neutral1_1000 not found.

      aapt: error: resource android:color/system_neutral1_1000 not found ♥♥

Click here to Tweet this

Sign Up for Our Newsletters

Get only the best articles delivered to your mail