question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

App crashes while reading file on android, Error: java.lang.NumberFormatException

See original GitHub issue

Versions:

"react-native-fetch-blob": "0.10.8"
"react-native": "0.49.5"

I was reading a file using this code:

RNFetchBlob.fs
      .readFile(filePath, "ascii")
      .then(data => {
        this.showProgressModal = true;
        ...
      }).catch(e){}

On Android device I got this error and app crashes:

java.lang.NumberFormatException: For input string: "raw:/storage/emulated/0/Download/Bittrexv1.csv"
                                                                             at java.lang.Long.parseLong(Long.java:590)
                                                                             at java.lang.Long.valueOf(Long.java:804)
                                                                             at com.RNFetchBlob.Utils.PathResolver.getRealPathFromURI(PathResolver.java:41)
                                                                             at com.RNFetchBlob.RNFetchBlobFS.normalizePath(RNFetchBlobFS.java:918)
                                                                             at com.RNFetchBlob.RNFetchBlobFS.readFile(RNFetchBlobFS.java:141)
                                                                             at com.RNFetchBlob.RNFetchBlob$6.run(RNFetchBlob.java:208)
                                                                             at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
                                                                             at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
                                                                             at java.lang.Thread.run(Thread.java:764)

PS. Its working fine on Android emulator and ios simulator. Haven’t tested on ios device yet. Please let me know if more information is needed to debug the issue, Thanks!

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:8

github_iconTop GitHub Comments

7reactions
khsilycommented, Jan 16, 2019

simple workaround just for now.

const filePath = item.uri.split('raw%3A')[1].replace(/\%2F/gm, '/');
RNFetchBlob.fs.readFile(filePath, 'utf8').then(...)
1reaction
navneet-kumarcommented, Mar 7, 2019

I am still facing this issue in "rn-fetch-blob": "^0.10.15" is it not yet merged to master ?

03-07 09:13:09.434 25287 25395 E AndroidRuntime: java.lang.NumberFormatException: For input string: "raw:/storage/emulated/0/Download/patients.json"
03-07 09:13:09.434 25287 25395 E AndroidRuntime: 	at java.lang.Long.parseLong(Long.java:590)
03-07 09:13:09.434 25287 25395 E AndroidRuntime: 	at java.lang.Long.valueOf(Long.java:804)
03-07 09:13:09.434 25287 25395 E AndroidRuntime: 	at com.RNFetchBlob.Utils.PathResolver.getRealPathFromURI(PathResolver.java:43)
03-07 09:13:09.434 25287 25395 E AndroidRuntime: 	at com.RNFetchBlob.RNFetchBlobFS.normalizePath(RNFetchBlobFS.java:1126)
03-07 09:13:09.434 25287 25395 E AndroidRuntime: 	at com.RNFetchBlob.RNFetchBlobFS.readFile(RNFetchBlobFS.java:154)
03-07 09:13:09.434 25287 25395 E AndroidRuntime: 	at com.RNFetchBlob.RNFetchBlob$6.run(RNFetchBlob.java:226)
03-07 09:13:09.434 25287 25395 E AndroidRuntime: 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
03-07 09:13:09.434 25287 25395 E AndroidRuntime: 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
03-07 09:13:09.434 25287 25395 E AndroidRuntime: 	at java.lang.Thread.run(Thread.java:764)
Read more comments on GitHub >

github_iconTop Results From Across the Web

android - application crashed with NumberFormatException
The reason you are getting this error is because the EditText is not created on the UI yet. But, you need the EditText...
Read more >
Crash in java.lang.NumberFormatException: For input string
I have checked for all usages of IconTabWidget as well as its functions and it is never used in order to add tabs...
Read more >
Detect and diagnose crashes - Android Developers
An app that is written using Java or Kotlin crashes if it throws an unhandled exception, represented by the Throwable class.
Read more >
java.lang.numberformatexception for input string null
By the way, this is not the application developer's fault. This is a data error and to solve this problem you need to...
Read more >
How to Fix with java.net.SocketException: Connection reset ...
This occurred when Server closed the connection, while the client is still waiting to read data from its InputStream. For example, if you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found