[Android] Crittercism でリアルタイムにクラッシュレポートを把握する

Thu, July 4, 2013 - 4 min read

Android アプリに、リアルタイムにクラッシュレポートを把握できる「Crittercism」というサービスを導入しました。

Crittercism | Mobile Application Performance Management



Crittercism - Installation Instructions



READ_LOGS パーミッションについては、ユーザの半分以上が Android 4.1 以上の端末を使っていたので、付与しませんでした。

Android 4.1 以上での動作について Android 4.1 (Jelly Bean) 以上の端末では、この設定を行わなくてもリモート LogCat は機能します。一方、セキュリティ上の理由から、アプリ自身のプロセスから出力されたログ以外は、参照することができません。

[引用]:リモートLogCatの有効化 - DeployGate


initCrittercism メソッドは、onCreate メソッドから呼び出します。

import com.crittercism.app.Crittercism;

 * Initialize Crittercism (Error reporting and monitoring tool.)
 * http://www.crittercism.com
private void initCrittercism() {
    JSONObject crittercismConfig = new JSONObject();
    try {
        // include version code in version name
        crittercismConfig.put("includeVersionCode", true);
        // necessary for collecting logcat data on Android Jelly Bean devices.
        crittercismConfig.put("shouldCollectLogcat", true);
    } catch (JSONException je) {

    Crittercism.init(getApplicationContext(), "", crittercismConfig);


proguard を使う場合は、下記の設定も追加しておきましょう。

-keep public class com.crittercism.**

-keepclassmembers public class com.crittercism.*

最後に、READ_LOGS パーミッションについてよく分からなくて、サポートに問い合わせた時の返信内容をメモ。


I’ll try to give you a brief tour of this permission and how it interacts with Crittercism.

Crittercism does not require the READ_LOGS permission in order to function correctly. However, by enabling this permission (where applicable), it can provide additional useful information with every crash and exception report that Crittercism receives.

The Android API:

The logs permission functions in two very different ways depending on the version of the Android API. For versions 15 and lower, any access to the logs requires this permission, and its inclusion gives complete access to all log entries.

As you mentioned, such a global permission poses a potential security risk, and at the very least raises questions about data separation. For this reason, starting in Jelly Bean (API version 16 and higher), Google changed its policy about log access.

After the policy change READ_LOGS no longer works for API Level 16 and higher. With these versions, each app has access to log entries generated by the app itself.

To enable logcat collection for newer devices, you need to include the following code in the onCreate() method of your main activity:

// create the JSONObject. (Do not forget to import org.json.JSONObject!) 
JSONObject crittercismConfig = new JSONObject(); 
crittercismConfig.put("shouldCollectLogcat", true); // send logcat data for devices with API Level 16 and higher 
catch (JSONException je){}

Crittercism.init(getApplicationContext(), "", crittercismConfig);

Does that answer your questions? For further details, please refer to our documentation, here https://app.crittercism.com/developers/docs-android#including_logcat .

Best regards,