The main reason for this issue is that higher versions of gradle are incompatible with lower versions or have added new restrictions. Here’s how to fix it:
In the build.gradle file, change the following in the dependencies section:
From:
implementation
or
compile
To:
api
Also, make sure to update:
implementation fileTree(dir: 'libs', include: ['*.jar'])