The Raygun4Android provider

Raygun4Android is a library that you can easily add to your Android app, which will then allow you to transmit all exceptions to your Raygun.io dashboard. Installation is painless, and configuring your site to transmit errors takes less than five minutes.

Raygun4Android supports all devices with Gingerbread and newer installed (2.3/API v9). It can be added as a Maven dependency in your pom.xml, or manually adding the JAR to your project if you use Ant or other build tools.

Installation

With Maven

To your pom.xml, add:

<dependency>
    <groupId>com.mindscapehq.android</groupId>
    <artifactId>raygun4android</artifactId>
    <version>1.0.3</version>
</dependency>

In your IDE, build your project (or run mvn compile), then see the configuration section below.

With Gradle/Android Studio

To a build.gradle file, add:

repositories {
    ...
    mavenCentral()
}
dependencies {
    ...
    compile 'com.google.code.gson:gson:2.1'
    compile 'com.mindscapehq.android:raygun4android:1.2.0'
    compile 'com.mindscapehq.android:raygun4android:1.2.0:sources'
}

After syncing the Raygun package will be accessible to import. For Gradle, you may need to add the following specific imports to your class, where you wish to use RaygunClient:

import main.java.com.mindscapehq.android.raygun4android.RaygunClient;
import main.java.com.mindscapehq.android.raygun4android.messages.RaygunUserInfo;

With Ant, other build tools, or manually

Download the JAR for the latest version, as well as the Gson library (if you do not already use it). Place both of these in a /lib folder in your project, add them to your project's classpath, then see below.

Configuration and Usage

  1. In your AndroidManifest.xml, make sure you have granted Internet permissions. Beneath the manifest element add:

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
  2. Inside the application element, add:

    <service   android:name="main.java.com.mindscapehq.android.raygun4android.RaygunPostService"
               android:exported="false"
               android:process=":raygunpostservice"/>
    <meta-data android:name="com.mindscapehq.android.raygun4android.apikey"
               android:value="PASTE_YOUR_API_KEY_HERE" />

    And replace the value in meta-data with your API key, available from your Raygun dashboard.

  3. In a central activity, call the following:

    RaygunClient.Init(getApplicationContext());
    RaygunClient.AttachExceptionHandler();

    The above exception handler automatically catches & sends all uncaught exceptions. You can create your own or send from a catch block by calling RaygunClient.Send() and passing in the Throwable.

A usage example is also available from the GitHub repository and Maven, in /sample-app.

Documentation

View the complete Raygun4Android documentation here, including user/version tracking and troubleshooting information.

Raygun4Android GitHub Repository

For complete installation instructions, getting the source code and troubleshooting, visit the GitHub repository here.