The core of the problem

Smartphones are getting more and more powerful, but the battery capacity is lagging behind. Vendors are always trying to squeeze some battery saving features into the firmware with each new Android release. With Android 6 (Marshmallow), Google has introduced Doze mode to the base Android, in an attempt to unify battery saving across the various Android phones.

Unfortunately, vendors such as Samsung, Huawei, OnePlus (and more) did not seem to catch that ball and they all have their own battery savers, usually very poorly written, saving battery only superficially.

These battery saving features have lots of side effects. They usually kill long running processes – but don’t care whether the user wants the process to run or not (think sleep tracking).
They also impose arbitrary limits on random things – like how many times can you schedule an alarm during the night. If you go over the limit – boom! No alarm in the morning! That’s what you get for not reading the documentation on vendor modifications (oh wait, there is no documentation).

How to prevent the alarm and sleep tracking from failing? Opt out of the battery savers.

Solutions

Android 8 (Oreo)

Android O has brought an option to limit background activity for specific apps. This will break alarms when enabled for Sleep as Android.

Please make sure that System settings > Apps > Sleep > Battery > Background activity is enabled.

Huawei

Huawei is one of the most troubled phones on the market, Chinese vendors tend to ignore Android best practices and implement very bizarre custom modifications which make background task nearly impossible to run.

Please do:

  • Phone settings > Advanced Settings > Battery manager > Power plan is set to Performance..
  • Phone Settings > Advanced Settings > Battery Manager > Protected apps – check for Sleep as Android as Protected
  • Phone Settings > Apps > Sleep as Android > Battery > Power-intensive prompt [x] and Keep running after screen off [x]
  • Phone settings > Apps > ‘Advanced (At the bottom) > Ignore optimisations > Press ‘Allowed’ > All apps > Find Sleep on the list and set to ‘Allow’
  • (Huawei P9 Plus) Phone settings > Apps > Settings > Special access > Ignore battery optimisation > select allow Sleep app.

If all fails, please try to set the app as device administrator (Sleep as Android > Setting > CAPTCHA > Prevent escaping CAPTCHA). This may also prevent the system from killing sleep tracking.

OnePlus

The app does not usually work on OnePlus phones unless you turn off battery optimizations for Sleep.

System Settings > Apps > Gear Icon > Special Access > Battery Optimization.

WARNING: Recently OnePlus phones started reverting this setting randomly for random apps. So you set it to be “not optimized”, and the next day it may be back to “optimized”. There is no workaround and you may have to check system settings every once in a while.
There is a bug report filed to OnePlus.

On some OnePlus phones there is also a thing called App Auto-Launch which essentially prevents apps working in the background. Please disable it for Sleep.

Also do:

Phone settings > Battery > Battery optimization > switch to the All apps list (Top menu) > Sleep > Don’t optimize

NOTE: Some of our users indicated that you need to disable Doze mode in Developer options.

OnePlus 5 specifically

Disable Settings > Battery > Battery optimization > (three dots) > Enhanced optimization. This option may also be called Advanced optimisation.

Samsung Galaxy

  1. S8 (and apparently also some older phones) has introduced a flawed attempt at prolonging battery life called “App power monitor“. For Sleep as Android to work correctly, please whitelist Sleep from App power monitor.How to do it:Open the Settings app > Device maintenance > Battery and at the bottom you’ll see a list of your most frequently used apps. You can sleep apps individually or in a group by selecting them then tapping the big SAVE POWER button. Apps that are sleeping will appear in the SLEEPING APPS list at the bottom (tap it to expand the list).Scrolling further — all the way to the very bottom — and you’ll find Unmonitored apps. These are apps that you specifically want to exclude (white list) from App power monitor. When inside the Unmonitored apps menu, you can tap the 3-dot menu to add or delete apps from the list.Rather than bothering with any of that, you can just turn off the App power monitor feature completely as it has little-to-no impact on battery life and only serves to handicap the normal functioning of your Galaxy phone. It’s excessive and in some cases downright misleading, using scare tactics to keep you reliant on Samsung’s software when other Android devices get by just fine without it.
  2. On other Samsung phones, the path may look like this:
    Phone settings > Applications > select three dot menu (top right corner) > Special Access > Optimize Battery usage > Find Sleep on the list and make sure that it is not selected.

NOTE: If you enable Edge Lighting for Sleep As Android, then Sleep As Android will not be able to wake up your screen when the alarm starts. To allow Sleep As Android to work as intended, please remove Sleep As Android from the Edge Ligthing applications list.

Xiaomi / MIUI

Xiaomi are the most troubled phones on the market. Chinese vendors tend to ignore Android best practices and implement very bizarre custom modifications which make background task nearly impossible to run.

The specific steps depend on which version of the MIUI do you have. Things to try:

  • BATTERY MANAGEMENT
    Please enable:

    • Settings > Advanced Settings > Battery manager > Power plan is set to Performance
    • Device Settings > Advanced Settings > Battery Manager > Protected apps – Sleep as Android needs to be Protected
    • Device Settings > Apps > Sleep as Android > Battery > Power-intensive prompt [x] and Keep running after screen off [x]..
  • BATTERY MANAGEMENT 2
    Settings > Additional Settings > Battery & Performance > Manage apps’ battery usage

    and here:
    1) Switch Power Saving Modes to Off
    2) Choose the next options: Saving Power in The Background > Choose apps > select ‘Sleep’ > Background Settings > No restrictions
  • APP BATTERY SAVER
    Security > Battery > App Battery Saver > Sleep as Android > No restriction

    then enable SaA to autostart in the security center
  • AUTOSTART
    (according to https://in.c.mi.com/thread-253478-1-0.html):

    • Open security app > permissions > auto-start
    • Enable Autostart for desired apps.
  • APP PINNING
    It really helps sleep tracking if you pin Sleep as Android. How to do it?
    When you open recent apps tray, just drag Sleep as Android downwards – it will be locked. So even if you clear recent apps it will not clear from the background. Drag downwards again to clear Sleep from the background.

If all fails, please try to set the app as device administrator (Sleep as Android > Setting > CAPTCHA >Prevent escaping CAPTCHA). This may also prevent the system from killing sleep tracking.

 

Meizu

Meizu are one of the most troubled phones on the market. Chinese vendors tend to ignore Android best practices and implement very bizarre custom modifications which make background task nearly impossible to run.

Please enable:
Settings > Advanced Settings > Battery manager > Power plan is set to Performance..
Device Settings > Advanced Settings > Battery Manager > Protected apps – check for Sleep as Android as Protected
Device Settings > Apps > Sleep as Android > Battery > Power-intensive prompt [x] and Keep running after screen off [x]..

If all fails, please try to set the app as device administrator (Sleep as Android > Setting > CAPTCHA >Prevent escaping CAPTCHA). This may also prevent the system from killing sleep tracking.

Sony

Sony Stamina Mode makes 3rd party alarms not work. There is no workaround from our side, please disable Stamina mode or whitelist our application.

Please go to your Phone settings > Battery > Three dots in the top right corner > Battery optimisation > Apps > Sleep.

Nokia

It seems under some circumstances Nokia behaves differently from standard Android and puts our app on the list of apps with background restrictions.

Take a look in Phone settings > Apps > Battery > Sleep as Android

  1. FORCE CLOSING THE APP: In case you force close the app, alarms won’t ring either. In this case it is necessary to restart the app in order to reschedule alarms. This may also happen if you are using task killer software or automated backup software.
  2. EMPTY BATTERY: Another reason may be that the device did run out of battery before the alarm time. To prevent this, we recommend putting the device into the charger for sleep tracking or increasing the battery level when we leave the phone on stand-by. Configure this in Settings → Sleep tracking → Stand-by.
  3. CRASH: On specific ROMs it may happen that the application crashed during sleep tracking which may also result in missed alarm. In general, features which are known to be sensitive for crashing on exotic firmwares include: wake up with light, noise recording, screen dimming. You may want to try to disable those features.

If none of the cases above apply to You, please send us a debug report (menu → report a bug) as soon as possible after you realize the alarm did not ring.