Android 30 sdk & build tools 30.0.2 license issue when build on travis

I have changed compileSdkVersion to 30 & buildToolsVersion to 30.0.2 in my android project. I am able to build the project successfully on my machine. But when we build the same project on Travis the build is getting failed
Following are the logs from the build:

What went wrong:

Could not determine the dependencies of task ‘:app:bundleExperimentalDebugResources’.
> Failed to install the following Android SDK packages as some licences have not been accepted.

  • build-tools;30.0.2 Android SDK Build-Tools 30.0.2*
  • platforms;android-30 Android SDK Platform 30*
  • To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.*
  • Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html*

I have tried all possible solutions which I have seen on internet.Nothing helped me.
Here is my code from travis.yml


language: android
jdk:

  • oraclejdk8
    android:
    licenses:
    • ‘android-sdk-preview-license-.+’
    • ‘android-sdk-license-.+’
    • ‘google-gdk-license-.+’
      components:
    • platform-tools
    • tools
    • android-30
    • build-tools-30.0.2
      before_install:
  • yes | sdkmanager --update
  • yes | sdkmanager --licenses
  • yes | sdkmanager “platforms;android-30”

Please help me in building the project on travis.
Thanks

Hello,
Try with the following configurations for .travis.yml and hopefully, the issue you are encountering will be resolved.

language: android
dist: trusty
android:
   components:
      - tools
      - platform-tools
      - tools
      - extra-google-google_play_services
      - extra-android-m2repository
   licenses:
      - 'android-sdk-preview-license-.+'
      - 'android-sdk-license-.+'
      - 'google-gdk-license-.+'

before_install:
   - touch $HOME/.android/repositories.cfg
   # Android API Level 30
   - yes | sdkmanager "platforms;android-30"
   - yes | sdkmanager "build-tools;30.0.2"
   # Android API Level 31
   - yes | sdkmanager "platforms;android-31"
   - yes | sdkmanager "build-tools;31.0.0"
   # Android API Level 32
   - yes | sdkmanager "platforms;android-32"
   - yes | sdkmanager "build-tools;32.0.0"


before_cache:
   - rm -f  $HOME/.gradle/caches/modules-2/modules-2.lock
   - rm -fr $HOME/.gradle/caches/*/plugin-resolution/

cache:
   directories:
      - $HOME/.android/build-cache

script:
   - sdkmanager --list

Best,