[Translate] How to install acra-an Android app crash tracking system-on your own server
How to Setup ACRA, a Android application Crash Tracking system, on your own host
Original address:
http://inthecheesefactory.com/blog/how-to-install-and-use-acra-android/en
There are so many limitations to developing a mobile app, such as hardware limitations (CPU, memory, battery, etc.). If your code is not reasonable enough, prepare for the world's most serious problem: Crash. As shown in the study:
应用崩溃是手机app用户抱怨最多的额问题
More serious:
如果一个应用连续崩溃3次,大概一半的用户会卸载这个应用
Crash tracking system that allows developers to collect every detail that causes crashes from the user's device, specifically to address this application crash. Currently the 2 most popular crash tracking systems are crashlytics and Parse Crash Reporting, both of which are free and developers can integrate them into your app for free. When the app crashes, the entire tracking report is sent to their backend, and developers can quickly and easily fix these serious problems so you can have a "no crash" application in a very short time.
However, the providers of these services collect this data and are still concerned about companies that are sensitive to user privacy.
So... Is there a crash tracking system that allows us to deploy on our own servers? Of course!! And it will be very easy to create, below please application Crash Reporting on Android (ACRA) a library that allows Android apps to automatically send crash reports to their servers.
Begin!
Creating a server
The server side is a prerequisite for the client. So let's start with the server side.
ACRA is well-designed and is quite popular (ACRA is for client applications, and the server can build on its own). It allows developers to develop their own server systems, and we find many kinds of ACRA services on the web. I suggest choosing – and the best-acralyzer,acralyzer is also developed by the ACRA team, Acralyzer work on Apache Couchdb, so there is no need to install any additional software except COUCHDB.
Acralyzer is a full-featured back-end crash tracking system. The same stack trace report that is fed back from different devices is categorized as an issue. If you've fixed a problem, you can turn it off with a simple click. It also works in real time. The only drawback that I found in this system is that his interface is a little complicated, but it doesn't matter, it was designed for developers =p.
The installation is simple, here is a complete guide on how to install Acralyzer on Ubuntu.
First, start with the installation couchdb, open the terminal and enter the following command:
apt-get install couchdb
Use the following instructions to verify that the installation is successful
curl http://127.0.0.1:5984
If the installation is successful, the following information is returned
{"couchdb":"Welcome","version":"1.2.0"}
Edit the /etc/couchdb/local.ini file to allow us to access the COUCHDB via an external IP (the default is only 127.0.0.1来 access). Just remove the comments from the next two lines.
;port = 5984;bind_address = 127.0.0.1
Then modify to:
port = 5984bind_address = 0.0.0.0
In this file, you should also add a username/password as an administrator account to find this line (usually at the end of the file):
[admins]
Add a username=password form of content on its next line. For example:
nuuneoi = 12345
Do not worry about the text password will be a problem here, once couchdb reboot, your password is automatically hashed encrypted, and is unreadable
Save the file by using the following statement to restart COUCHDB:
curl -XPOSThttp://localhost:5984/_restart -H"Content-Type: application/json"
Now, you can access the COUCHDB through the browser, and the Web service is called the Futon-couchdb interface back end. Open the browser with the following address:
http://<YOUR_SERVER_IP>:5984/_utils
The interface is displayed as follows:
First, you need to log in to the system via the administrator account you previously set
Now we're going to install a acro-storage (Acralyzer's storage side). From the menu on the right, click Replicator (Replicator) and fill out the form from remote database and from remote database similar to the following:
fromhttp://get.acralyzer.com/distrib-acra-storageto Local Database: acra-myapp
Then click Replicate and wait for it to complete.
Then install Acralyzerusing a similar method:
fromhttp://get.acralyzer.com/distrib-acralyzerto Local Database: acralyzer
or click Replicate to install the
If you do all the right things above, you will find that there are 2 more databases--acra-myapp and Acralyzer in the system.
Close to success, next, we want to create a user, open a browser, go to this URL:
http://<YOUR_SERVER_IP>:5984/acralyzer/_design/acralyzer/index.html
Go to the Admin page and click Users
Fill in an arbitrary user name and password (not necessarily the previous Admin account), click Createuser. You will then see the following information:
把这些信息都拷贝保存在文档里,我们会在后面的客户端里用到
The last thing is to protect the data in the Acra-myapp , you can set only open permissions to the administrator or some users, you can enter Acra-myapp, and then click Securities. Fill in the Roles field in the members section. As shown below:
["reader"]
Get!
After that, you can access the operations panel by using a webpage like this:
http://<YOUR_SERVER_IP>:5984/acralyzer/_design/acralyzer/index.html
请注意:arco-myapp是为一个应用创建的,如果你要为另外一个应用创建一个后端系统。那么重复上面的步骤,复制一个acro-storage,不过需要把本地的数据库改为*acra-<your_app_name>* 。 注意名字是以*acra-*开头的。
If there is more than one app in the system. A drop-down list is presented in the Acralyzer's operator panel, which allows you to select which app to view the problem report, and you can try it yourself.
Installing ACRA on the client
Installing ACRA on a mobile client is easy, first you need to add a (dependency) dependency in Build.gradle (using Android Studio):
‘ch.acra:acra:4.6.1‘
Sync your gradle file and create a custom application class-Don't forget to define it in Androidmanifest.xml. (What I think every Android developer will do),
Add a annotation @ReportCrashes on your custom application class
import android.app.application;import Org.acra.ACRA; import org.acra.annotation.ReportsCrashes; import org.acra.sender.HttpSender; /** * Created by Nuuneoi on 2/19/2015. */ @ReportsCrashes () public class Span class= "Hljs-title" >mainapplication extends application { @Override public void oncreate () {super . OnCreate (); Acra.init (this ); }}
Now the saved information mentioned above comes in handy, copying them into the @reportscrashes notes.
@ReportsCrashes( httpMethod = HttpSender.Method.PUT, reportType = HttpSender.Type.JSON, "http://YOUR_SERVER_IP:5984/acra-myapp/_design/acra-storage/_update/report", "tester", "12345")
Last step, don't forget to add network permissions in androidmanifest.xml
<uses-permission android:name="android.permission.INTERNET"/>
Congratulations to you! All done!
Test
Now let's test it and add some crash to the activity. For example:
TextView tvHello;@OverrideprotectedvoidonCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); tvHello.setText("Test Crash");}
Run your app, then change it in a crash way, run it again, and in your dashboard you can see that these bugs reports have been sent to the back-end system.
Each bug entry is a series of messages sent from different app users at different times.
Click on a report, drill down, and you'll see that the content is a complete stacktrace.
And a bunch of long messages, enough for you to turn over 7 pages.
If you fix a bug. You can close the bug by clicking on the "Bug" icon. (highlighted in the section)
I hope you find this article helpful, especially for those who are concerned about privacy, need a crash tracking system of large companies.
In fact, Acra has many features, such as: When crash occurs, a toast prompt or pop-up dialog. You can find these options on the ACRA website.
Acralytics also has a lot of other features, for example, you can set the server to send us an email when the bug report is received. For more information, please visit Acralyzer.
Original NUUNEOI
[Translate] How to install acra-an Android app crash tracking system