getodk / collect

ODK Collect is an Android app for filling out forms. It's been used to collect billions of data points in challenging environments around the world. Contribute and make the world a better place! ✨📋✨
https://docs.getodk.org/collect-intro
Other
718 stars 1.38k forks source link

Attempt to invoke virtual method 'java.lang.String org.odk.collect.forms.Form.getFormMediaPath()' on a null object reference #4895

Closed grzesiek2010 closed 2 years ago

grzesiek2010 commented 2 years ago

Software and hardware versions

Collect v2021.3.0

Problem description

https://console.firebase.google.com/u/2/project/api-project-322300403941/crashlytics/app/android:org.odk.collect.android/issues/be730c9d272352bd5b8685ab0d197899?time=last-seven-days&versions=v2021.3.0%20(4316)&sessionEventKey=6184E33F02B600015883C970B2D53C78_1605436904284051748

Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String org.odk.collect.forms.Form.getFormMediaPath()' on a null object reference
       at org.odk.collect.android.utilities.FormUtils.getMediaFiles(FormUtils.java:20)
       at org.odk.collect.android.formmanagement.ServerFormsDetailsFetcher.areNewerMediaFilesAvailable(ServerFormsDetailsFetcher.java:130)
       at org.odk.collect.android.formmanagement.ServerFormsDetailsFetcher.fetchFormDetails(ServerFormsDetailsFetcher.java:86)
       at org.odk.collect.android.tasks.DownloadFormListTask.doInBackground(DownloadFormListTask.java:63)
       at org.odk.collect.android.tasks.DownloadFormListTask.doInBackground(DownloadFormListTask.java:39)
       at android.os.AsyncTask$3.call(AsyncTask.java:378)
       at java.util.concurrent.FutureTask.run(FutureTask.java:266)
       at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:289)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
       at java.lang.Thread.run(Thread.java:929)

Steps to reproduce the problem

  1. Upload a simple form with media files to Central and download it in Collect
  2. Update the form bumping its version and download in Collect
  3. Fill one form and save it
  4. Delete the newer version of the form
  5. Try to open the list of forms to download

The app doesn't crash but loads and loads and in logs I get the same NPE

If you have a form but without media files and you do the same, then there is no crash or infinitive loading but the message that an update is available is not visible what is also a bug.

I used this form: formTest.zip

grzesiek2010 commented 2 years ago

The crash still occurs https://console.firebase.google.com/u/2/project/api-project-322300403941/crashlytics/app/android:org.odk.collect.android/issues/be730c9d272352bd5b8685ab0d197899?time=last-seven-days&versions=v2021.3.1%20(4320)&sessionEventKey=618BDAC9035500011273D05239EB50C5_1607300143708503704

There must be different steps to reproduce it but the stacktrace is the same.