BUILD FAILED with an exception in android studio

try to use NDK 24

android {
    ndkVersion "24.0.7956693" // beta 2
    ...
}

You can install it with.

echo "y" | sudo ${ANDROID_HOME}/tools/bin/sdkmanager --install 'ndk;24.0.7956693' --channel=3