Search code examples
android-studiogoogle-gemini

How to solve the error: status FAILED_PRECONDITION in Android Studio Gemini?


I want to try out the new Gemini assistant in Android studio. However it will not work due to an unexpected network error. It states: Please try again later. Error: Status FAILED_PRECONDITION

I tried installing the most recent Android Studio versions and logging in with my Google account. Accepting the terms and conditions for Gemini and gave project permissions. After asking one of the suggested questions, I got an error instead of an answer.

Android Studio versions used:

  1. Android Studio Koala 2024.1.1 (Build #AI-241.15989.150.2411.11948838, built on June 10, 2024)
  2. Android Studio Koala Feature Drop 2024.1.2 Canary 8 (Build #AI-241.18034.62.2412.12022747, built on June 27, 2024)

Example: Gemini start page Error instead of answer


Solution

  • I had the same problem, and I found this page from Google itself that helped: Troubleshooting guide.

    This problem, FAILED_PRECONDITION, was defined "User location is not supported for the API use without a billing account linked.", and as a solution, "To use the Gemini API, you will need to setup a paid plan using Google AI Studio.". Basically, you can't use Gemini AI without having a paid account.

    In this other webpage, Available regions for Google AI Studio and Gemini API you can verify whether your country is also required to have a paid plan (the ones with the blue 1 need paid plan)

    Hope this helps, this is indeed the case for me. Now is time to try and avoid this regional barrier, good luck to y'all too ; ).