Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MailSender does not launch #1146

Closed
jefflongo opened this issue Dec 23, 2022 · 18 comments
Closed

MailSender does not launch #1146

jefflongo opened this issue Dec 23, 2022 · 18 comments
Labels

Comments

@jefflongo
Copy link

jefflongo commented Dec 23, 2022

Describe the bug
MailSender does not trigger after tapping notification. Notification is dismissed and exception is thrown in logcat.

ACRA configuration:

ACRA.init(this, new CoreConfigurationBuilder()
                .withBuildConfigClass(BuildConfig.class)
                .withReportFormat(StringFormat.JSON)
                .withLogcatArguments("-t", "100", "-v", "long", "-s", MYTAG1 + ":V", MYTAG2 + ":V",
                        MYTAG3 + ":V")
                .withPluginConfigurations(
                        new NotificationConfigurationBuilder()
                                .withTitle(getString(R.string.acra_notif_title))
                                .withText(getString(R.string.acra_notif_text))
                                .withChannelName(getString(R.string.app_name))
                                .withSendOnClick(true)
                                .build(),
                        new MailSenderConfigurationBuilder()
                                .withMailTo(getString(R.string.acra_developer_email))
                                .withReportAsFile(true)
                                .withReportFileName(getString(R.string.acra_file_name))
                                .withSubject(getString(R.string.acra_mail_subject))
                                .withBody(getString(R.string.acra_mail_body))
                                .build()
                )
        );

Logcat dump of exception:

Attempt to cast generated internal exception:
java.lang.ClassCastException: Cannot cast java.lang.String to java.util.ArrayList
at java.lang.Class.cast(Class.java:2479)
at android.os.BaseBundle.getValueAt(BaseBundle.java:405)
at android.os.BaseBundle.getValue(BaseBundle.java:374)
at android.os.BaseBundle.getArrayList(BaseBundle.java:1486)
at android.os.BaseBundle.getCharSequenceArrayList(BaseBundle.java:1529)
at android.os.Bundle.getCharSequenceArrayList(Bundle.java:1204)
at android.content.Intent.getCharSequenceArrayListExtra(Intent.java:9709)
at android.content.Intent.migrateExtraStreamToClipData(Intent.java:12784)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1799)
at android.app.ContextImpl.startActivity(ContextImpl.java:1145)
at android.app.ContextImpl.startActivity(ContextImpl.java:1116)
at android.content.ContextWrapper.startActivity(ContextWrapper.java:441)
at android.content.ContextWrapper.startActivity(ContextWrapper.java:441)
at org.acra.sender.EmailIntentSender.sendLegacy(EmailIntentSender.kt:104)
at org.acra.sender.EmailIntentSender.sendWithSelector(EmailIntentSender.kt:131)
at org.acra.sender.EmailIntentSender.send(EmailIntentSender.kt:64)
at org.acra.sender.ReportSender.send(ReportSender.kt:59)
at org.acra.sender.ReportDistributor.sendCrashReport(ReportDistributor.kt:101)
at org.acra.sender.ReportDistributor.distribute(ReportDistributor.kt:65)
at org.acra.sender.SendingConductor.sendReports(SendingConductor.kt:50)
at org.acra.scheduler.DefaultSenderScheduler.scheduleReportSending(DefaultSenderScheduler.kt:61)
at org.acra.scheduler.SchedulerStarter.scheduleReports(SchedulerStarter.kt:49)
at org.acra.receiver.NotificationBroadcastReceiver.onReceive(NotificationBroadcastReceiver.kt:72)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:4881)
at android.app.ActivityThread.-$$Nest$mhandleReceiver(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2417)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.app.ActivityThread.main(ActivityThread.java:8741)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)

Expected behavior
Gmail should open and draft an email bug report.

Version

  • Samsung S22+
  • Android: 13 (API 33)
  • ACRA 5.9.7
  • Compile SDK version: 33
  • Target SDK version: 33
  • Java
@rethinavelsmitch
Copy link

rethinavelsmitch commented Dec 23, 2022

Describe the bug:
MailSender does not trigger after displaying toast message., Working in Pixel4a and not working in OnePlus and Redmi Devices.

ACRA configuration:

initAcra {
          // core configuration:
          buildConfigClass = BuildConfig::class.java
          reportFormat = StringFormat.JSON

          toast {
              // required
              text = "Application Crashed, Logs will be sent to Developers"
              // defaults to Toast.LENGTH_LONG
              length = Toast.LENGTH_LONG
          }

          mailSender {
              // required
              mailTo = "[email protected]"
              reportAsFile = true
              reportFileName = "Crash.txt"
              subject = BuildConfig.APPLICATION_ID + " - " + BuildConfig.VERSION_NAME
              body = "Hey Velu, I found a crash in Recent Android APK, PFA. "
          }
      }

Device Specifications : One Plus Nord

@henrichg
Copy link

@jefflongo
If user has installed also another e-mail application, for example Samsung E-mail, the internal ReportSender working, is possible to send report with GMail.
And is not needed to configure Samsung E-mail for this (add account).

@JeanPaulLucien

This comment was marked as spam.

@yuriykulikov
Copy link
Contributor

Possibly related to #1118

@JeanPaulLucien

This comment was marked as spam.

@yuriykulikov
Copy link
Contributor

I am experiencing the same issue with 5.9.7, Pixel 6a, Android 13, Gmail. I can only see these suspicious lines in the logs:

2022-12-30 20:02:31.549 29618-29618 ACRA                    com.better.alarm.debug               I  Sending report /data/user/0/com.better.alarm.debug/app_ACRA-approved/2022-12-30T20:02:31.537+01:00-IS_SILENT.stacktrace
2022-12-30 20:02:31.560  1685-7546  PackageManager          pid-1685                             W  Intent does not match component's intent filter: Intent { act=android.intent.action.SEND flg=0x10000000 (has extras) sel=act=android.intent.action.SENDTO dat=mailto: flg=0x10000000} }
2022-12-30 20:02:31.560  1685-7546  PackageManager          pid-1685                             W  Access blocked: ComponentInfo{com.google.android.gm/com.google.android.gm.ComposeActivityGmailExternal}

@NLLAPPS
Copy link

NLLAPPS commented Feb 15, 2023

I have same issue and looks like it may be related to trampoline block. When I use Gmail as default Email, i get simila rlogs as above. When I change ot Outlook, I get "Indirect notification activity start (trampoline)"

Relevant logs:

START u0 {act=android.intent.action.SEND_MULTIPLE flg=0x10000000 cmp=com.microsoft.office.outlook/.compose.ComposeLauncherActivity (has extras) sel=act=android.intent.action.SENDTO dat=mailto: flg=0x10000000}} from uid 10453
Indirect notification activity start (trampoline) from xxxxxxxx blocked
Background activity start [callingPackage: xxxxxxxx; callingUid: 10453; appSwitchState: 2; isCallingUidForeground: false; callingUidHasAnyVisibleWindow: false; callingUidProcState: RECEIVER; isCallingUidPersistentSystemProcess: false; realCallingUid: 10453; isRealCallingUidForeground: false; realCallingUidHasAnyVisibleWindow: false; realCallingUidProcState: RECEIVER; isRealCallingUidPersistentSystemProcess: false; originatingPendingIntent: null; allowBackgroundActivityStart: false; intent: Intent { act=android.intent.action.SEND_MULTIPLE flg=0x10000000 cmp=com.microsoft.office.outlook/.compose.ComposeLauncherActivity (has extras) sel=act=android.intent.action.SENDTO dat=mailto: flg=0x10000000} }; callerApp: ProcessRecord{9f3a038 24969:xxxxxxxx:acra/u0a453}; inVisibleTask: false]
TaskLaunchParamsModifier:task=null activity=ActivityRecord{411c529 u0 com.microsoft.office.outlook/.compose.ComposeLauncherActivity} display-id=0 display-windowing-mode=1 suggested-display-area=DefaultTaskDisplayArea@177469868
TaskLaunchParamsModifier:task=Task{43e12c4 #656 type=standard A=10297:com.microsoft.office.outlook U=0 visible=false visibleRequested=false mode=fullscreen translucent=true sz=1} activity=ActivityRecord{411c529 u0 com.microsoft.office.outlook/.compose.ComposeLauncherActivity} t-1} display-from-task=0 display-id=0 display-windowing-mode=1 suggested-display-area=DefaultTaskDisplayArea@177469868 non-freeform-display display-area=DefaultTaskDisplayArea@177469868 maximized-bounds
Abort background activity starts from 10453 startActivity: reason=startActivityAsUser, result=102

@F43nd1r
Copy link
Member

F43nd1r commented Feb 16, 2023

@NLLAPPS that looks more like your app crashed outside of the context of an activity, in which case it won't be allowed to start anything in the foreground.

@NLLAPPS
Copy link

NLLAPPS commented Feb 16, 2023

Hi, crash was as soon as app main activity opened as test. Perhaps a little bit of delay required for framework to register visibility.

@yuriykulikov
Copy link
Contributor

yuriykulikov commented Apr 2, 2023

This PR #1170 by @grueni75 partially solves the issues on my devices (GMail is the only client). Thank you, @grueni75! However, attachments are not attached.

yuriykulikov added a commit to yuriykulikov/acra that referenced this issue Apr 2, 2023
Set intent type to message/rfc822 for GMail

This fixes ACRA#1146
@yuriykulikov
Copy link
Contributor

@F43nd1r what was the reason for using intent.selector? Was it because of gmail in 2021?

Perhaps the legacy function can replace the selector, with a minor tweak to get rid of deprecated use:

  private fun queryActivities(context: Context): MutableList<ResolveInfo> {
    val pm = context.packageManager
    return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
      pm.queryIntentActivities(
          buildSendToIntent(),
          PackageManager.ResolveInfoFlags.of(PackageManager.MATCH_DEFAULT_ONLY.toLong()))
    } else {
      @Suppress("DEPRECATION")
      pm.queryIntentActivities(buildSendToIntent(), PackageManager.MATCH_DEFAULT_ONLY)
    }
  }

@F43nd1r
Copy link
Member

F43nd1r commented Apr 8, 2023

Everybody please test with 5.9.8-beta01 - I have removed using selector intents on tiramisu. Need data on how this changes things for you.

@jefflongo
Copy link
Author

Just tried 5.9.8-beta02, still not working for me. Same error as in the OP with just gmail installed.

@F43nd1r
Copy link
Member

F43nd1r commented Apr 16, 2023

@jefflongo the stacktrace in OPs post is a red herring. This error is produced by android but it continues on to handle the string correctly as a string. If it's not working for you, look for other errors or warnings.

@jefflongo
Copy link
Author

jefflongo commented Apr 16, 2023

The only thing that comes after that is this:

Background activity start [callingPackage: com.jefflongo.redacted; callingUid: 10490; appSwitchState: 2; isCallingUidForeground: false; callingUidHasAnyVisibleWindow: false; callingUidProcState: RECEIVER; isCallingUidPersistentSystemProcess: false; realCallingUid: 10490; isRealCallingUidForeground: false; realCallingUidHasAnyVisibleWindow: false; realCallingUidProcState: RECEIVER; isRealCallingUidPersistentSystemProcess: false; originatingPendingIntent: null; allowBackgroundActivityStart: false; intent: Intent { act=android.intent.action.SEND_MULTIPLE typ=*/* flg=0x10000001 pkg=com.google.android.gm cmp=com.google.android.gm/.ComposeActivityGmailExternal clip={*/* {U(content)}} (has extras) }; callerApp: ProcessRecord{d0dded8 30892:com.jefflongo.redacted:acra/u0a490}; inVisibleTask: false]

and gmail does not launch. Sometimes when I re-open the app after the crash the notification will appear again and clicking it will sometimes open gmail.

@jefflongo
Copy link
Author

jefflongo commented Apr 16, 2023

Ok @F43nd1r I found some more information. There is a

Indirect notification activity start (trampoline) from com.example.acracrashdemo blocked

error in logcat after tapping "ok" on the notification to launch gmail. I was able to reproduce this with this demo application I made on an API 32 resizable emulator device. It's worth noting that on the API 33 resizable emulator device it worked properly.

Based on this information, it seems the bug is not about the MailSender (at least in the 5.9.8-beta02 release), but about launching the activity from a notification.

@jefflongo
Copy link
Author

@F43nd1r
Copy link
Member

F43nd1r commented Apr 19, 2023

@jefflongo this seems to be a different issue, please open a new one with these informations as visibility in here is limited but I also don't want to reopen this if it's not the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants