
Contents
How to Setup Cloudant Backend For ACRA (Application Crash Reports for Android)
Tung Dao Xuan, tungdx1210@gmail.com, is the author of this article and he contributes to RobustTechHouse Blog
What is ACRA?
ACRA stands for Application Crash Reports for Android. This library helps your software send crash reports to a backend of your choice.
The Acralyzer is an open source backend for ACRA reports that is really simple to install. The only server-side requirement is Apache CouchDB. You can host it on your own server or use the free hosting services of Cloudant.
Setup Cloudant backend
Step 1:
Sign up an account with Cloudant
Step 2:
Open Replication tab and fill in the fields as shown below:
Source database (Remote Database tab): http://get.acralyzer.com/distrib-acra-storage
Target database (New Database tab) : acra-<name_of_your_database>
Then, click the Replicate button.
Step 3:
Continue to replicate another:
Source database (Remote Database tab): http://get.acralyzer.com/distrib-acralyzer
Target database (New Database tab) : acralyzer
Then, click the Replicate button.
After that, open the Databases tab, you will see the 2 databases you have replicated.
Step 4:
Open acra-<name_of_your_database> database (in this tutorial is: acra-demo), select the Permissions tab.
Click the Generate API key button and note down Key and Password. You will need them when you integrate ACRA with your Android software.
Remove the Reader permission and add the Writer permission for the key you have just generated.
To confirm your backend is created successfully, go to https://<your_cloudant_account>.cloudant.com/acralyzer/_design/acralyzer/index.html and you will see the result as below figure.
Setup Android code with ACRA.
Step 1:
In build.gradle file, add ACRA library:
compile ‘ch.acra:acra:4.6.2’
Step 2:
In your AndroidManifest.xml file, declare internet permission.
<uses-permission android:name=”android.permission.INTERNET”>
Step 3:
In your class that extends from Application class, update ACRA configuration like this
@ReportsCrashes( formUri = "https://<your_cloudant_account>.cloudant.com/acra-<name_of_your_database>/_design/acra-storage/_update/report", reportType = HttpSender.Type.JSON, httpMethod = HttpSender.Method.POST, formUriBasicAuthLogin = "<your_key_that_is_created_before>", formUriBasicAuthPassword = "<your_password_that_is_created_before >", customReportContent = { ReportField.APP_VERSION_CODE, ReportField.APP_VERSION_NAME, ReportField.ANDROID_VERSION, ReportField.PACKAGE_NAME, ReportField.REPORT_ID, ReportField.BUILD, ReportField.STACK_TRACE, ReportField.DISPLAY, ReportField.TOTAL_MEM_SIZE, ReportField.AVAILABLE_MEM_SIZE }, mode = ReportingInteractionMode.SILENT ) public class <YourClassName> extends Application { @Override public final void onCreate() { super.onCreate(); ACRA.init(this); }
Conclusion
You are done! Run your software and see your crash reports to find out where the problems in your software and fix it.
You can configure report content and use other features. To find out more, check out the links below:
https://github.com/ACRA/acra/wiki/AdvancedUsage
https://github.com/ACRA/acra/wiki/ReportContent
RobustTechHouse is a leading tech company for mobile app development and ECommerce web design and development. If you are interested to engage RobustTechHouse for your projects, you can contact us here. If you like our articles, you can follow us on our Facebook.
very clear. thank you.
this was a very well written article, the information was very nice Thanks for your efforts
recipe meal kit app development