Skip to content
New issue

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

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

Already on GitHub? # to your account

SenderService never called... #375

Closed
Ahmedfir opened this issue Feb 19, 2016 · 25 comments
Closed

SenderService never called... #375

Ahmedfir opened this issue Feb 19, 2016 · 25 comments

Comments

@Ahmedfir
Copy link

Hi, I think I missed something but I have a problem with setting up arca for my app.

I can see that neither the service or the sender were called. I followed the basic setup steps but couldn't get it to work. I defined my costum sender and a factory that initializes it... but none of these was called...

@Ahmedfir
Copy link
Author

@ReportsCrashes(
        formUri = AcraUtils.ACRA_SETUP_URL,
        mode = ReportingInteractionMode.SILENT,
        formUriBasicAuthLogin =AcraUtils.ACRA_SETUP_LOGIN ,
        formUriBasicAuthPassword = AcraUtils.ACRA_SETUP_PASSWORD,
        reportSenderFactoryClasses = {MyHttpSenderFactory.class},
        customReportContent = {ReportField.DEVICE_FEATURES, ReportField.PHONE_MODEL, ReportField.SETTINGS_SECURE, ReportField.INSTALLATION_ID, ReportField.SETTINGS_SYSTEM, ReportField.ANDROID_VERSION, ReportField.PACKAGE_NAME, ReportField.APP_VERSION_CODE, ReportField.CRASH_CONFIGURATION, ReportField.EVENTSLOG, ReportField.USER_CRASH_DATE, ReportField.DUMPSYS_MEMINFO, ReportField.STACK_TRACE, ReportField.PRODUCT, ReportField.DISPLAY, ReportField.APP_VERSION_NAME, ReportField.AVAILABLE_MEM_SIZE, ReportField.USER_APP_START_DATE, ReportField.CUSTOM_DATA, ReportField.BRAND, ReportField.TOTAL_MEM_SIZE, ReportField.FILE_PATH, ReportField.ENVIRONMENT, ReportField.REPORT_ID}
)
public class AcraSetupApplication extends Application {

  @Override
    public void onCreate() {

        super.onCreate();


        ACRA.init(this);


    }
}

here's my config.

@william-ferguson-au
Copy link
Member

How are you integrating ACRA? Ie is the ACRA Manifest and Proguard rules being automatically merged into those of your app? Recommended.

If so you should have the ACRA SenderService decalred in you generated AndroidManifest.
If not then you need to manually include the ACRA elements.
See https://github.com/ACRA/acra/wiki/BasicSetup#declaring-the-senderservice

@paulpv
Copy link

paulpv commented Feb 23, 2016

I'm in the same boat as @Ahmedfir.
I am debug stepping through the ACRA code, and I see where SenderServiceStarter.startService in called, but a breakpoint at the beginning of SenderService.onHandleIntent is never hit.

I am upgrading from 4.6.2 to 4.8.2, and my previous configuration worked fine and the new one has changed very little (effectively not at all).
My Application subclass has the @ReportsCrashes annotation, and here is my initialization code:

protected void initializeCrashReporting()
{
    if (BuildConfig.DEBUG)
    {
        ACRA.DEV_LOGGING = true;
    }

    ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(this);

    configurationBuilder
            .setLogcatArguments(new String[]
                    {
                            "-t", "250",
                            "-v", "threadtime"
                    })
            .setLogcatFilterByPid(false)
            .setCustomReportContent(new ReportField[]
                    {
                            ReportField.PACKAGE_NAME,
                            ReportField.APP_VERSION_NAME,
                            ReportField.APP_VERSION_CODE,
                            ReportField.ANDROID_VERSION,
                            ReportField.BRAND,
                            ReportField.PHONE_MODEL,
                            ReportField.PRODUCT,
                            ReportField.TOTAL_MEM_SIZE,
                            ReportField.AVAILABLE_MEM_SIZE,
                            ReportField.DEVICE_ID,
                            ReportField.INSTALLATION_ID,
                            ReportField.REPORT_ID,
                            ReportField.USER_APP_START_DATE,
                            ReportField.USER_CRASH_DATE,
                            ReportField.USER_COMMENT,
                            ReportField.THREAD_DETAILS,
                            ReportField.STACK_TRACE,
                            ReportField.LOGCAT
                    });

    // https://github.com/ACRA/acra/wiki/Report-Destinations#sending-reports-to-your-own-self-hosted-script
    configurationBuilder
            // https://github.com/ACRA/acra/wiki/Report-Destinations#postput-request
            .setHttpMethod(Method.PUT)
            .setFormUri(getString(R.string.crash_report_url))
            .setFormUriBasicAuthLogin(getString(R.string.crash_report_username))
            .setFormUriBasicAuthPassword(getString(R.string.crash_report_password))
            .setReportType(Type.JSON);

    ACRAConfiguration configuration;

    try
    {
        if (true)
        {
            configurationBuilder
                    .setSendReportsAtShutdown(false)
                    .setForceCloseDialogAfterToast(true)
                    .setReportingInteractionMode(ReportingInteractionMode.SILENT);
        }
        else
        {
            configurationBuilder
                    .setResDialogTitle(R.string.crash_dialog_title)
                    .setResDialogText(R.string.crash_dialog_text)
                    .setResDialogCommentPrompt(R.string.crash_dialog_comment_prompt)
                    .setResDialogEmailPrompt(R.string.crash_dialog_email_prompt)
                    .setResDialogOkToast(R.string.crash_dialog_ok_toast)
                    .setReportingInteractionMode(ReportingInteractionMode.DIALOG);
        }

        configuration = configurationBuilder.build();
    }
    catch (ACRAConfigurationException e)
    {
        PbLog.e(TAG, "initializeCrashReporting: EXCEPTION", e);
        configuration = null;
    }

    if (configuration != null)
    {
        ACRA.init(this, configuration, true);
    }
}

@paulpv
Copy link

paulpv commented Feb 23, 2016

Also, I removed any custom crash fields from my manifest and I am using the default manifest and proguard merge (I'm running debug anyway, so proguard is not relevant right now).

@paulpv
Copy link

paulpv commented Feb 23, 2016

FYI, a breakpoint in the SenderService is never even hit

@paulpv
Copy link

paulpv commented Feb 23, 2016

In the debugger I can see the SenderService process being started, and switching to it shows logging output, so it looks like it is not hitting my breakpoints due to a process issue.
The log output is :

...
02-23 14:33:07.736 3638-3670/? D/ACRA: About to start sending reports from SenderService
02-23 14:33:07.737 3638-3670/? D/ACRA: com.pebblebee.app.hive reports will be sent by Http.
02-23 14:33:07.738 3638-3670/? D/ACRA: Finished sending reports from SenderService
...

I will change the manifest process to use the main app process to see what is going on...

@william-ferguson-au
Copy link
Member

@paulpv debugging won't help because the SenderService is started in a new process.

@paulpv
Copy link

paulpv commented Feb 23, 2016

Weird! I edited my manifest to override the SenderService:

        <service
            android:name="org.acra.sender.SenderService"
            android:exported="false"
            />
        <!--
            android:process=":acra"
            -->

...and the generated manifest still has it in there!

        <service
            android:name="org.acra.sender.SenderService"
            android:exported="false"
            android:process=":acra" />
        <!-- android:process=":acra" -->

@paulpv
Copy link

paulpv commented Feb 23, 2016

I do see in the code where you test that the service is running under the process name ":acra":
https://github.com/ACRA/acra/blob/master/src/main/java/org/acra/ACRA.java#L270

So, I will have to fork the code to test this out much further...

@william-ferguson-au
Copy link
Member

@paulpv
SenderService is declared in the AndroidManifest for ACRA. So if you are using Manifest merging in your build then it will be automatically added.

@paulpv
Copy link

paulpv commented Feb 23, 2016

@william-ferguson-au Understood, but by defining it a second time in my manifest I should be overriding the values.
The reason it isn't removing the process name is because I wasn't using tools:remove="android:process":

        <service
            android:name="org.acra.sender.SenderService"
            android:exported="false"
            tools:remove="android:process"
            />
        <!--
            android:process=":acra"
            -->

I still need to tweak the code to get it to run without the hard coded ":acra" process name, and perhaps a little other logic.
I'll send you a PR w/ some recommendations.

@paulpv
Copy link

paulpv commented Feb 24, 2016

Has the "Approved Reports" logic changed since 4.6.2?
The service isn't seeing any approved reports.
I am running in SILENT mode, so I would expect all reports to automatically be approved.
I also added to my ACRA configuration:

                configurationBuilder
                        .setSendReportsAtShutdown(false)
                        .setForceCloseDialogAfterToast(true)
                        .setDeleteOldUnsentReportsOnApplicationStart(false)
                        .setDeleteUnapprovedReportsOnApplicationStart(false)
                        .setReportingInteractionMode(ReportingInteractionMode.SILENT);

@william-ferguson-au
Copy link
Member

The logic of approved reports hasn't changed, but the location and naming convention has.
Reports are now separated into 2 folders: approved and unapproved.

@paulpv
Copy link

paulpv commented Feb 24, 2016

I see several unapproved crash reports in app_ACRA-unapproved.
I'm trying to find in the code what moves them to app_ACRA-approved during startup...

@paulpv
Copy link

paulpv commented Feb 24, 2016

@william-ferguson-au I'm curious: How do you debug this w/ the SenderService being a separate process?

@william-ferguson-au
Copy link
Member

I stopped wasting time with a debugger back in about 1992.

I diagnose with logging. Good logging will tell you everything you need, even well after the fact. If its not good logging then it needs to be amended.

This https://github.com/ACRA/acra/blob/master/src/main/java/org/acra/sender/SenderService.java#L48 is the only thing that would move those reports to approved during startup. But if they were silent reports then they should have been pushed to approved when they were created.

@paulpv
Copy link

paulpv commented Feb 24, 2016

Hmmm...
My sendReportsAtShutdown is configured to be false.
I am expecting reports to be sent at startup.
But...
https://github.com/ACRA/acra/blob/master/src/main/java/org/acra/builder/ReportExecutor.java#L178
...endApplication is being called before the only thing that I can find that approved reports: https://github.com/ACRA/acra/blob/master/src/main/java/org/acra/builder/ReportExecutor.java#L187
startSendingReports(sendOnlySilentReports, true);

@william-ferguson-au
Copy link
Member

OK, it's possible that slipped through with the reorg. Want to provide a PR for it?
Is there a particular reason you are not sending at shutdown/

@paulpv
Copy link

paulpv commented Feb 24, 2016

In the past I had seen problems w/ crashes failing to be sent during shutdown.

@paulpv
Copy link

paulpv commented Feb 24, 2016

I'd provide a PR if the precise intricacies of how to handle the exception in ReportExecutor were clear to me.
I'll see if I can figure out a clean solution...

@william-ferguson-au
Copy link
Member

OK

  1. At least create an issue for it providing enough details that I can replicate.
  2. The reason that there were sometime problems sending crashes at shutdown were because the VM was already in a bad / failing /shutting down state. Starting up the SenderService in a new process resolves that.

@romansl
Copy link
Contributor

romansl commented Feb 24, 2016

For debugging you can use Android Studio or IDEA. Menu Run -> Attach debugger to Android process -> (you package):acra.

@william-ferguson-au
Copy link
Member

OK @paulpv I'm going to close this issue because I think we are all in agreement that SenderService is being called.

If setSendReportsAtShutdown(false) is causing silent reports to not be queued for sending on restart, then could you raise an issue for it with the relevant details to reproduce.

@paulpv
Copy link

paulpv commented Feb 25, 2016

@william-ferguson-au will do later today, but I can't say for sure if @Ahmedfir's issue was related to this. He is not setting setSendReportsAtShutdown to false.

@paulpv
Copy link

paulpv commented Feb 26, 2016

@william-ferguson-au I didn't have time today to work on my ACRA stuff. Tomorrow is another day.

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

No branches or pull requests

4 participants