For me, I upgraded my gradle tools to 8, and adding the following configuration in modules's build.gradle resolved this issue(inside 'android' block):
buildFeatures { aidl = true }