Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caused by java.lang.NullPointerException: java.io.File.<init> (File.java:262) #910

Closed
andrepcg opened this issue Jun 30, 2017 · 12 comments
Closed

Comments

@andrepcg
Copy link

Description

React native app on Android fails to restart after an update, crashing.

Reproduction

Running a release version of an app, issuing a code push update makes device crash when applying the update.

Exception java.lang.RuntimeException: An error occurred while executing doInBackground()
android.os.AsyncTask$3.done (AsyncTask.java:318)
java.util.concurrent.FutureTask.finishCompletion (FutureTask.java:354)
java.util.concurrent.FutureTask.setException (FutureTask.java:223)
java.util.concurrent.FutureTask.run (FutureTask.java:242)
java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1133)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:607)
java.lang.Thread.run (Thread.java:762)
arrow_drop_down
Caused by java.lang.NullPointerException:
java.io.File.<init> (File.java:262)
com.microsoft.codepush.react.FileUtils.copyDirectoryContents (FileUtils.java:19)
com.microsoft.codepush.react.CodePushUpdateUtils.copyNecessaryFilesFromCurrentPackage (CodePushUpdateUtils.java:71)
com.microsoft.codepush.react.CodePushUpdateManager.downloadPackage (CodePushUpdateManager.java:226)
com.microsoft.codepush.react.CodePushNativeModule$3.doInBackground (CodePushNativeModule.java:230)
com.microsoft.codepush.react.CodePushNativeModule$3.doInBackground (CodePushNativeModule.java:224)
android.os.AsyncTask$2.call (AsyncTask.java:304)
java.util.concurrent.FutureTask.run (FutureTask.java:237)
java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1133)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:607)
java.lang.Thread.run (Thread.java:762)

Additional Information

  • react-native-code-push version: 3.0.0-beta
  • react-native version: 0.45.1
  • iOS/Android/Windows version: Android 7.0
  • Does this reproduce on a debug build or release build? Release
  • Does this reproduce on a simulator, or only on a physical device? Physical
@sergey-akhalkov
Copy link
Contributor

sergey-akhalkov commented Jun 30, 2017

Hi @andrepcg, I've just tried to reproduce the issue with the following repro steps but with no luck:

  1. build this sample app.zip in release mode
  2. install it on device
  3. release several CodePush updates
  4. open app on device, check for updates and install the latest one
  5. restart app
  6. update is applied with no errors

So could you please correct my repro steps or provide me with the minimal version of your app where the issue is reproduces? Also it would be helpful if you could provide me with the command you are using to release new updates and full release history.

@andrepcg
Copy link
Author

I found that it doesn't happen everytime. I've had this happen two times in two different builds but cannot find a pattern

@sergey-akhalkov
Copy link
Contributor

Got it, please let me know if any updates, I'll also try to perform other test cases and let you know if any changes.

@youanswer
Copy link

Having the similar issue on Android 6.0.1 device.

java.lang.RuntimeException An error occurred while executing doInBackground() 
    AsyncTask.java:309 android.os.AsyncTask$3.done
    FutureTask.java:354 java.util.concurrent.FutureTask.finishCompletion
    FutureTask.java:223 java.util.concurrent.FutureTask.setException
    FutureTask.java:242 java.util.concurrent.FutureTask.run
    ThreadPoolExecutor.java:1113 java.util.concurrent.ThreadPoolExecutor.runWorker
    ThreadPoolExecutor.java:588 java.util.concurrent.ThreadPoolExecutor$Worker.run
    Thread.java:818 java.lang.Thread.run

Caused: java.lang.NullPointerException Attempt to invoke virtual method 'char[] java.lang.String.toCharArray()' on a null object reference 
    File.java:183 java.io.File.fixSlashes
    File.java:130 java.io.File.<init>
    FileUtils.java:19 com.microsoft.codepush.react.FileUtils.copyDirectoryContents
    CodePushUpdateUtils.java:71 com.microsoft.codepush.react.CodePushUpdateUtils.copyNecessaryFilesFromCurrentPackage
    CodePushUpdateManager.java:226 com.microsoft.codepush.react.CodePushUpdateManager.downloadPackage
    CodePushNativeModule.java:230 com.microsoft.codepush.react.CodePushNativeModule$3.doInBackground
    CodePushNativeModule.java:224 com.microsoft.codepush.react.CodePushNativeModule$3.doInBackground
    AsyncTask.java:295 android.os.AsyncTask$2.call
    FutureTask.java:237 java.util.concurrent.FutureTask.run
    ThreadPoolExecutor.java:1113 java.util.concurrent.ThreadPoolExecutor.runWorker
    ThreadPoolExecutor.java:588 java.util.concurrent.ThreadPoolExecutor$Worker.run
    Thread.java:818 java.lang.Thread.run

@sergey-akhalkov
Copy link
Contributor

sergey-akhalkov commented Jul 3, 2017

Hey guys @andrepcg, @youanswer, @pinqy520, thanks for reaching us. Currently, we are trying to reproduce the issue and figure out why currentPackageFolderPath variable is null. In case we won't find the root cause of the issue, we'll implement workaround that will help us to avoid the issue - in case getCurrentPackageFolderPath() returns null, we are going to ask server for full package instead of diff, so we are going to avoid this condition and update should be applied without any exceptions.

Thanks for your patience and let me know if you have any questions or considerations.

@sergey-akhalkov
Copy link
Contributor

sergey-akhalkov commented Jul 3, 2017

Hey guys, could you please perform codePush.getCurrentPackage() method before codePush.sync and share us with its output (I mean share it in case when the issue reproduces)? This check relates to currentPackageFolderPath variable I've talked above and it could help us to investigate the issue.

@pinqy520
Copy link

pinqy520 commented Jul 3, 2017

@sergey-akhalkov i performed codePush.getCurrentPackage() method, and it returns null before the app crashes.

code:

(codePush as any).getCurrentPackage().then((r: any) => {
    fetch('http://faceparty.la/tt=' + JSON.stringify(r)) // send log to server
})
codePush.sync()

image

@sergey-akhalkov
Copy link
Contributor

sergey-akhalkov commented Jul 3, 2017

Hey guys @andrepcg, @youanswer, @pinqy520, @rj12info, could you please insert if (Platform.OS === "ios" && config.packageHash) { line in your node_modules/react-native-code-push/CodePush.js file instead of if (config.packageHash) {, rebuild your apk with this changes, release an update and let me know if the issue is still reproduces?

@didiercapozzi
Copy link

@sergey-akhalkov I can confirm you that your solution with if (Platform.OS === "ios" && config.packageHash) { worked fine for me.

@sergey-akhalkov
Copy link
Contributor

sergey-akhalkov commented Jul 3, 2017

Ok guys, I've created PR #911 and merged it to master, tomorrow we are going to produce patch releases v2.1.1 and v3.0.1 for react-native-code-push.

Please let me know if you have any questions/considerations or if the issue is still reproduces.

@max-mironov
Copy link
Contributor

Hi all, we just released hotfix both for v2.1.x and 3.0.x. Please let us know if you see any issues.

@sergey-akhalkov
Copy link
Contributor

Closing this for now, please feel free to reopen if the issue is still reproduce.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants