Akshay J
Akshay J

Reputation: 5458

Acra reporting using email

I am trying to use ACRA to report unhandled exceptions in my app.

Gave permission:

<uses-permission android:name="android.permission.READ_LOGS"/>
<uses-permission android:name="android.permission.INTERNET" />
<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme"
    android:name=".MyApplication">

gradle:

compile 'ch.acra:acra:4.9.0'

Extended Application Class

package online.hannuveda.transafe_rx;

import org.acra.*;
import org.acra.annotation.*;
import android.support.multidex.MultiDexApplication;


@ReportsCrashes(formUri = "",
        mailTo = "[email protected]",
        mode = ReportingInteractionMode.TOAST,
        resToastText = R.string.crash_toast_text)

public class MyApplication extends MultiDexApplication
{
    @Override
    public void onCreate() {
        super.onCreate();
        ACRA.init(this);
    }
}

In my login button, I am deliberately creating an exception using this:

public void Login_Click(View v)
{

    int i = 12/0;
}

When this exception occurs, I see the toast, then the app crashes but I don't see any email in my inbox. Any idea what is wrong ?

Upvotes: 4

Views: 3067

Answers (2)

Zoe - Save the data dump
Zoe - Save the data dump

Reputation: 28238

Firstly, remove formUri. When you use mailTo in addition to formUri it send the email if there is no internet at the time of the crash.

Further, this permission:

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

Is only for some apps, and I think you have to apply to use it. On newer versions of Android, you don't need that permission any more.

Upvotes: 1

Tim
Tim

Reputation: 43314

Remove formUri = "", and try again.

If you pass both formUri and mailTo, it will first try to send it via HTTP to the endpoint "" and use the mailTo as fallback in case there is no internet permission, but you do have the permission so it only tries to send it to "", and won't try to mail it.

Upvotes: 4

Related Questions