Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Crittercism not working on android service with separate process

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"/>
like image 249
Sanket Avatar asked Jul 02 '15 11:07

Sanket


1 Answers

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

like image 191
Sanket Avatar answered Oct 08 '22 04:10

Sanket