Reputation: 559
I'm using Cordova 4.2.0
and the plugin org.apache.cordova.splashscreen
.
My Android application runs and the plugin works. However, I can't hide the splash screen from inside my javascript file.
So, this works:
<preference name="SplashScreenDelay" value="10000"/>
This not works:
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
//{Angular app creation omitted here}
setTimeout(function() {
navigator.splashscreen.hide();
}, 10000);
}
I suspect this is happening because Android look for a file that does not exists in the specified folder.
02-12 12:09:37.561: E/AndroidProtocolHandler(27796): Unable to open asset URL: file:///android_asset/www/js/cordova_plugins.js
In fact the real path of the file is www/cordova_plugins.js
(inside assets folder on the Android project).
I tried call this file on my index.html
but another error is thrown (and the application does not starts):
02-12 12:16:32.100: E/AndroidProtocolHandler(30211): Unable to open asset URL: file:///android_asset/www/js/plugins/org.apache.cordova.splashscreen/www/splashscreen.js
And again the real path has not js/
prefix.
How I can fix this?
Upvotes: 0
Views: 1551
Reputation: 63
I faced the same issue today itself and @rcorreia has answered perfectly.
cordova.js and cordova_plugins.js should be in the same directory. Once you change the location of cordova.js, it will search in the same directory for the file cordova_plugins.js
If you are using the platform Android, files should be in YOUR_APP\platforms\android\platform_www
As suggested here,http://ngcordova.com/docs/install/
Include ng-cordova.js or ng-cordova.min.js in your index.html file before cordova.js and after your AngularJS / Ionic file (since ngCordova depends on AngularJS).
Quicker Solution : Just Install cordova, it will find and get the files automatically.
Hope it helps.
Upvotes: 1
Reputation: 559
Cordova was looking on the wrong folder because my onDeviceReady
call were done on js/cordova.js
, my custom file for Cordova things. There is a method on the library cordova.js
that search the folder of cordova.js
. The library uses the found folder to load the plugins. As my custom file had the same name, the library thought that the plugins folder was inside the js folder, when it was on root.
Upvotes: 0