FAILURE: Build failed with an exception.

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':unityLibrary:GoogleMobileAdsPlugin.androidlib:generateReleaseRFile'.
> Failed to install the following SDK components:
      platforms;android-31 Android SDK Platform 31
  The SDK directory is not writable (C:\Program Files\Unity\Hub\Editor\6000.0.23f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK)



SOLUTION:

Make sure SDK Platform 31 is installed with Android Studio.
Go to the SDK folder of Android Studio.
Copy the folder of platform 31 from this SDK/platforms folder and paste it into the SDK/platforms folder used by Unity.