This error is actually more annoying than common. One of the major reasons it is so annoying is because of the fact that it does not actually point to the exact line or file that caused the error. It leaves it up to you to figure it out.
We still have not been able to point out what exactly triggers this error but it seems to have something to do with a mismatch in your Gradle dependencies.
There are different ways to fix this issue. Not all of them will work for you.
- Check your build.gradle file to make sure your compileSdkVersion matches the version of your support libraries.123compileSdkVersion 27implementation 'com.android.support:appcompat-v7:26.1.0'implementation 'com.android.support:design:26.1.0'
The above code will possibly throw this error because the support library version does not match the compileSdkVersion. So to fix this, upgrade your support library version.
- Migrate your entire project to AndroidX. To migrate your project, follow these instructions:
- Click on the Refractor menu item in Android Studio
- Click on “Migrate to AndroidX”.
- Follow screen instructions
The second solution could be problematic in large and complex projects. You might be required to manually migrate some of your libraries. However, this solution is guaranteed to solve this error as long as the migration is successfully completed.
It is recommended that you backup your entire project before attempting to migrate to AndroidX. This way, if something goes wrong, you can easily revert to a working version.
That’s all for now.
If you have any questions or contributions, feel free to post them in the comment box below :).