'Switching from sdk 29 to 31. I get this error

I'm trying to upgrade from sdk 29 to 31 I am getting this error:

Caused by: org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method compileSdk() for arguments [31] on object of type com.android.build.gradle.internal.dsl.BaseAppModuleExtension.

sdk


Solution 1:[1]

I changed to version 31

$ buildToolsVersion '31.0.0'

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Alex Bolotnikoff