Simple service causes android whitescreen


#1

I added a very simple getter/setter service to my ionic application. It works perfectly with ionic serve, it works in the ios emulator, and yet it white screens in android emulation/running on android devices.

I will see the splash screen, followed by a white screen. I’ve tried every ‘fix’ I can find on the forums and elsewhere. I have narrowed it down to including this service.

Am I doing something incorrectly and am just blind to it after staring at it for so long? If I remove the service from the application dependencies and the locations the getters/setters are called in the code the android application will build and run perfectly.

When running ‘ionic emulate android -lcs’ the only error I was getting was “No Content-Security-Policy meta tag found. Please add one when using the cordova-plugin-whitelist plugin.” However after solving this error the problem persisted.

Here is the service:

angular.module('starter.articleService', [])

.service('selectedArticle', function () {
        var selection = 0;
    
        return {
            getValue: function () {
                return selection;
            },
            setValue: function (value) {
                selection = value;
            }
        };
    });

Any ideas?


#2

The solution was as simple as I expected it would be.

The path to the script containing the service was incorrect, I had the script src as “js/Services/articleservice.js” instead of “js/services/articleservice.js”

It seems odd to me that this doesn’t matter in browser, or in the iOS emulator but fails on android devices/android emulation.