# Crasheye SDK for Android

# Integration

# Create AppKey

Once you register and log in Crasheye, you can create your own app. Every app will have a unique AppKey to initialize the SDK, and to identify your app as well.( Download Sample (opens new window) )

Create new app:

  1. Log in Crasheye to access admin panel.
  2. Click the profile picture at the upper right corner of the page, and select [my apps] in the popup menu to access the list of your app.
  3. Click [new] in app list page.
  4. Name your app and choose a platform in the popup box. Click [yes]. A new app is created.

Keep your unique AppKey secured from misuse.

# Download SDK

Click Download Android SDKin SDK download page.。

# Import Dependent File

Copy [Crasheye.jar] from the downloaded SDK to [libs] folder in your project, and then open [libs] folder in Android Studio project. You will see the copied [Crasheye.jar] in it. Right click on it and select [Add As Library...] to import the file..

# Configuration

Configure permission settings (required) and channel information (optional) in AndroidManifest.xml, as demonstrated in the following code sample:

<!--Permission Configuration, Required>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.READ_LOGS" />

<application ……>
    <activity ……/>

        <!--Channel Information, Optional>
    <meta-data android:name="CRASHEYE_CHANNEL" android:value="Your_Channel"/>
</application>

# Initialize SDK

Crasheye only needs to add a line of code to complete the monitoring of APP exceptions.

It is recommended to add this initialization code after Application.onCreate() or MainActivity.onCreate(). The code example is as follows:

@override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Crasheye.init(this, "Your_AppKey");

}

At this point, the SDK access work on Android is complete.

# Test

Please test on a real device. If successful, data will be shown in admin panel in real time.

Start your application. You will see "init success!" and "ndk creah handler init success" shown on LogCat:



# Common APIs

Set channel number

You can set Channel ID in AndroidManifest.xml; Crasheye will read the settings and report to the server. Read more: Configuration

You can also call an API to set Channel ID without adding channel information in AndroidManifest.xml, as demonstrated in the following code sample:

@override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Crasheye.setChannelID("Your_Channel");
    Crasheye.init(this, "Your_AppKey");
}

Set App Version number

By default, Crasheye will read version information from android:versionName in AndroidManifest.xml. Of course you can also set app version by calling API.

@override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Crasheye.setAppVersion("Your_APP_Version");
    Crasheye.init(this, "Your_AppKey");
}

Set to report only in Wifi environment

In order to save the cellular data usage for the users, Crasheye offers an API to report stack trace of crashes only when the device is on wifi networks.

@override
public void onCreate(Bundle savedInstanceState) {
    // true: Report via WIFI only; false: Report via whatever connected network. Default value is false.
    super.onCreate(savedInstanceState);
    Crasheye.setFlushOnlyOverWiFi(true);
    Crasheye.init(this, "Your_AppKey");
}

Set user ID

You can assign User Identification to each reported issue to help filter and locate issues. Developer can use this method to filter crash issues reported by his own device.

Crasheye.setUserIdentifier(String userIdentifier);

Set the collection log
This API collects logs (LogCat) in runtime. When exception occurs, the collected logs will be saved and reported to server. (Maximum 1000 lines of the latest logs)

/**
* Set line limit and keyword to access logs
* @param lines	: lines of codes collected (1000 lines in maximum)
* @param filter	: Keyword(require = false), for example, using Crasheye as keyword is equivalent to entering "logcat -d Crasheye" in Logcat filter
*/
Crasheye.setLogging(int lines, String filter);

Add breadcrumbs (dotting info)

By leaving breadcrumbs (navigation information), you can capture the time and sequence of crashes and handled exceptions to keep track of if your app is working as intended. Call the following API where you want to monitor:

Crasheye.leaveBreadcrumb(String breadcrumb);

Add custom data

In case that you want to capture more data than the default setup does, you can call this API to add developer-defined text string to collect more information:

Crasheye.addExtraData(String key, String value);

Actively report script information interface

This API is for the convenience of developers. The caught exceptions of stack trace, such as lua and js script exception, will be reported to server. (In order to reduce repetitive reports, the same exception will only be reported once in 10 minutes)

/**
* Script exception reporting interface
* @param errorTile : title of script exception
* @param stacktrace : stack trace
* @param language : script language
*/
Crasheye.sendScriptException(String errorTitle, String stacktrace, String language);

Get device ID information

Device ID is accessible via this API. Users can filter the logs with device ID to find the matched exceptions of the device.

Crasheye.getCrasheyeUUID();

Set up a beta version

/**
* Set whether the version is the beta
* @param isBeta : true is beta version
*/
Crasheye.setIsBetaVersion(boolean isBeta)

# Mapping Upload

  1. Environment

    Java SE Runtime Environment 7 (opens new window) or later

  2. Preparation

a.Download Upload tool
b.mapping.txtfile path:

<project folder>/app/build/outputs/mapping/release/
  1. ** Mapping file Upload**

    Via website:

    1. Settings -> Symbols -> Mapping File Upload
    2. Select a matched app version
    3. Upload mapping file via website

    Via upload tool:

    1. Start the mapping file upload tool, and use the following command to upload:
    Parameters Meaning
    -appkey Appkey of the projectappkey
    [-veresion] app version (optional), read from AndroidManifest.xml by default
    [-AndroidManifestPath] AndroidManifest.xml file path (to get app version, being mutually exclusive with the parameter -version) (optional)
    [-mapping] mapping.txt file path
java -jar CrasheyeAndroidSymbol.jar -appkey=project's AppKey [-version=App version] [-AndroidManifestPath=AndroidManifest.xml path] -mapping=mapping.txt
Last Updated: 11/22/2022, 2:12:03 PM