RequestFileSystem in Cordoba 3.4 with the error "Class not found"

hoping that someone could understand this, they fought this question all day. I am trying to browse folders in the file system to select a file, but I cannot connect to the file system.

When I call "window.requestFileSystem", the error callback returns a "Class not found" error. Turning to the Cordoba requestFileSystem function, I notice that the β€œClass not found” is returned during the call to exec () (where I cannot trace it). Has anyone overcame this problem or knew how to fix it? I know that it is listed in several forums, but the fixes offered there do not work for me.

As far as I can see, all the plugins are there. Installed using the Cordova CLI, they are displayed in the plugin folder. I really wonder if the plugin is uploaded, and not sure how I can verify this.

  • org.apache.cordova.console
  • org.apache.
  • cordova.device org.apache.cordova.file
  • org.apache.cordova.file transfer

Www / index.html

<body onload="onLoad();">
    <script type="text/javascript">
        // Init when we're good and ready.
        function onLoad(){document.addEventListener('deviceready', init, true);}

        // Init :)
        function init(){
            // window.requestFileSystem is recognized, so far so good.
            window.requestFileSystem(1, 0, function(fileSystem){
                alert('success');
            }, function(e){
                // 'e' is an object, {code: 'Class not found'}
                alert('Error accessing local file system');
            });
        }
    </script>
    <div class="app">
        <h1>Apache Cordova</h1>
        ...
    </div>

    <script type="text/javascript" src="cordova.js"></script>
</body>

config.xml

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.fwd.cwptakeonsheetsv1" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>CWPTakeOnSheetsV1</name>
    <description>
        A sample Apache Cordova application that responds to the deviceready event.
    </description>
    <author email="dev@cordova.apache.org" href="http://cordova.io">
        Apache Cordova Team
    </author>
    <content src="index.html" />
    <access origin="*" />



    <feature name="App">
        <param name="android-package" value="org.apache.cordova.App" />
    </feature>
    <feature name="Device">
        <param name="android-package" value="org.apache.cordova.device.Device" />
    </feature>
    <feature name="File">
        <param name="android-package" value="org.apache.cordova.file" />
        <param name="android-package" value="org.apache.cordova.file.FileUtils" />
        <param name="onload" value="true" />
        <param name="android-package" value="org.apache.cordova.FileUtils" />
    </feature>
    <feature name="FileTransfer">
        <param name="android-package" value="org.apache.cordova.filetransfer.FileTransfer" />
    </feature>
</widget>

Cordoba requestFileSystem.js

/**
 * Request a file system in which to store application data.
 * @param type  local file system type
 * @param size  indicates how much storage space, in bytes, the application expects to need
 * @param successCallback  invoked with a FileSystem object
 * @param errorCallback  invoked if error occurs retrieving file system
 */
var requestFileSystem = function(type, size, successCallback, errorCallback) {
    argscheck.checkArgs('nnFF', 'requestFileSystem', arguments);
    var fail = function(code) {
        errorCallback && errorCallback(new FileError(code));
    };

    if (type < 0) {
        fail(FileError.SYNTAX_ERR);
    } else {
        // if successful, return a FileSystem object
        var success = function(file_system) {
            if (file_system) {
                if (successCallback) {
                    // grab the name and root from the file system object
                    var result = new FileSystem(file_system.name, file_system.root);
                    successCallback(result);
                }
            }
            else {
                // no FileSystem object returned
                fail(FileError.NOT_FOUND_ERR);
            }
        };
        // The error happens in exec()
        exec(success, fail, "File", "requestFileSystem", [type, size]);
    }
};
+4
source share
3 answers

In the end, I solved my problem. Here are the steps I took to make it work:

  • Moved all JavaScript to the head-section of my index.html (including links to .js files).

  • I pulled out all the function tags from the config.xml file. My /platforms/android/AndroidManifest.xml still contains:

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    
  • alerts() . , , , , .

, window.requestFileSystem - undefined, , , JavaScript, .

- Ram .

@QuickFix !

0

, ( , ). :

/android.json "config.xml" "res/xml/config.xml".

, ( , Immersify), config.xml. , , "" platform/android/res/xml/config.xml, "class not found" .

+2

android.json, ? , " 3.4", sqlite, ( ). config.xml

+1

Source: https://habr.com/ru/post/1534671/


All Articles