[ 
https://issues.apache.org/jira/browse/CB-7522?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jason Ginchereau updated CB-7522:
---------------------------------
    Labels: Android  (was: )

> Wrong file path leads to error code 1000 due to NullPointerException on 
> Android
> -------------------------------------------------------------------------------
>
>                 Key: CB-7522
>                 URL: https://issues.apache.org/jira/browse/CB-7522
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Plugin File
>    Affects Versions: 3.5.0
>         Environment: Android
>            Reporter: Leon
>            Priority: Minor
>              Labels: Android
>
> Hi,
> I am using Cordova version 3.5.0-0.2.6 and version 1.3.0 of the File plugin 
> on Ubuntu. 
> Yesterday I got error code 1000 (corresponds to UNKNOWN_ERR as defined in 
> android/FileUtils.java) when I tried the following JavaScript code on Samsung 
> S2 (GT-I9100) with Android 4.1.2:
> {code:title=my.js|borderStyle=solid}
> var sFileLocation = '/Android/data/<package name>/assets/';   
> sFileLocation += filesToRemove[nFile];
> fileSystem.root.getFile(
>       sFileLocation,
>       null,
>       function(entry) {
>               entry.remove( function() {
>                       console.log("file removed");
>               }, onError);
>       }, onGetFileError);
> {code}
> My investigation showed that the error code 1000 was caused by Java 
> NullPointerException from implentation of the method 
> fullPathForFilesystemPath in class *LocalFilesystem* because of the following 
> code:
> {code:title=LocalFilesystem.java|borderStyle=solid}
> private String fullPathForFilesystemPath(String absolutePath) {
>               if (absolutePath != null && 
> absolutePath.startsWith(this.fsRoot)) {
>                       return absolutePath.substring(this.fsRoot.length());
>               }
>               return null;
>       }
> {code}
> The specified path at JavaScript snippet starts with / but its prefix does 
> not match the root of dir so in Android the Java method  
> fullPathForFilesystemPath returns *null* and leads to error *1000* at the 
> JavaScript. 
> The +JavaScript snippet works fine+ if the path is specified using any of the 
> following formats: *"Android/data/<package name>/assets/"* or 
> *"/storage/sdcard0/Android/data/<package name>/assets/"*.
> It is not exactly a bug but it is very inconvenient and not developer 
> friendly. I did not find anything about this behaviour at the docuemntation 
> of the plugin. It will be much better if error code such 
> FileError.ENCODING_ERR (5) or even FileError.NOT_FOUND_ERR (1) is returned. 
> May we modify the Java code and to update the documentation to make it more 
> friendly for developers?
> Best regards,
> Leon



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org
For additional commands, e-mail: issues-h...@cordova.apache.org

Reply via email to