Troubleshooting Android
Common setup issues with Android and Amazon.
Troubleshooting Steps
Check this page first for common issues based on Android Setup.
Try the example project on Github.
If stuck, contact support directly or email [email protected] for help.
For faster assistance, please provide:
- Your OneSignal App ID
- Details, logs, and/or screenshots of the issue.
- Steps to reproduce
Troubleshooting Steps
Please follow all steps below. If you are still having issues, please reach out to support with a log generated following the steps below.
1. Double Check Setup Guide
Return to the setup guide you followed in Mobile Push Quickstart to make sure you followed all steps adding the OneSignal SDK to your app.
2. Initialize Within the Application Class
Native Android SDKs, make sure you added the OneSignal init code within the onCreate
method in your Application
class. See Android SDK Setup for details.
3. Check below for common issues and if still not sure, send us a log.
After running through the rest of this Troubleshooting guide, use the OneSignal SDK setLogLevel method to Verbose to check the full logcat from the device when reproducing the behavior.
//The following options are available with increasingly more information:
//NONE, FATAL, ERROR, WARN, INFO, DEBUG, VERBOSE
OneSignal.setLogLevel(OneSignal.LOG_LEVEL.VERBOSE, OneSignal.LOG_LEVEL.NONE);
If you need help interpreting the logs, please share them as a .txt file to help our support and engineering team assist you.
How to get a crash or error log from an Android device
With Android Studio
1. Select Android Monitor
from the bottom of the window.
------If you don't see this select it from View
> Tool Windows
> Android Monitor
2. Select your device from the drop down.
3. Ensure no filters are set and the type is set to Verbose.
4. Select all lines in the log by pressing Control + A and then copy them.
5. Paste them into a .txt
file and send this to support. Include steps to reproduce the problem as well.
With the terminal / command line.
1. adb logcat -b all -d -v threadtime > onesignal_crash_logcat.txt
2. Send the onesignal_crash_logcat.txt
to support. Include steps to reproduce the problem as well.
If you don't have adb
in your path you will need to fully path to adb
in the Android SDK. It is under <android-sdk>\platform-tools\adb
.
If you don't have the Android SDK installed you can just download the SDK Platform Tools which contains the adb
executable.
ANR Troubleshooting
ANR errors occur when the main thread of your app is being blocked for over 5 seconds. You may see these occur along with:
Broadcast of Intent { act=com.google.android.c2dm.intent.RECEIVE flg=0x11000010 pkg=YOUR.PACKAGE.NAME cmp=your.package.name/com.onesignal.FCMBroadcastReceiver (has extras) }
This just shows how the app process started. This may appear to occur more often after adding OneSignal due to push notification received events starting your app process.
The best way to dig into these ANR issues is to check the full stacktrace of all threads.
Starting at the top of each stacktrace and working down, it will help guide you on which event occurred last to trigger the ANR.
If you see OneSignal in the actual stacktrace, please make sure you are testing on the latest version of our SDK. Once you verify that is still happening, send the full stack trace of all threads with the ANR to [email protected] and we will help investigate.
The full log would most likely be in the low 1,000s of lines long. The log we are looking for looks something like this.
Invalid recipients
This dashboard error counts how many times FCM sent us an "Unregistered" error in the provided timeframe. This error happens when you send a message to an invalid push token
. You may have push subscriptions with invalid push tokens due to:
- The push subscription(s) could have been imported or updated using our REST APIs. Check for any internal developers or QA Testers that may have been using our APIs and updated the subscription's
token
incorrectly. - If you deleted or changed the Firebase project's FCM credentials associated with your OneSignal app Settings.
Why are notifications disappearing without clicking them?
Check if you are calling our SDK Method: OneSignal.clearOneSignalNotifications();
or using the native Android method NotificationManagerCompat.from(context).cancelAll()
discussed here.
Why do I see previous notifications again?
The OneSignal Android Native SDK will reshow notifications that did not get interacted with. The user must click or dismiss the notification to not show it again.
Error:Execution failed for task ':app:processDebugGoogleServices'.
If you are receiving the following Android Studio error when building your project
Error:Execution failed for task ':app:processDebugGoogleServices'.
> Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 9.0.0.
Remove the following line from your .gradle
file.
apply plugin: 'com.google.gms.google-services'
E/dalvikvm: Could not find class
Could not find class errors are expected in the logcat for Android devices before 5.0. It is just letting you know it could not find these classes as your app loads into memory. It does not cause any issues in your app as the calls are guarded with runtime checks so they won't create any issues.
Error: Failed to resolve: com.android.support:customtabs:[26.0.0,26.2.0) OR com.android.support:support-v4:[26.0.0,26.2.0)
Failed to resolve: com.android.support:customtabs:[26.0.0,26.1.0)
Could not resolve all dependencies for configuration ':appName:'.
> Could not find any version that matches com.android.support:customtabs:[26.0.0,26.2.0).
Versions that do not match:
26.0.0-alpha1
25.3.1
+ 19 more
Required by:
project :appName > com.onesignal:OneSignal:3.6.0
Please use one of the Options below to resolve the issue;
Option A
Add the new Google Maven repo to your build.gradle
repositories {
maven { url 'https://maven.google.com' }
}
Also update compileSdkVersion
to 26
in your app/build.gradle
.
Option B
If you are not ready to update your project to the new support library yet and are still using targetSdkVersion 25
or lower you can follow Option A or C in the section's instructions.
Error: All gms/firesbase libraries must use the exact same version specification
All gms/firebase libraries must use the exact same version (mixing versions can lead to runtime crashes).
Found versions 11.0.4, 10.2.1.
Examples include com.google.android.gms:play-services-base:11.0.4 and com.google.android.gms:play-services-gcm:10.2.1.
OneSignal automatically adds the following dependencies;
com.google.android.gms
- Version 11.2.+com.android.support
- Version 26.1.+
To fix this issue, all dependencies must be matching versions.
Option A
Add the OneSignal-Gradle-Plugin to your project.
Option B
Upgrade - Find all com.google.android.gms
compile lines and update them to match.
// Update 9.0.0 to 11.2.+ so it is using the same gms version as OneSignal
compile 'com.google.android.gms:play-services-maps:9.0.0'
Option C
Downgrade - Force OneSignal's dependencies to a lower version.
// Replace gmsVersion and/or androidSupportVersion with the versions you need to downgrade to.
def gmsVersion = '11.2.+'
compile("com.google.android.gms:play-services-gcm:${gmsVersion}") {
force = true
}
compile("com.google.android.gms:play-services-location:${gmsVersion}") {
force = true
}
// Must use 26.0.0 or newer if you have targetSdkVersion 26
def androidSupportVersion = '26.1.+'
compile("com.android.support:support-v4:${androidSupportVersion}") {
force = true
}
compile("com.android.support:customtabs:${androidSupportVersion}") {
force = true
}
Error: java.lang.NoSuchMethodError: com.google.android.gms.common.internal.zzaa.zzb
If you see that some obfuscated Firebase or Google GMS methods are missing, it is most probably a dependency versioning conflict.
You can use the gradle dependencies
and gradle dependencyInsight
directives to troubleshoot which libraries are causing classes/methods to go missing. Refer to the official Gradle documentation for more information:
https://docs.gradle.org/current/userguide/tutorial_gradle_command_line.html#sec:dependency_insight
For example:
./gradlew app:dependencyInsight --configuration compile
Error:Execution failed for task ':app:processDebugManifest'
If you see the following error make sure you have completed step 1.2 correctly.
Execution failed for task ':app:processDebugManifest'
Manifest merger failed with multiple errors, see logs
Error:(3,0) startup failed: only buildscript {} and other plugins {} script blocks are allowed before plugins {} blocks, no other statements are allowed
Make sure you added the code from step 1.1 of the Android Setup to the very top of the build.gradle file. This should be the first line of code in the file.
No Users showing on the OneSignal dashboard
Make sure you have your Application in your AndroidManifest.xml
and add logging around OneSignal to make sure it is being called.
Make sure you have android:name=".ApplicationClass"
.
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme
android:name=".ApplicationClass">
public class ApplicationClass extends Application {
@Override
public void onCreate() {
super.onCreate();
Log.d("OneSignalTag", "Before OneSignal init");
OneSignal.setLogLevel(OneSignal.LOG_LEVEL.VERBOSE, OneSignal.LOG_LEVEL.NONE);
OneSignal.startInit(this).init();
Log.d("OneSignalTag", "After OneSignal init");
}
}
ERROR: AppId format is invalid
- Make sure you have
onesignal_app_id
in yourbuild.gradle
and your id is correct.
android {
defaultConfig {
manifestPlaceholders = [onesignal_app_id: "PUT YOUR ONESIGNAL APP ID HERE",
// Project number pulled from dashboard, local value is ignored.
onesignal_google_project_number: "REMOTE"]
}
}
- Make sure you are not replacing the
<application>
tag in yourAndroidManifest.xml
withtools:node="replace"
<application
android:icon="@mipmap/ic_launcher"
tools:node="replace" <!-- Remove this line!!! -->
android:name=".ApplicationClass">
If you must replace some attributes please use tools:replace
instead tools:node
.
Example: tools:replace="icon, label"
OneSignal Dependencies
OneSignal automatically includes the following dependencies;
com.google.android.gms - Version 11.2.+
com.android.support - Version 26.1.+
Since these are commonly used by other SDKs you may run into issues due to conflicting versions. Add the OneSignal-Gradle-Plugin to your project which will automatically resolve any conflicts.
1. Open your app/build.gradle
(Module: app) file, add the following to the top.
plugins {
id 'com.onesignal.androidsdk.onesignal-gradle-plugin' version '0.8.1'
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
WARNING: The onesignal-gradle-plugin MUST be before com.android.application!
In Android Studio open build.gradle (Module: app), make sure you have the following plugins and the order is the same as shown below:
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
apply plugin: 'com.android.application'
... a resolved Google Play services library dependency depends on another at an exact version (e.g. "[10.2.1, 16.0.99]", but isn't being resolved to that version. Behavior exhibited by the library will be unknown
In Android Studio open build.gradle (Module: app), make sure to add the following to the top of the file:
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
apply plugin: 'com.google.gms.google-services'
(Missing Google Play Services Library) status on the Dashboard
In Android Studio open build.gradle
(Module: app) and make sure you are using the latest OneSignal SDK under dependencies.
dependencies {
compile 'com.onesignal:OneSignal:[3.6.0, 3.99.99]'
}
Android Studio - No resource found that matches the given name: attr 'android:keyboardNavigationCluster'
Make sure you have compileSdkVersion
to 26
in your app/build.gradle
. This is required when you update to 26 of the Android Support Library.
Eclipse - ERROR - "conversion to dalvik format failed with error 1"
If you're getting a conversion to dalvik format failed with error 1
error with Dx bad class file magic (cafebabe) or version (0033.0000)
messages before this then you may have the wrong Java version set on your system. See the follow post to fix this as well as the other answers.
http://stackoverflow.com/a/9041471/1244574
Questions about "com.onesignal.NotificationOpenedReceiver" & “com.onesignal.UpgradeReceiver"
com.onesignal.NotificationOpenedReceiver is defined exactly like this in the AndroidManifest.xml
Since there are no intent filters it's default is NOT exported outside of the app.
See the Android documentation for this default behavior.
https://developer.android.com/guide/topics/manifest/receiver-element#exported
"com.onesignal.UpgradeReceiver"
This is broadcast receiver is filter to android.intent.action.MY_PACKAGE_REPLACED which only the Android OS should be able to fire. Also the Intent is not read, this is only used trigger an SDK task to put back any notifications to the shade after the app is updated as Android does not do this automatically.
A Widget's onUpdate
method getting called more frequently than expected when including the OneSignal SDK
onUpdate
method getting called more frequently than expected when including the OneSignal SDKThe OneSignal SDK depends on the Android Work Manager to schedule asynchronous tasks. This dependency has made a design decision which has the effect of calling a widget's onUpdate
method more frequently than expected. To avoid your widget's onUpdate
method getting called frequently, schedule a task in WorkManager during app initialization that will not run for 10 years.
// Add this code to your app initialization, which schedules work to run "in 10 years"
val workRequest = OneTimeWorkRequest.Builder(NeverRunWorker::class.java)
.setInitialDelay(3650, TimeUnit.DAYS)
.build()
WorkManager.getInstance(applicationContext)
.enqueueUniqueWork(
"XXXXX",
ExistingWorkPolicy.REPLACE,
workRequest
)
// define this class to represent the worker that will never run
class NeverRunWorker(context: Context, workerParams: WorkerParameters) : Worker(context, workerParams) {
override fun doWork(): Result {
return Result.success()
}
}
Updated about 2 months ago