### Install Web3Auth Android SDK (Groovy) Source: https://github.com/web3auth/web3auth-android-sdk/blob/master/README.md Instructions for adding the Web3Auth Android SDK dependency to your project. It requires adding the JitPack repository to your project-level `settings.gradle` and the SDK dependency to your app-level `build.gradle`. ```Groovy dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { google() mavenCentral() maven { url "https://jitpack.io" } // <-- Add this line } } implementation 'com.github.web3auth:web3auth-android-sdk:9.0.0' ``` -------------------------------- ### Initialize and Login with Web3Auth Android SDK (Kotlin) Source: https://github.com/web3auth/web3auth-android-sdk/blob/master/README.md Demonstrates how to initialize the Web3Auth SDK with necessary options like client ID, network, and redirect URL. It also shows how to handle user login using a specified provider and manage the login callback, including handling results when the app is active or not alive. ```Kotlin import com.web3auth.core.Web3Auth import com.web3auth.core.types.Web3AuthOptions import com.web3auth.core.types.Provider import com.web3auth.core.types.LoginParams import com.web3auth.core.types.Web3AuthResponse import android.net.Uri import android.os.Bundle import androidx.appcompat.app.AppCompatActivity import android.widget.Toast import android.content.Intent import java.util.concurrent.CompletableFuture class MainActivity : AppCompatActivity() { private lateinit var web3Auth: Web3Auth override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) web3Auth = Web3Auth( Web3AuthOptions( context = this, clientId = "YOUR_WEB3AUTH_CLIENT_ID", // Pass over your Web3Auth Client ID from Developer Dashboard network = Network.MAINNET, redirectUrl = Uri.parse("{YOUR_APP_PACKAGE_NAME}://auth"), ) ) // Handle user signing in when app is not alive web3Auth.setResultUrl(intent?.data) } override fun onResume() { super.onResume() if (Web3Auth.getCustomTabsClosed()) { Toast.makeText(this, "User closed the browser.", Toast.LENGTH_SHORT).show() web3Auth.setResultUrl(null) Web3Auth.setCustomTabsClosed(false) } } override fun onNewIntent(intent: Intent?) { super.onNewIntent(intent) // Handle user signing in when app is active web3Auth.setResultUrl(intent?.data) } private fun onClickLogin() { val selectedLoginProvider = Provider.GOOGLE // Can be Google, Facebook, Twitch etc val loginCompletableFuture: CompletableFuture = web3Auth.login(LoginParams(selectedLoginProvider)) loginCompletableFuture.whenComplete { _, error -> if (error == null) { // render logged in UI } else { // render login error UI } } } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.