Android Studio Gemini Bot Only Analyzes Your Code with Explicit Permission

5 min read
May 18, 2024

Learning Android Development

Photo by Alexander Grey on Unsplash

The launch of Android Studio Jellyfish has stirred both enthusiasm and concern within the developer community. It offers impressive new features, yet there are worries about how it manages data.

A recent write-up delves into this issue: “Protect your code from Gemini in Android Studio.” It discusses the shift from the Studio Bot to Gemini. While Gemini provides sophisticated coding suggestions, it also brings up privacy issues because of its data collection methods.

Some developers have expressed worries about the move to upgrade from Android Studio Iguana to Android Studio Jellyfish.

I have to admit, I’m extremely careful 😨 when setting up Android Studio Jellyfish. To be on the safe side, I’ve held onto my Android Studio Iguana version, just in case my trial run with Jellyfish accidentally sends all the sample project codes to Google. Having that backup means I can quickly delete it if necessary! 🤪

I have to admit, I’m incredibly careful 😨 when it comes to installing Android Studio Jellyfish. I still have my trusty Android Studio Iguana as a backup, just in case my tinkering with Jellyfish on a sample project accidentally uploads all the sample project code to Google. Having this fallback means I can quickly erase everything if necessary! 🤪

After giving Android Studio Jellyfish a try, it's clear that Google has put in a lot of work to make sure users are thoroughly aware of what they're permitting when it requests access to read our code.

I’m posting this to give those who haven’t installed Android Studio Jellyfish a clear idea of what to expect. I hope this helps you feel reassured that you have solid control over the future of your code.

When you initially set up Android Studio Jellyfish, it notified users about the introduction of Gemini as Studio Bot. This feature is accessible in over 180 countries, indicating that there are still some countries where it isn't available.

To get to Gemini, head to the Gemini console by going through View → Tools Window → Gemini. You'll be asked to log in to Google; without logging in, it won't be activated.

Another way to access it is by navigating to Settings → Tools → Gemini. Remember, you'll also need to log in to use it.

If you're logged in and want to log out, simply navigate to the Settings → Tools → Google Accounts page. After logging out, you will also be automatically opted out from Gemini.

After you log in, Gemini remains inactive. You will need to grant authorization.

When you authorize it, you will get a clear notification that you are sharing data with Google.

You can withdraw permission at any time or selectively decide which data you'd like to share in the future.

Once you receive authorization, the journey isn't over just yet; you still have a few more steps to follow.

After that, you will be notified about its privacy notice.

Then followed by an age check.

Note, it states, “You don’t need to share your code to use Gemini,” with more information available here.

The note specifies, “You don’t need to share your code to use Gemini,” with further details accessible here.

Once you've authorized and accepted Google's terms, you'll have the opportunity to decide if Gemini should “Use context” from your project.

You have the flexibility to switch this feature on or off whenever you like, depending on your needs. This allows you to decide whether or not to share your code, enabling the AI to help you more effectively.

As previously stated, you can find this feature by navigating to Settings → Tools → Gemini.

A key detail to remember is that deactivating “Use context” will prevent Gemini from delivering AI-driven inline code completion, as illustrated in the example below.

An important thing to remember is that turning off "Use context," will prevent Gemini from offering AI-driven inline code completion, as illustrated below.

The Enabled AI-based inline code completions checkbox will become inactive if you disable “Use context”. (This setting can only be adjusted on the Settings page).

The Enabled AI-based inline code completions checkbox will become unselectable if you deactivate “Use context”. You can manage these settings exclusively from the Setting page.

If a single developer activates Gemini bots for every project they access, there's a possibility that your code might end up being transmitted to Google.

To avoid this issue, Google offers a straightforward fix: just place a .aiexclude file in the root directory of your project. This file works much like a .gitignore file.

At the moment, simply having an empty file will work (however, upcoming updates might necessitate using *, as mentioned in this article).

To gain more control, you might want to check out the required syntax for the .aiexclude file.

Cautious for Monorepo Project Structure

Imagine a situation where your main project is composed of several sub-projects, with each one being able to be developed independently, as shown below:.

Diagram showing the need of having multiple .aiexclude files if other independent projects exist within your project

In this configuration, the .aiexclude file (1) found at the root project level isn't enough to completely safeguard the subroot projects. This happens because subroot projects can be accessed independently, and Android Studio Jellyfish will only take into account the .aiexclude file situated in the subroot project’s own root directory. It will stop looking up in the parent folder.

In these scenarios, each separate project must include its own aiexclude file (such as 2 and 3) to guarantee complete safeguarding.

Read more in Tech