onnela-lab / beiwe-android

Beiwe is a smartphone-based digital phenotyping research platform. This is the Beiwe Android app code. The Beiwe2 app is also available on the Google Play store to use with open source builds of the Beiwe backend.
https://www.beiwe.org/
BSD 3-Clause "New" or "Revised" License
26 stars 17 forks source link

NPE at TextFileManager.throwGetterError inside handleIncomingMMS #42

Closed zagorsky closed 6 years ago

zagorsky commented 6 years ago

We got at least 300 of these from at least 20 users through the Google Play Store. All of them running app version 24 (2.2.5) or below; 24 is the current public version on Google Play.

java.lang.RuntimeException: 
  at android.app.ActivityThread.handleReceiver (ActivityThread.java:3357)
  at android.app.ActivityThread.-wrap20 (ActivityThread.java)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1734)
  at android.os.Handler.dispatchMessage (Handler.java:102)
  at android.os.Looper.loop (Looper.java:154)
  at android.app.ActivityThread.main (ActivityThread.java:6688)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1468)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1358)
Caused by: java.lang.NullPointerException: 
  at org.beiwe.app.storage.TextFileManager.throwGetterError (TextFileManager.java:67)
  at org.beiwe.app.storage.TextFileManager.checkAvailableWithTimeout (TextFileManager.java:109)
  at org.beiwe.app.storage.TextFileManager.getTextsLogFile (TextFileManager.java:77)
  at org.beiwe.app.listeners.SmsReceivedLogger.handleIncomingMMS (SmsReceivedLogger.java:60)
  at org.beiwe.app.listeners.SmsReceivedLogger.onReceive (SmsReceivedLogger.java:35)
  at android.app.ActivityThread.handleReceiver (ActivityThread.java:3350)

At version 24, here's SmsReceivedLogger.java line 60: https://github.com/onnela-lab/beiwe-android/blob/ad51ac75476832ff4d0fb8e8470288756ed1c469/app/src/main/java/org/beiwe/app/listeners/SmsReceivedLogger.java#L60

And here's TextFileManager.java line 67: https://github.com/onnela-lab/beiwe-android/blob/ad51ac75476832ff4d0fb8e8470288756ed1c469/app/src/main/java/org/beiwe/app/storage/TextFileManager.java#L67

sesterki commented 6 years ago

This error comes from the Background Service not running. Since it is now being restarted whenever it stops, this error should be less frequent. commit 6688eb03f54fc7f70fdb8a52209f04f2dcaa59c1 gives the TextFileManager a little more time before it errors. If an error does happen something bigger has gone wrong.

zagorsky commented 6 years ago

Should be fixed. If this error appears again in app version 2.4.1 or higher, we'll reopen this issue.