Please accept all necessary Android SDK licenses using Android SDK Manager code example
Example: error Failed to install the app. Please accept all necessary Android SDK licenses using Android SDK Manager
Go to Configure>SDK Manager in your Android Studio.
Select SDK Tools tab and install Google Play Licensing Library