Using an AI coding assistant?
For AI-driven installation, use this prompt:
Step 0. Configure FCM in OneSignal (required to deliver push)
You can install and initialize the OneSignal Android SDK without completing this step. However, push notifications will not deliver until Firebase Cloud Messaging (FCM) credentials are configured in your OneSignal app.If your company already has a OneSignal account, ask to be invited as an admin role to configure the app. Otherwise, sign up for a free account to get started.
Steps to configure your OneSignal app.
Steps to configure your OneSignal app.
These steps connect your OneSignal app to Firebase Cloud Messaging (FCM). You only need to do this once per app.
- Login to https://onesignal.com and create or select your App.
- Navigate to Settings > Push & In-App.
- Select Google Android (FCM) and Continue through the setup wizard.
- Input your Firebase Server Key or Service Account details.
- Continue through the setup wizard to get your App ID. This will be used to initialize the SDK.
For full setup instructions, see our Mobile push setup guide.
Setup contract & requirements
This section summarizes the tools, versions, and assumptions used throughout the guide.- SDK version:
5.6.1+(latest: check releases) - AI setup instructions:
https://raw.githubusercontent.com/OneSignal/sdk-ai-prompts/main/docs/android/ai-prompt.md - SDK repo:
https://github.com/OneSignal/OneSignal-Android-SDK - Android Studio: Meerkat+ (2024.2.1+)
- Android API: 23+ minimum (Android 6.0+), 31+ recommended (Android 12+)
- Device/Emulator: Android 7.0+ with Google Play Services installed
- Required dependency:
com.onesignal:OneSignal:[5.6.1, 5.6.99] - Application class: Required for proper SDK initialization
- App ID format: 36-character UUID (example:
12345678-1234-1234-1234-123456789012) — find at OneSignal Dashboard > Settings > Keys & IDs - Initialize:
OneSignal.initWithContext(this, "YOUR_APP_ID") - Battery Optimization: May affect background notifications
- Recommended: Assign External ID via
OneSignal.login("user_id")to unify users across devices
Android setup steps
By the end of the steps below, you will have:- The OneSignal SDK installed and initialized in your Android app
- Push notification permissions prompting correctly on a real device
- A test push and in-app message successfully delivered
If you skipped Step 0 (Configuring FCM in OneSignal), you can still complete the Android Studio setup below. Complete Step 0 before you test or send push notifications.
Step 1. Add the OneSignal SDK
- In Android Studio, open your
build.gradle.kts (Module: app)orbuild.gradle (Module: app)file - Add OneSignal to your
dependenciessection:

- Sync Gradle: Click Sync Now in the banner that appears or go to File > Sync Project with Gradle Files
Verify that the gradle sync completes successfully without dependency conflicts.
Step 2. Create and configure Application class
It’s best practice to initialize OneSignal in theonCreate method of your Application class to ensure proper SDK setup across all entry points.
Create an Application class if you don’t already have one:
- File > New > Kotlin Class/File (or Java Class)
- Name:
ApplicationClass(or your preferred name)

YOUR_APP_ID with your actual OneSignal App ID from the Dashboard > Settings > Keys & IDs.

- Open your app’s
AndroidManifest.xml - In your
<application>tag addandroid:name=".ApplicationClass"(replace.ApplicationClasswith your actual class name if set it to something different).
AndroidManifest.xml

Verify that the app builds and runs without errors.
Step 3. Configure default notification icons (recommended)
Customize notification icons to match your app’s branding. This step is optional but recommended for a professional appearance.Step 4. Test the integration
Verify Subscription creation:- Launch app on device or emulator with Google Play Services
- Check Dashboard > Audience > Subscriptions — status shows “Never Subscribed”
- Accept the permission prompt when it appears
- Refresh dashboard — status changes to “Subscribed”



You have successfully created a mobile Subscription.
Mobile subscriptions are created when users first open your app on a device or if they uninstall and reinstall your app on the same device.
Create test Subscription and segment
- Click ⋮ next to the Subscription > Add to Test Subscriptions > name it
- Go to Audience > Segments > New Segment
- Name:
Test Users, add filter Test Users > Create Segment


You have successfully created a segment of test users.We can now test sending messages to this individual device and groups of test users.
Send test push via API
- Navigate to Settings > Keys & IDs.
- In the provided code, replace
YOUR_APP_API_KEYandYOUR_APP_IDin the code below with your actual keys. This code uses theTest Userssegment we created earlier.


Verify the test device received a notification with:
- Your custom icon (if configured)
- Large image when expanded
- Dashboard > Delivery > Sent Messages shows “Confirmed” status (unavailable on free plans).
Test in-app messages
- Close app for 30+ seconds
- Dashboard > Messages > In-App > New In-App > select Welcome template
- Audience: Test Users segment
- Trigger: On app open
- Schedule: Every time trigger conditions are satisfied
- Click Make Message Live
- Open app




Verify the test device received an in-app message. See the In-app messages setup guide for more details.
You have successfully set up the OneSignal SDK and learned important concepts like:
- Gathering Subscriptions, setting Test subscriptions, and creating Segments.
- Sending Push with images using Segments and our Create message API.
- Sending In-app messages.
Common Errors & Fixes
| Error / Symptom | Cause | Fix |
|---|---|---|
Cannot resolve symbol 'OneSignal' | SDK dependency not added or gradle not synced | Add dependency to build.gradle and sync project |
Application class not found | Application class not registered in manifest | Add android:name=".ApplicationClass" to <application> tag |
Google Play Services not available | Emulator/device missing Play Services | Use device with Play Store or emulator with Google APIs |
| Push received but default Android icon | Custom icon not configured or wrong name | Create notification icon asset named onesignal_small_icon_default |
| No push notifications received | FCM not configured in OneSignal | Complete Step 0: Configure FCM credentials in OneSignal dashboard |
| In-app messages not showing | Session not started or network issues | Close app 30+ seconds, reopen, check internet connection |
Manifest merger failed | Conflicting manifest attributes | Check for duplicate application names or permissions conflicts |
| Battery optimization blocking notifications | Device power management | Guide users to disable battery optimization for your app |
| Can’t diagnose issue | Not enough log info | Add verbose logging and check logcat output for errors |
User management
Previously, we demonstrated how to create mobile Subscriptions. Now we’ll expand to identifying Users across all their Subscriptions (including push, email, and SMS) using the OneSignal SDK.Assign External ID (recommended)
Use an External ID to identify users consistently across devices, email addresses, and phone numbers using your backend’s user identifier. This ensures your messaging stays unified across channels and 3rd party systems. See our Mobile SDK reference for more details and Java code examples.Kotlin
OneSignal generates unique read-only IDs for Subscriptions (Subscription ID) and Users (OneSignal ID).Setting the External ID via our SDK is highly recommended to identify users across all their subscriptions, regardless of how they are created.Learn more about the
login method in the SDK reference guide.Add Tags & Custom Events
Tags and Custom Events are both ways to add data to your users. Tags arekey-value strings and are generally associated with user properties (like username, role, or status) while Custom Events have a JSON format and are usually associated with actions (like new_purchase, abandoned_cart, and associated properties). Both can be used to power advanced Message Personalization and Journeys. See our Mobile SDK reference for more details and Java code examples.
Kotlin
More details on how to use Tags and Custom Events in the Tags and Custom Events guides.
Add email and/or SMS subscriptions
You can reach users through email and SMS channels in addition to push notifications. If the email address and/or phone number already exist in the OneSignal app, the SDK will add it to the existing user — it will not create duplicates. See our Mobile SDK reference for more details and Java code examples.Kotlin

Best practices for multi-channel communication
- Obtain explicit consent before adding email or SMS subscriptions.
- Explain the benefits of each communication channel to users.
- Provide channel preferences so users can select which channels they prefer.
Privacy & user consent
To control when OneSignal collects user data, use the SDK’s consent gating methods. See our Mobile SDK reference for more details and Java code examples.Kotlin
See our Privacy & security docs for more on:
Prompt for push permissions
Instead of callingrequestPermission() immediately on app open, take a more strategic approach. Use an in-app message to explain the value of push notifications before requesting permission.
For best practices and implementation details, see our Prompt for push permissions guide.
Listen to push, user, and in-app events
Use SDK listeners to react to user actions and state changes. Add these in your Application class afterOneSignal.initWithContext().
Push notification events
Kotlin
User state changes
Example shows how to use push subscription observer. Other user state events like the user state observer and notification permission observer are available in the Mobile SDK Reference.Kotlin
In-app message events
Additional in-app message methods are available in the Mobile SDK Reference.Kotlin
Advanced setup & capabilities
Android-specific features
- Notification Channels — Organize notifications into categories (Android 8.0+)
- Service Extensions — Advanced notification customization
- Huawei/HMS Support — Alternative to Google Play Services
Universal features
- Deep Linking — Navigate users to specific screens from notifications
- Action Buttons — Add interactive buttons to notifications
- Identity Verification — Secure user identification
- Location Tracking — Location-based targeting
- Integrations — Connect with analytics and data platforms
- Multi-language Messaging — Localized notifications
Need help?Chat with our Support team or email
support@onesignal.comPlease include:- Details of the issue you’re experiencing and steps to reproduce if available
- Your OneSignal App ID
- The External ID or Subscription ID if applicable
- The URL to the message you tested in the OneSignal Dashboard if applicable
- Any relevant logs or error messages