Acra reporting using email

元气小坏坏 提交于 2020-01-24 06:02:50

问题


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 = "akshaycjoshi@gmail.com",
        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 ?


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/40045595/acra-reporting-using-email

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!