Crash on notification and fails on image upload
Summary:
The app crash when ever I click on the Notification feature and I was unable to upload image, showing "Failed" most time I tried
Steps to reproduce:
Quite easy. Login and click on the "Notification" it crashes Also, the second issues is quite simple as I only tried to upload image.
Add System logs:
Device and Android version:
Tecno droid pad Android 5.0 1gb Ram and 16gb Rom
Screen-shots:

Would you like to work on the issue? I would have love to solve this issue but I am not a developer.
I will look into it. I am not able to reproduce it on Android 7.0 though. So I will try it on Android 5.0
OK, Thank you!
Ok I could reproduce this in Android 5.0 where it fails with following stack trace:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: fr.free.nrw.commons.beta, PID: 8726
java.util.regex.PatternSyntaxException: Unrecognized backslash escape sequence in pattern near index 4:
(^\h*)|(\h*$)
^
at java.util.regex.Pattern.compileImpl(Native Method)
at java.util.regex.Pattern.compile(Pattern.java:411)
at java.util.regex.Pattern.
Apparently '\h' pattern is not recognized by Pattern class in Android 5 but gets recognized in higher versions (atleast in Android 7.0).
There are two things here:
- I am not getting why replaceAll for whitespaces in front or end is required post trim() in here: notificationText = notificationText.trim().replaceAll("(^\h*)|(\h*$)", "");
- If I missed anything here and we need replaceAll then can we go with '\s' escape sequence which is working on both Android versions.
What do you think @misaochan ?
Thanks for the investigations @konohakesh . :)
- I believe we found trim() to be insufficient for tidying up whitespaces. AFAIK this was implemented by @maskaravivek - Vivek, do you recall why replaceAll was needed?
- I looked up https://developer.android.com/reference/java/util/regex/Pattern and it seems that indeed '\s' is the recommended character sequence for whitespace. Please feel free to go for it. :)
Also, I tried to upload image with Android 6.0 but the image failed (similar to the issue on 5.0) to upload after several attempt.
@tykees , what version of the app are you using? Could you check About and let us know please?
Latest version on F-driod
Strange that F-droid has not taken up 2.8.6 yet. I have been tagging releases and it is available here. Is there a delay for deployment?
Image upload failures were fixed in 2.8.5, so it is expected that you would experience failures, if you are running 2.8.4.
With what I can see, that update and release was 24hrs ago. The latest version on play store and F-driod is still 2.8.4, I will update once I can get the apk or any downloadable version of the app.
2.8.5, which does fix upload failures, was 19 days ago. I am a bit concerned that F-droid has not updated it?
The latest production version on the Play Store should be 2.8.5 too. Are you certain it is 2.8.4 for you? Could you try uninstalling and reinstalling your app? Sometimes the Play Store app caches and does not display the current version.
I had totally missed this second issue you are getting while image upload, at the time of reading the defect.
But now I went ahead and tried to reproduce it on Android 5, 6 and 7.0 . I could not reproduce it. So may be it is fixed as everyone else is saying. I will go ahead and create a PR for the earlier issue.
Has directed by @misaochan, I uninstall the one I downloaded from F-driod and I downloads from playstore. but, the issue still reoccur when I tried to upload.
@misaochan Are we ready to roll out 2.8.6 to all users? That way @tykees can share logs from his app. :)
@tykees Hmm. Could I please trouble you to do this:
- Opt in to beta testing at https://play.google.com/apps/testing/fr.free.nrw.commons
- Update to 2.8.6
- Go to Settings > Send log file
- Tap Send log file
- Restart your app
- Perform an upload
- After it fails, tap Send log file again
This will help us debug the cause of the failure for you. :)
@maskaravivek This is a tricky decision, and I eventually decided to leave 2.8.6 in beta. The reason is that from 1 Nov 2018, all app updates must target API 26 or higher, so this means that further hotfixes to 2.8-release are not possible without cherrpicking the API 26 fixes from master - i.e. time-consuming. 2.8.5 has been around for 20+ days now and is relatively stable, so I can reasonably trust that it will hold on til we can stabilize master for a release. I can't say the same of 2.8.6.
My rationale is that most people who would send logs to us anyway are already in beta testing or could be requested to sign up for beta testing.
Okey, thanks! Doing that now
Done!
Thanks @tykees !
@maskaravivek Please see the logs here. It seems to be a badtoken error.
error code="badtoken" info="The centralauthtoken is not valid."
Uploads have been refactored as a part of backend-overhaul, as the crash on notification click has already been merged. Closing this issue