I managed to solve the problem by following this post:
Long story short, go to C:\Program Files\Epic Games\UE_5.4\Engine\Build\Android\Java\gradle\app and add the following two lines in the dependencies:
def billing_version = "6.1.0"
implementation "com.android.billingclient:billing:$billing_version"
6 Likes