google / ground-android

Ground mobile data collection app for Android
http://groundplatform.org
Apache License 2.0
245 stars 116 forks source link

Fatal Crash trying to add data to a layer #1035

Closed atalekar closed 2 years ago

atalekar commented 2 years ago
Crash report
11-14 18:33:59.046 E AndroidRuntime: FATAL EXCEPTION: main
11-14 18:33:59.046 E AndroidRuntime: Process: com.google.android.gnd, PID: 18377
11-14 18:33:59.046 E AndroidRuntime: java.util.UnknownFormatConversionException: Conversion = 'End of String'
11-14 18:33:59.046 E AndroidRuntime:    at java.util.Formatter$FormatSpecifierParser.peek(Formatter.java:2642)
11-14 18:33:59.046 E AndroidRuntime:    at java.util.Formatter$FormatSpecifierParser.<init>(Formatter.java:2603)
11-14 18:33:59.046 E AndroidRuntime:    at java.util.Formatter.parse(Formatter.java:2558)
11-14 18:33:59.046 E AndroidRuntime:    at java.util.Formatter.format(Formatter.java:2505)
11-14 18:33:59.046 E AndroidRuntime:    at java.util.Formatter.format(Formatter.java:2459)
11-14 18:33:59.046 E AndroidRuntime:    at java.lang.String.format(String.java:2870)
11-14 18:33:59.046 E AndroidRuntime:    at timber.log.Timber$Tree.formatMessage(Timber.java:539)
11-14 18:33:59.046 E AndroidRuntime:    at timber.log.Timber$Tree.prepareLog(Timber.java:525)
11-14 18:33:59.046 E AndroidRuntime:    at timber.log.Timber$Tree.e(Timber.java:450)
11-14 18:33:59.046 E AndroidRuntime:    at timber.log.Timber$1.e(Timber.java:306)
11-14 18:33:59.046 E AndroidRuntime:    at timber.log.Timber.e(Timber.java:83)
11-14 18:33:59.046 E AndroidRuntime:    at com.google.android.gnd.ui.home.HomeScreenFragment.lambda$showAddFeatureDialog$2$HomeScreenFragment(HomeScreenFragment.java:183)
11-14 18:33:59.046 E AndroidRuntime:    at com.google.android.gnd.ui.home.-$$Lambda$HomeScreenFragment$UEv2Sa3uROhPYhyRlxY31dApYbM.accept(Unknown Source:6)
11-14 18:33:59.046 E AndroidRuntime:    at com.google.android.gnd.ui.home.AddFeatureDialogFragment.lambda$createDialog$3(AddFeatureDialogFragment.java:86)
11-14 18:33:59.046 E AndroidRuntime:    at com.google.android.gnd.ui.home.-$$Lambda$AddFeatureDialogFragment$4yjAqkqGQmGDn8kNQ2IE1NqyK4I.onClick(Unknown Source:4)
11-14 18:33:59.046 E AndroidRuntime:    at androidx.appcompat.app.AlertController$AlertParams$3.onItemClick(AlertController.java:1068)
11-14 18:33:59.046 E AndroidRuntime:    at android.widget.AdapterView.performItemClick(AdapterView.java:330)
11-14 18:33:59.046 E AndroidRuntime:    at android.widget.AbsListView.performItemClick(AbsListView.java:1197)
11-14 18:33:59.046 E AndroidRuntime:    at android.widget.AbsListView$PerformClick.run(AbsListView.java:3190)
11-14 18:33:59.046 E AndroidRuntime:    at android.widget.AbsListView.onTouchUp(AbsListView.java:4178)
11-14 18:33:59.046 E AndroidRuntime:    at android.widget.AbsListView.onTouchEvent(AbsListView.java:3919)
11-14 18:33:59.046 E AndroidRuntime:    at android.view.View.dispatchTouchEvent(View.java:14540)
11-14 18:33:59.046 E AndroidRuntime:    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3114)
11-14 18:33:59.046 E AndroidRuntime:    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2787)
11-14 18:33:59.046 E AndroidRuntime:    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3120)
11-14 18:33:59.046 E AndroidRuntime:    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2801)
11-14 18:33:59.046 E AndroidRuntime:    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3120)
11-14 18:33:59.046 E AndroidRuntime:    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2801)
11-14 18:33:59.046 E AndroidRuntime:    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3120)
11-14 18:33:59.046 E AndroidRuntime:    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2801)
11-14 18:33:59.046 E AndroidRuntime:    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3120)
11-14 18:33:59.046 E AndroidRuntime:    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2801)
11-14 18:33:59.046 E AndroidRuntime:    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3120)
11-14 18:33:59.046 E AndroidRuntime:    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2801)
11-14 18:33:59.046 E AndroidRuntime:    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3120)
11-14 18:33:59.046 E AndroidRuntime:    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2801)
11-14 18:33:59.046 E AndroidRuntime:    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3120)
11-14 18:33:59.046 E AndroidRuntime:    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2801)
11-14 18:33:59.046 E AndroidRuntime:    at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:502)
11-14 18:33:59.046 E AndroidRuntime:    at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1890)
11-14 18:33:59.046 E AndroidRuntime:    at android.app.Dialog.dispatchTouchEvent(Dialog.java:864)
11-14 18:33:59.046 E AndroidRuntime:    at androidx.appcompat.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:69)
11-14 18:33:59.046 E AndroidRuntime:    at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:460)
11-14 18:33:59.046 E AndroidRuntime:    at android.view.View.dispatchPointerEvent(View.java:14799)
11-14 18:33:59.046 E AndroidRuntime:    at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:6344)
11-14 18:33:59.046 E AndroidRuntime:    at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:6145)
11-14 18:33:59.046 E AndroidRuntime:    at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5623)
11-14 18:33:59.046 E AndroidRuntime:    at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:5680)
11-14 18:33:59.046 E AndroidRuntime:    at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:5646)
11-14 18:33:59.046 E AndroidRuntime:    at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:5811)
11-14 18:33:59.046 E AndroidRuntime:    at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:5654)
11-14 18:33:59.046 E AndroidRuntime:    at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:5868)
11-14 18:33:59.047 E AndroidRuntime:    at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5627)
11-14 18:33:59.047 E AndroidRuntime:    at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:5680)
11-14 18:33:59.047 E AndroidRuntime:    at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:5646)
11-14 18:33:59.047 E AndroidRuntime:    at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:5654)
11-14 18:33:59.047 E AndroidRuntime:    at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5627)
11-14 18:33:59.047 E AndroidRuntime:    at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:8558)
11-14 18:33:59.047 E AndroidRuntime:    at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:8509)
11-14 18:33:59.047 E AndroidRuntime:    at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:8478)
11-14 18:33:59.047 E AndroidRuntime:    at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:8681)
11-14 18:33:59.047 E AndroidRuntime:    at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:259)
11-14 18:33:59.047 E AndroidRuntime:    at android.os.MessageQueue.nativePollOnce(Native Method)
11-14 18:33:59.047 E AndroidRuntime:    at android.os.MessageQueue.next(MessageQueue.java:335)
11-14 18:33:59.047 E AndroidRuntime:    at android.os.Looper.loopOnce(Looper.java:161)
11-14 18:33:59.047 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:288)
11-14 18:33:59.047 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:7838)
11-14 18:33:59.047 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
11-14 18:33:59.047 E AndroidRuntime:    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
11-14 18:33:59.047 E AndroidRuntime:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)

To Reproduce Steps to reproduce the behavior:

  1. Launch app, join "sample project"
  2. add data --> "daily data"
  3. Observe crash.
gino-m commented 2 years ago

The line in HomeScreenFragment.showAddFeatureDialog causing this exception is:

            Timber.e("No permissions set on layer %s%", layer.getId());

The format string is invalid, which is what is causing the reported exception. That said, after the "add feature" fab is tapped, the the user shouldn't be able to select a layer to which they don't have permission to add features.

gino-m commented 2 years ago

@atalekar Also, showAddFeatureDialog is not checking whether the user has owners/manager role, in which case they should be able to add to all layers. I'll try to send a fix.

atalekar commented 2 years ago

I think the underlying reason why this was crashing is that the layer didn't have polygon or points selected. Currently the method in question requires any layer to collect either polygons or points - but the UI on web app allows it to be multiselect which allows you to select points only (default), polygons only, both points and polygons, neither. I should probably be a single one and required.

gino-m commented 2 years ago

The project not having any layers allowing contributors could add points or polygons exposed the issue, but it isn't the root case. I'm preparing an actual fix now - in the meantime I assume setting "Contributors can add..." on one or more layers resolved the issue for you?

gino-m commented 2 years ago

We spoke, this can be worked around by granting contributors the right to add points or polygons via the web app. #1044 will also require the data collectors to be granted "manager" access for the interim.