Please accept all necessary Android SDK licenses using Android SDK Manager: "$ANDROID_HOME/tools/bin/sdkmanager --licenses". 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