Search code examples
androidacraacralyzer

No good example for latest ACRA (Application Crash Report for Android)


I searched a lot about ACRA. Since after the code transferred from code.google.com to Github. All the answer's in SO has bad link's. All the example code's are not so useful as google docs has been deprecated for using it.

So please guide me how the new system woks and how to use it.


Solution

  • First, add ACRA to your project:

    Maven

    <dependency> 
        <groupId>ch.acra</groupId> 
        <artifactId>acra</artifactId> 
        <version>4.9.2</version> 
        <type>aar</type> 
    </dependency>
    

    Gradle

    compile 'ch.acra:acra:4.9.2'
    

    Now, you need a java class that extends Application. This is also defined in the manifest so no initialisation of the class is needed!

    @ReportsCrashes(
        formUri = "http://example.com/reportpath"
    )
    public class MyApplication extends Application {
        @Override
        protected void attachBaseContext(Context base) {
            super.attachBaseContext(base);
            ACRA.init(this);
        }
    }
    

    In your manifest:

    <application android:icon="@drawable/icon" android:label="@string/app_name"
               IMPORTANT! ---> android:name="MyApplication"  >
    

    You need these permissions: (read logs is not necessary if you do not need to read the logcat)

    <uses-permission android:name="android.permission.INTERNET"/>
    

    That is everything you need java-wise. From here it splits in two. If your site supports CouchDB:

    Install Acralyzer: https://github.com/ACRA/acralyzer

    If your server doesn't have CouchDB, try one of these: https://github.com/ACRA/acra/wiki/Backends