I’m trying to use org.apache.cordova.file plugin but it fails on load time. I’m very surprised because I understand org.apache.cordova.file plugin is very common. I’ve tried different cordova plugin file versions and even cordova versions too but I’m not able to find a way to make it work. Probably, I’m missing some fundamental step but I’ve read many times the documentations and I did not find anything …
In order to ensure it is not related to my app, I’ve installed a clean ionic template and I’m having the same problem. If I run with "CordovaSim I see following error.
!JavaScript ERROR: SyntaxError: Unexpected token '?' on line 2 for http://localhost:50480/plugins/org.apache.cordova.file/www/FileWriter.js
If I start with an emulator I see following error.
Channel not fired: onFileSystemPathsReady
I’m able to easily reproduce the problem just executing following commands:
$ ionic -version
1.3.11
$ cordova -version
4.2.0
$ ionic start ionic-testfile -a 'TestFile' -i com.ionicframework.test.file tabs
Creating Ionic app in folder /Users/jcastro/workspace.picdeal/ionic-testfile based on tabs project
Downloading: https://github.com/driftyco/ionic-app-base/archive/master.zip
[=============================] 100% 0.0s
Downloading: https://github.com/driftyco/ionic-starter-tabs/archive/master.zip
[=============================] 100% 0.0s
Update config.xml
Initializing cordova project
…
$ cd ionic-testfile/
$ ionic plugin add org.apache.cordova.file
Fetching plugin "org.apache.cordova.file" via plugin registry
Running command: /Users/jcastro/workspace.picdeal/ionic-testfile/hooks/after_plugin_add/010_register_plugin.js /Users/jcastro/workspace.picdeal/ionic-testfile
$ ionic platform add android
Running command: /Users/jcastro/workspace.picdeal/ionic-testfile/hooks/before_platform_add/init_directories.js /Users/jcastro/workspace.picdeal/ionic-testfile
Creating android project...
…
Running command: /Users/jcastro/workspace.picdeal/ionic-testfile/hooks/after_plugin_add/010_register_plugin.js /Users/jcastro/workspace.picdeal/ionic-testfile
$ ionic emulate android -l -c
Setup Live Reload
…
Waiting for emulator...
HAX is working and emulator runs in fast virt mode
Booting up emulator (this may take a while).....BOOT COMPLETE
Installing app on emulator...
Using apk: /Users/jcastro/workspace.picdeal/ionic-testfile/platforms/android/ant-build/CordovaApp-debug.apk
Launching application...
LAUNCH SUCCESS
0 961179 log deviceready has not fired after 5 seconds.
1 961181 log Channel not fired: onFileSystemPathsReady
Just in case anyone else gets this issue I was able to make cordova plugin file works with Android/IOS emulators. Finally, I’m only having above problem with Cordovasim.
Currently I’m using following packages versions:
I was using Jboss CordovaSim to run my application and this was the source of my problem. I was not able to make Cordova File Plugin works with Jboss CordovaSim even with the default app created by ionic.
So, I’m not using anymore Jboss Cordovasim to emulate my app and I’m directly running it with Android emulator or IOS emulator. I do not make anything special in my app, just Cordova File plugin + cordovaFile from ngCordova. For example,
$cordovaFile.createDir(cordova.file.dataDirectory, registerDir, true)
.then(function (success) {
console.log('enterCode: dir created ' + JSON.stringify(success));
}, function (error) {
console.log('enterCode: dir not created ' + JSON.stringify(error));
});
I generated APK from the app, becuase of cordova file plugin issue. other plugins like Camera, IMEI, GeoLocation also not working in mobile. Please help me resolving the issue. I am stuck in this issue from past 5 days.
Sorry, I cannot help you. I was facing that issue only using Cordovasim emulator so I was just testing the app using IOS or Android emulator as a workaround