npx skills add ...
npx skills add auth0/agent-skills --skill auth0-android
npx skills add auth0/agent-skills --skill auth0-android
Use when adding Auth0 login, logout, or credential management to an Android app in Kotlin or Java. Covers Web Auth, biometric-protected CredentialsManager, and MFA — even if the user just says "add login to my Android app" without mentioning Auth0. Integrates com.auth0.android:auth0.
Add authentication to Android applications using com.auth0.android:auth0.
Agent instruction: Before providing SDK setup instructions, fetch the latest release version by running:
Use the returned version in all
implementationdependency lines instead of any hardcoded version below. If the command fails, fall back to checking https://github.com/auth0/Auth0.Android/releases.
Install SDK: Add the Auth0 Android SDK dependency to your build.gradle:
Configure Auth0:
Agent instruction: Check whether the user prompt already includes both Auth0 Client ID and Domain.
- If both are provided, proceed directly to Manual Setup in Setup Guide [blocked] using those values.
- If either is missing, you MUST ask the user BEFORE writing any code or files:
- Question: "How would you like to configure Auth0 for this project?"
- Options: "Automatic setup (Recommended) — Auth0 CLI creates the app and writes credentials to strings.xml" / "Manual setup — I'll provide my Client ID and Domain"
Then follow Setup Guide [blocked] for the chosen path. Do NOT proceed to step 3 until Auth0 credentials are confirmed.
Note: For native Android apps, Domain and Client ID are public configuration (not secrets). No client secret is used. Write values directly to
strings.xmlwithout displaying them in conversation output.
Initialize: Create an Auth0 account instance:
IMPORTANT:
Auth0.getInstance(context)auto-readscom_auth0_client_idandcom_auth0_domainfromstrings.xml. Never passclientIdordomainas arguments (e.g.Auth0.getInstance(clientId, domain)) — that hardcodes credentials in source.
Add Auth UI: Implement login and logout with Web Auth:
Agent instruction: Before adding new UI elements, search the project for existing click handlers for login, logout, sign-in, or sign-out buttons (e.g.,
loginButton,signInButton,logoutButton,signOutButton, orsetOnClickListenerwith auth-related naming). If existing handlers are found, hook the Auth0 code into them without modifying the existing UI. Only create new buttons if no existing handlers are found.
Login:
Logout:
Build & Verify:
Agent instruction: After completing the integration, build the project to verify it compiles successfully:
If the build fails, analyze the error output and fix the issues. Common integration build failures include:
- Unresolved reference: Missing import statements — add the required
import com.auth0.android.*imports- Cannot resolve symbol
R.string.com_auth0_scheme:strings.xmlnot updated — verifycom_auth0_scheme,com_auth0_client_id, andcom_auth0_domainentries exist- Incompatible types in callback: Callback type parameters don't match — ensure
Callback<Credentials, AuthenticationException>for login andCallback<Void?, AuthenticationException>for logout- Unresolved
lifecycleScope: Missing dependency — addimplementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.+'or move code out of coroutine scope- minSdk too low: SDK requires API 21+ — update
minSdkVersionto at least 21- Java version mismatch: SDK requires Java 8 — add
compileOptionswithJavaVersion.VERSION_1_8Re-run the build after each fix. Track the number of build-fix iterations.
Failcheck: If the build still fails after 5–6 fix attempts, stop and ask the user:
- Question: "The build is still failing after several fix attempts. How would you like to proceed?"
- Options: "Let the agent continue fixing iteratively" / "I'll fix it manually — show me the errors" / "Skip build verification and proceed"
Repeat this check after every 5–6 iterations if errors persist. Do not leave the project in a non-compiling state without the user's explicit consent.
The callback URL must match your Auth0 application settings: {SCHEME}://{YOUR_AUTH0_DOMAIN}/android/{YOUR_APP_PACKAGE_NAME}/callback
| Mistake | Fix |
|---|---|
| App type not set to Native in Auth0 Dashboard | Create a Native application type in your Auth0 tenant. The Android SDK requires Native app configuration, not Machine-to-Machine or other types. |
| Missing callback URL in Allowed Callback URLs | Add {SCHEME}://{YOUR_AUTH0_DOMAIN}/android/{YOUR_APP_PACKAGE_NAME}/callback to your Auth0 application's Allowed Callback URLs setting, where {SCHEME} matches com_auth0_scheme in strings.xml (e.g., demo by default). |
Missing <uses-permission android:name="android.permission.INTERNET" /> | Add the INTERNET permission to AndroidManifest.xml. The SDK requires network access for authentication. |
| Custom scheme in lowercase | Android requires scheme names to be lowercase. Use https (recommended) or lowercase custom scheme like myapp://callback. |
Forgetting .validateClaims() on direct auth calls | Always call .validateClaims() when using AuthenticationAPIClient directly (for database, passwordless, or API login). Web Auth validates automatically. |
| Storing tokens in SharedPreferences without encryption | Use SecureCredentialsManager to store credentials. Never store tokens manually in plain text. The manager encrypts tokens at rest. |
| Missing manifest placeholders | Add manifestPlaceholders = [auth0Domain: "@string/com_auth0_domain", auth0Scheme: "@string/com_auth0_scheme"] to your build.gradle defaultConfig block. |
| Class | Purpose |
|---|---|
Auth0 | Entry point for SDK, holds app credentials |
WebAuthProvider | OAuth 2.0 login/logout via browser |
AuthenticationAPIClient | Direct API calls (database login, passwordless, MFA) |
SecureCredentialsManager | Secure storage and retrieval of credentials |
Credentials | User tokens and expiration |