cordova-plugin-autostart
cordova-plugin-autostart copied to clipboard
Java.lang.RuntimeException
Hello, trying to use your plugin, on a Tablet, Android 6.0.1
I'm getting :
07-20 16:11:36.928 6027 6027 E AndroidRuntime: java.lang.RuntimeException: Unable to start receiver com.tonikorin.cordova.plugin.autostart.BootCompletedReceiver: java.lang.StringIndexOutOfBoundsException: length=0; regionStart=0; regionLength=-1
my simple code :
var myTextArea='';
var app = { initialize: function() { this.bindEvents(); }, bindEvents: function() { document.addEventListener('deviceready', this.onDeviceReady, false); }, onDeviceReady: function() { main(); } };
app.initialize();
function main() { myPrint('> AST: AutoStart Test / main()'); cordova.plugins.autoStart.enable(); myPrint('<< main()'); } function $(id){return document.getElementById(id);} function myPrint(str){ myTextArea+=str+'\n'; $('id-textarea').innerHTML = myTextArea; }
Thanks a lot in advance.
This might be the same issue I had, certainly the same Exception code (StringIndexOutOfBoundsException). My error came from line 48 in AppStarter.java.
String servicePackageName = serviceClassName.substring(0, serviceClassName.lastIndexOf("."));
Here the serviceClassName
was empty, hence the error, trying to substring from 0 to -1;
For now I just wrapped it around try-catch
String servicePackageName = "";
try {
servicePackageName = serviceClassName.substring(0, serviceClassName.lastIndexOf("."));
} catch (Exception e) {
//TODO: handle exception
Log.d("MyDebug", "Error in setting servicePackageName");
}