VOOZH about

URL: https://www.geeksforgeeks.org/kotlin/android-jetpack-compose-integrate-google-recaptcha/

⇱ Android Jetpack Compose - Integrate Google reCAPTCHA - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Android Jetpack Compose - Integrate Google reCAPTCHA

Last Updated : 23 Jul, 2025

Google reCAPTCHA is a service provided by Google which is used to verify the user whether is a user or a robot by providing them with a simple captcha to solve. In this article, we will be taking a look at How to integrate Google reCAPTCHA in the android application using Jetpack Compose.

Steps to Integrate Google reCAPTCHA

Step 1: Create a New Project in Android Studio

To create a new project in the Android Studio, please refer to How to Create a new Project in Android Studio with Jetpack Compose.

Step 2: Add the below Dependency to your build.gradle.kts File

Below is the dependency for Volley which will be needed for using of reCAPTCHA. For adding this dependency navigate to the app > Gradle Scripts > build.gradle.kts(Module :app) and add the below dependency in the dependencies section. 

dependencies {
...
implementation("com.android.volley:volley:1.2.1")
implementation ("com.google.android.gms:play-services-safetynet:18.1.0")
}

After adding the dependency simply sync your project to install it. 


Step 3: Generating API key for using Google reCAPTCHA

For using Google reCAPTCHA we have to build two keys as site key and the site secret key which we have to use for authentication. For creating a new API key navigate to this Google developer's site. And refer to the following diagram to generate the API keys.

👁 Image

After adding this data accept reCAPTCHA terms and then click on Submit option.


Step 4: Adding permissions for the Internet

As we are calling the API for Google reCAPTCHA so we have to add permissions for the Internet in our AndroidManifest.xml. Navigate to the app > AndroidManifest.xml and add the below code to it. 

<uses-permission android:name="android.permission.INTERNET"/>


Step 5: Working with the MainActivity.kt file

Go to the MainActivity.kt file and refer to the following code. Below is the code for the MainActivity.kt file. Comments are added inside the code to understand the code in more detail.

MainActivity.kt:

Output:

Comment
Article Tags:

Explore