Coding⏱️ 3 min read📅 2026-06-03

How to Fix: AppCompat v7 r21 returning error in values.xml?

Android Studio error in values.xml with AppCompat v7 r21

Quick Answer: The issue is caused by a deprecated attribute 'android:actionModeShareDrawable' which was removed in Android 5.0 (API level 21). Update the version to 23.0.0 or later, or use the new attribute 'android:actionModeBackground' instead.

The 'AppCompat v7 r21' library is causing errors when using Android Studio, and it affects developers who are trying to use this library in their projects.

This error can be frustrating for developers because it prevents them from successfully building and running their apps. Fortunately, there are steps you can take to resolve the issue.

💡 Why You Are Getting This Error

  • The primary reason for this error is that the 'AppCompat v7 r21' library has been deprecated and is no longer supported. This means that it will not receive any further updates or bug fixes.
  • An alternative reason could be that the project's Gradle file is using an outdated version of the library, which may also cause compatibility issues.

✅ Best Solutions to Fix It

Update to the latest version of AppCompat

  1. Step 1: Open the project's build.gradle file and update the 'appcompat-v7' dependency to its latest version.
  2. Step 2: In the Gradle file, replace `21.0.0` with the latest version number, such as `1.2.0`. This will ensure that your project uses the most recent and supported version of AppCompat.
  3. Step 3: After updating the dependency, clean and rebuild the project to ensure that all necessary files are generated.

Use a different library

  1. Step 1: Consider using a different library, such as 'AppCompat v7 r1' or 'Material Design', which is still actively maintained and supported.
  2. Step 2: Update the project's Gradle file to use the new dependency, following the same steps as above.

💡 Conclusion

By updating to the latest version of AppCompat or using a different library, you should be able to resolve the error and successfully build and run your app. Remember to regularly check for updates to ensure that your project remains compatible with changing Android versions.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions