How to resolve "Could not find method bundle() for arguments [build_6plat21h.....] on object of type com.android.build.gradle.LibraryExtension"?

I ran into the same problem trying all things, commenting the bundle block fixed the problem for me

/*bundle {
        language {
            enableSplit = false
        }
        density {
            enableSplit = false
        }
        abi {
            enableSplit = true
        }
    }*/

I am not sure if this is the right approach but after building the project and generating the apk I got my .aar file which I guess is what you are trying to get.