Search code examples
cordovaapibuilddocuments

Reading documents does not work with new PhoneGap Build


can anyone help me with an issue I am having with PhoneGap. I built an app where it used to work fine on build 3.7.0 (default). Code that would read folder contents, etc would work fine. Now I tried compiling on the new default ver of 5.2.0 and this code does not work. Reading folders/files and writing folders/files does not work anymore. So I went to phonegap and uploaded a new version of my project with config.xml pointing to old ver of 3.7.0 and it does not even compile anymore on phonegap build.

Sample of the code that no longer works on the new PhoneGap Build (but used to work fine on 3.7.0):

var docPath;

document.addEventListener("deviceready", onDeviceReady, false);  

function onDeviceReady() {
    window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onFileSystemSuccess, onFail);
}

function onFileSystemSuccess(fileSystem) {
    docPath = fileSystem.root;
    fileSystem.root.getDirectory("Documents", { create: true, exclusive: true }, getDirSuccess, onFail);
}

function getDirSuccess(dirEntry) {
    alert(JSON.stringify(dirEntry));
    var directoryReader = dirEntry.createReader();
    directoryReader.readEntries(readerSuccess, onFail);
}

function readerSuccess(entries) {
    var i;
    for (i = 0; i < entries.length; i++) {
        alert(entries[i].name);
    }
}

Parts of my Config.xml file:

<access origin="*"/>
<preference name="SplashScreen" value="screen" />
<preference name="phonegap-version" value="3.7.0" />
<preference name="android-build-tool" value="ant" />

<preference name="orientation" value="portrait" />
<gap:plugin name="org.apache.cordova.battery-status" source="npm"/>
<gap:plugin name="org.apache.cordova.camera" source="npm"/>
<gap:plugin name="org.apache.cordova.media-capture" source="npm"/>
<gap:plugin name="org.apache.cordova.console" source="npm"/>
<gap:plugin name="org.apache.cordova.contacts" source="npm"/>
<gap:plugin name="org.apache.cordova.device" source="npm"/>
<gap:plugin name="org.apache.cordova.device-motion" source="npm"/>
<gap:plugin name="org.apache.cordova.device-orientation" source="npm"/>
<gap:plugin name="org.apache.cordova.dialogs" source="npm"/>
<gap:plugin name="org.apache.cordova.file" source="npm"/>
<gap:plugin name="org.apache.cordova.file-transfer" source="npm"/>
<gap:plugin name="org.apache.cordova.geolocation" source="npm"/>
<gap:plugin name="org.apache.cordova.globalization" source="npm"/>
<gap:plugin name="org.apache.cordova.inappbrowser" source="npm"/>
<gap:plugin name="org.apache.cordova.media" source="npm"/>
<gap:plugin name="org.apache.cordova.network-information" source="npm"/>
<gap:plugin name="org.apache.cordova.splashscreen" source="npm"/>
<gap:plugin name="org.apache.cordova.vibration" source="npm"/>
<gap:plugin name="cordova-plugin-flashlight" source="npm" />
<gap:plugin name="org.apache.cordova.console" source="npm"/>
<gap:plugin name="org.apache.cordova.network-information" source="npm"/>
<gap:plugin name="cordova-plugin-legacy-whitelist" source="npm" />

<icon src="icon.png"/>

<!-- for iOS -->
<feature name="Flashlight">
  <param name="ios-package" value="Flashlight" />
</feature>

<!-- for Android -->
<feature name="Flashlight">
  <param name="android-package" value="nl.xservices.plugins.Flashlight" />
</feature>

<!-- for WP8 -->
<feature name="Flashlight">
  <param name="wp-package" value="Flashlight" />
</feature>
</widget>

Any suggestions?


Solution

  • By removing all of the NPM plugins from cordova and putting the phonegap version on the top of my config.xml, and I commented out

    <content src="index.html" />
    

    and all of the "feature" parameters...I was able to upload to PhoneGap Build and compile using 3.7.0. However, reading document content is not working at this time.