9

I have an application which starts android service in separate process. By that mean two processes are running. One is my main application and another is service.

Now I tried to integrate crittercism (it's a Mobile Application Performance Management tool) in by below approaches but it is not able to generate crash log for service.

  1. Integrate crittercism in app only.

    Result : It generates crash log for app only, not for service.

  2. Integrate crittercism in service in onCreate() method.

    Result : It is not showing crash log and also not showing app load in live stats.

  3. Integrate crittercism in both app and service.

    Result : It generates crash log for app only not for service.

So how do I get crash log for android service?

Here is the code by which I have implemented:

MainApplication.java

public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);

    Crittercism.initialize(getApplicationContext(), "CRITTERCISM_APP_ID");
}

MyService.java

public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);

    Crittercism.initialize(getApplicationContext(), "CRITTERCISM_APP_ID"); // Same app id which is used for MainApplication.java
}

build.gradle file of both service and main application:

dependencies {
    compile 'com.crittercism:crittercism-android-agent:5.0.6'
}

Also added below permission for both service and main application

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
4
  • #3 should be the right answer, as you would need to set this stuff up in both processes. You might consider posting your code where you configure Crittercism, and perhaps we can suggest some changes. Jul 2, 2015 at 12:00
  • @CommonsWare I have updated my question with code...
    – Sanket
    Jul 2, 2015 at 12:11
  • Hey there - one of the founders of Crittercism here, can you send a note to support@crittercism.com? Jul 2, 2015 at 15:10
  • @crittercismrob I already have sent a note to support@crittercism.com.
    – Sanket
    Jul 3, 2015 at 4:26

1 Answer 1

4

I got reply from Crittercism community and below is their reply:

The crashes cannot be captured in a remote service and because its Android issue. We also do not count app loads in remote services but other data is collected: HE, Network, etc. Crittercism counts actual app loads only.

One possible work around is to manually wrap all of the top level methods in the service in a try/catch block. In the catch block, use Crittercism.logHandledException.

Here's an example:

try {
customersTopLevelMethod();
} catch (Throwable t) {
Crittercism.logHandledException(t);

// You probably want to rethrow the exception since the service will now
// be in an invalid state.
throw t;
}

Here is the link too - http://community.crittercism.com/questions/1210/crittercism-not-working-on-android-service-with-se.html#answer-1217

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.