You must specify a resource ID or literal value

264 views Asked by At

Halo everyone, I have a problem material-dialog in kotlin an gives error "You must specify a resource ID or literal value". Where is the problem, thanks.

in class;

  override fun dataPushError(throwable: Throwable) {
    MaterialDialog(requireContext()).show {
      icon(R.drawable.ic_error)
      title(R.string.gagal_menyimpan_data)
      message(text = throwable.message)
    }
  }

error capture

Error Log

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: id.dasawisma.android, PID: 10888
    java.lang.IllegalArgumentException: message: You must specify a resource ID or literal value
        at com.afollestad.materialdialogs.utils.MDUtil.assertOneSet(MDUtil.kt:328)
        at com.afollestad.materialdialogs.MaterialDialog.message(MaterialDialog.kt:174)
        at com.afollestad.materialdialogs.MaterialDialog.message$default(MaterialDialog.kt:172)
        at id.dasawisma.android.ui.main.bangunan_basic.BangunanBasicFragment.dataPushError(BangunanBasicFragment.kt:636)
        at id.dasawisma.android.core.base.fragment.BaseDataFetchPushFragment$onViewCreated$$inlined$observe$1.onChanged(LiveData.kt:64)
        at androidx.lifecycle.LiveData.considerNotify(LiveData.java:133)
        at androidx.lifecycle.LiveData.dispatchingValue(LiveData.java:151)
        at androidx.lifecycle.LiveData.setValue(LiveData.java:309)
        at androidx.lifecycle.LiveData$1.run(LiveData.java:93)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7656)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
D/TransportRuntime.JobInfoScheduler: Upload for context TransportContext(cct, DEFAULT, MSRodHRwczovL2ZpcmViYXNlbG9nZ2luZy1wYS5nb29nbGVhcGlzLmNvbS92MS9maXJlbG9nL2xlZ2FjeS9iYXRjaGxvZ1xBSXphU3lDY2traUg4aTJaQVJ3T3MxTEV6RktsZDE1YU9HOG96S28=) is already scheduled. Returning...
V/StudioTransport: Handling agent command 1200 for pid: 10888.
I/Process: Sending signal. PID: 10888 SIG: 9
1

There are 1 answers

0
Martin Zeitler On

You're constructing the dialog wrongfully, by not chaining the setters for title & message:

MaterialDialog(requireContext())
  .title(R.string.your_title)
  .message(R.string.your_message)
  .icon(R.drawable.your_icon)
  .show()

For reference: https://github.com/zubairehman/BaseDialogs