我想在我的测试应用程序(棒棒糖)中使用ACRA在Android Studio中获取基本报告。Android ACRA报告
到目前为止,我已经实现了以下内容:
在gradle这个
添加扶养compile 'ch.acra:acra:4.6.2'
添加MyApplication的延伸应用,并加入ReportsCrashes注解吧:
@ReportsCrashes( resNotifTickerText = R.string.crash_notification_ticker_text, resNotifTitle = R.string.crash_notification_title, resNotifText = R.string.crash_notification_text, resNotifIcon = R.mipmap.error); public class MyApplication extends Application { private static final String TAG = MyApplication.class.getSimpleName(); @Override public void onCreate(){ super.onCreate(); ACRA.init(this); } }
(顺便说一句,抱歉代码以上格式化,但StackOverflow的拒绝适当的格式化它由于某种原因)
这是基于在github上提供ACRA文档https://github.com/ACRA/acra/wiki/BasicSetup
加入应用程序的名称和INTERNET权限AndroidManifest
<!-- add INTERNET permission --> <uses-permission android:name="android.permission.INTERNET" /> <!-- add application name --> <application android:name="MyApplication" android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme" > <activity android:name=".MainActivity" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application>
我的主要活动只有一个按钮,点击后,就会当它试图通过零
public class MainActivity extends AppCompatActivity { public final static String TAG = MainActivity.class.getSimpleName(); private Button btnError; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); btnError = (Button) findViewById(R.id.btnError); btnError.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(getApplicationContext(), getString(R.string.toast_app_crash), Toast.LENGTH_SHORT).show(); Runnable r = new Runnable() { @Override public void run() { // this will crash your app throwing Arithmetic Exception int number = 7/0; } }; Handler h = new Handler(); h.postDelayed(r, 2000); } }); } }
我期待看到一些形式的通知和某种做到分工崩溃的应用程序报告生成,但我没有得到任何。我的应用程序在尝试除零的地方崩溃。
我不知道我做错了什么。
感谢,
所以,这将让弹出对话框,它可以让我输入注释。但它在哪里发送?我在哪里看到它?谢谢 – pixel
是的,你会得到对话框。它会被发送到“formUri”指向的任何地方。在上面的代码中是没有的。你应该把它指向你的崩溃服务器。 – William
@William你会介意推荐一些我可以使用的好的免费崩溃服务器吗?谢谢 – pixel