├── .gitignore
├── .idea
├── caches
│ └── build_file_checksums.ser
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── DemoApk.apk
├── LICENSE.md
├── README.md
├── README_EN.md
├── art
├── WechatIMG751.jpeg
├── uce_feature.png
├── uce_handler_example.gif
└── uce_handler_feature.png
├── build.gradle
├── example_app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── next
│ │ └── uceh_example
│ │ ├── MainActivity.java
│ │ └── MyApplication.java
│ └── res
│ ├── drawable-v24
│ └── ic_launcher_foreground.xml
│ ├── drawable
│ └── ic_launcher_background.xml
│ ├── layout
│ └── activity_main.xml
│ ├── mipmap-anydpi-v26
│ ├── ic_launcher.xml
│ └── ic_launcher_round.xml
│ ├── mipmap-hdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-mdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxxhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ └── values
│ ├── colors.xml
│ ├── strings.xml
│ └── styles.xml
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── ignore-dummy-module
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ └── AndroidManifest.xml
├── settings.gradle
├── uce_handler
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── next
│ │ └── uceh
│ │ ├── ExceptionInfoBean.java
│ │ ├── UCECallback.java
│ │ ├── UCEDefaultActivity.java
│ │ ├── UCEHandler.java
│ │ └── UCEHandlerHelper.java
│ └── res
│ ├── layout
│ └── default_error_activity.xml
│ ├── menu
│ └── crash_info_options.xml
│ └── values
│ ├── colors.xml
│ ├── dimens.xml
│ └── strings.xml
└── uce_handler_no_op
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
├── androidTest
└── java
│ └── me
│ └── next
│ └── uce_handler_no_op
│ └── ExampleInstrumentedTest.java
├── main
├── AndroidManifest.xml
└── java
│ └── com
│ └── next
│ └── uceh
│ ├── ExceptionInfoBean.java
│ ├── UCECallback.java
│ └── UCEHandler.java
└── test
└── java
└── me
└── next
└── uce_handler_no_op
└── ExampleUnitTest.java
/.gitignore:
--------------------------------------------------------------------------------
1 | #This is a gitignore file
2 | #Created by "rohitss"
3 | # Remove tracked files using [git rm -r --cached .]
4 | # Built application files
5 | #*.apk
6 | *.ap_
7 |
8 | /gradle.properties
9 |
10 | # Files for the ART/Dalvik VM
11 | *.dex
12 |
13 | # Java class files
14 | *.class
15 |
16 | # Generated files
17 | bin/
18 | gen/
19 | out/
20 |
21 | # Gradle files
22 | .gradle/
23 | build/
24 |
25 | # Local configuration file (sdk path, etc)
26 | local.properties
27 |
28 | # Proguard folder generated by Eclipse
29 | proguard/
30 |
31 | # Log Files
32 | *.log
33 | import-summary.txt
34 |
35 | # Android Studio Navigation editor temp files
36 | .navigation/
37 |
38 | # Android Studio captures folder
39 | captures/
40 |
41 | # Intellij
42 | *.iml
43 | .idea/workspace.xml
44 | .idea/tasks.xml
45 | .idea/gradle.xml
46 | .idea/dictionaries
47 | .idea/libraries
48 |
49 | # Keystore files
50 | *.jks
51 |
52 | # External native build folder generated in Android Studio 2.2 and later
53 | .externalNativeBuild
54 |
55 | # Google Services (e.g. APIs or Firebase)
56 | google-services.json
57 |
58 | # Freeline
59 | freeline.py
60 | freeline/
61 | freeline_project_description.json
62 |
--------------------------------------------------------------------------------
/.idea/caches/build_file_checksums.ser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingideayou/UCE-Handler/e44fd8085fa378757d17df2423fbe136408bac81/.idea/caches/build_file_checksums.ser
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
88 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/DemoApk.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingideayou/UCE-Handler/e44fd8085fa378757d17df2423fbe136408bac81/DemoApk.apk
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright © 2018 Rohit Sahebrao Surwase
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://jitpack.io/#RohitSurwase/UCE-Handler) [](http://www.repostatus.org/#active) [](https://GitHub.com/kingideayou/UCE-Handler/stargazers)
2 |
3 | # UCE Handler
4 | #### 捕获应用的 UncaughtException,应用崩溃时提供崩溃的类名、方法名、行数、Error Log、Activity 路径、设备信息、应用信息...同时支持复制、分享和保存崩溃信息。方便在开发和测试时使用
5 |
6 | ## Features
7 | * 监控 App 整个生命周期
8 | * 优雅捕获所以 UncaughtException
9 | * 崩溃时直接展示崩溃信息、格式化显示崩溃信息
10 | * 复制、分享、保存崩溃日志
11 | * 使用者可以拦截崩溃自行处理[如何配置](#自定义处理崩溃信息)
12 |
13 | ## 提供的崩溃日志信息
14 | * Crash `ClassName`、`MethodName`、`LineNumber`、`CrashInfo`
15 | * Device/mobile info.
16 | * Application info.
17 | * Crash log.
18 | * Activity track. //optional
19 | * All log files are placed in a separate folder.
20 |
21 | ### 示例图片
22 | 
23 | 
24 |
25 | ## 预览效果
26 | Download the example app [here](https://github.com/kingideayou/UCE-Handler/raw/master/DemoApk)
27 |
28 | # Setup
29 | Project 根目录的 build.gradle 文件:
30 |
31 | allprojects {
32 | repositories {
33 | ...
34 | maven { url 'https://jitpack.io' }
35 | }
36 | }
37 |
38 | Application 或 Module 的 build.gradle 文件:
39 |
40 | dependencies {
41 | debugImplementation 'com.github.kingideayou.UCE-Handler:uce_handler:1.5.2'
42 | releaseImplementation 'com.github.kingideayou.UCE-Handler:uce_handler_no_op:1.5.2'
43 | }
44 |
45 | ##### 在应用的 Application 类初始化:
46 | * Initialize library using builder pattern.
47 |
48 | public class MyApplication extends Application {
49 | @Override public void onCreate() {
50 | ...
51 | // Initialize UCE_Handler Library
52 | new UCEHandler.Builder(this).build();
53 | } }
54 |
55 | ##### Kotlin 初始化
56 |
57 | UCEHandler.Builder(applicationContext).build()
58 |
59 | ##### 自定义处理崩溃信息
60 |
61 | .setUCEHCallback(new UCECallback() {
62 | @Override
63 | public void exceptionInfo(@Nullable ExceptionInfoBean exceptionInfoBean) {
64 | Log.e("UCE-Handler", "exceptionInfo...");
65 | }
66 |
67 | @Override
68 | public void throwable(@Nullable Throwable throwable) {
69 | Log.e("UCE-Handler", "throwable...");
70 | }
71 | })
72 |
73 | ### Optional Parameters
74 |
75 | | Optional Parameters | Default | Desc |
76 | | ------ | ------ | ------ |
77 | | `setUCEHEnabled(true/false)` | true | Enable/Disable UCE_Handler. |
78 | | `setTrackActivitiesEnabled(true/false)` | false | Choose whether you want to track the flow of activities the user/tester has taken or not. |
79 | | `setBackgroundModeEnabled(true/false)` | true | Choose if you want to catch exceptions while app is in background. |
80 | | `setUCEHCallback(UCECallback)` | null | You can handle catch exception infos yourself. |
81 |
82 | #### 注意:「保存异常信息」需要提供读取本地存储空间权限
83 |
84 | ## Authors & Contributers
85 |
86 | * [**Rohit Surwase**](https://github.com/RohitSurwase) - *Initial work* - [API-Calling-Flow](https://github.com/RohitSurwase/API-Calling-Flow) , [AndroidDesignPatterns](https://github.com/RohitSurwase/AndroidDesignPatterns) , [News App Using Kotlin, MVP](https://github.com/RohitSurwase/News-Kotlin-MVP) , [Linkaive - Android App on Play Store](https://play.google.com/store/apps/details?id=com.rohitss.saveme)
87 | * [**NeXT**](https://juejin.im/user/55f4419360b28e983c150d0e)
88 |
89 | ## Thanks To
90 | * [UCE-Handler](https://github.com/RohitSurwase/UCE-Handler)
91 | * [Recovery](https://github.com/Sunzxyong/Recovery)
92 | * [leakcanary](https://github.com/square/leakcanary)
93 |
94 | ## License
95 | Copyright © 2018 NeXT.
96 |
97 | This project is licensed under the Apache License, Version 2.0 - see the [LICENSE.md](LICENSE.md) file for details
--------------------------------------------------------------------------------
/README_EN.md:
--------------------------------------------------------------------------------
1 | [](https://jitpack.io/#RohitSurwase/UCE-Handler) [](http://www.repostatus.org/#active) [](https://GitHub.com/RohitSurwase/UCE-Handler/stargazers)
2 |
3 |
4 |
5 | # UCE Handler
6 | ### Android library which lets you take control of Android App's uncaught exceptions. View, Copy, Share, Save and Email exceptions details including other useful info easily.
7 | Tracking down all exceptions is the crucial part of the development. We could just expect that we have handled all exceptions. But whatever we do, we come across it with the so-called pop-up saying “Unfortunately, App has stopped”, that is why it is called uncaught-exceptions.
8 |
9 | Why should you use this library? Read the answer - [Handling Uncaught-Exceptions in Android](https://android.jlelse.eu/handling-uncaught-exceptions-in-android-d818ffb20181)
10 |
11 | 
12 | 
13 | 
14 |
15 | ## Features
16 | * Android App lifecycle aware.
17 | * Catches all uncaught exceptions gracefully.
18 | * Displays separate screen with multiple options whenever an App crashes.
19 | * View, Copy, Share, and Save crash logs easily.
20 | * Email crash log along with the .txt file with multiple developers/receipients.
21 | * Completely close the crashed/unstable Application.
22 |
23 | ## Logged Information
24 | * Device/mobile info.
25 | * Application info.
26 | * Crash log.
27 | * Activity track. //optional
28 | * All log files are placed in a separate folder.
29 |
30 | ### Each Log file is named upon App's name so you can identify and distinguish files easily if you have added this library in multiple projects/applications.
31 |
32 |
33 | ## Example
34 | Download the example app [here](https://github.com/RohitSurwase/UCE-Handler/raw/master/UCE_Handler_Example.apk)
35 |
36 | ## Getting Started
37 | Add this library to your Android project and initialize it in your Application class. Additionaly you can add developer's email addresses who will get the email of crash log along with the .txt file attached.
38 |
39 | # Setup
40 | In your Project's build.gradle file:
41 |
42 | allprojects {
43 | repositories {
44 | ...
45 | maven { url 'https://jitpack.io' }
46 | }
47 | }
48 |
49 | In your Application's or Module's build.gradle file:
50 |
51 | dependencies {
52 | debugImplementation 'com.github.kingideayou.UCE-Handler:uce_handler:1.5.1'
53 | releaseImplementation 'com.github.kingideayou.UCE-Handler:uce_handler_no_op:1.5.1'
54 | }
55 |
56 | In your Application class:
57 | * Initialize library using builder pattern.
58 |
59 | public class MyApplication extends Application {
60 | @Override public void onCreate() {
61 | ...
62 | // Initialize UCE_Handler Library
63 | new UCEHandler.Builder(this).build();
64 | } }
65 |
66 | ##### Kotlin way of initialization
67 |
68 | UCEHandler.Builder(applicationContext).build()
69 |
70 | ##### For those of you who are still using Eclipse + ADT, you need to add UCEDefaultActivity manually in your App's manifest. (As suggested by [Caceresenzo](https://github.com/RohitSurwase/UCE-Handler/issues/2#issuecomment-385262850))
71 |
72 |
73 | ...
74 |
77 |
78 |
79 | ### Optional Parameters
80 | ##### .setUCEHEnabled(true/false)
81 | // default 'true'
82 | => Enable/Disable UCE_Handler.
83 | ##### .setTrackActivitiesEnabled(true/false)
84 | // default 'false'
85 | => Choose whether you want to track the flow of activities the user/tester has taken or not.
86 | ##### .setBackgroundModeEnabled(true/false)
87 | // default 'true'
88 | => Choose if you want to catch exceptions while app is in background.
89 | ##### .addCommaSeparatedEmailAddresses("abc@gmail.com, pqr@gmail.com,...)
90 | // default - empty
91 | => Add comma separated email addresses who will receive the crash logs.
92 |
93 | #### 'Save Error Log' will work only if your app already has storage permission as library does not ask for it.
94 |
95 | ## Authors & Contributers
96 |
97 | * [**Rohit Surwase**](https://github.com/RohitSurwase) - *Initial work* - [API-Calling-Flow](https://github.com/RohitSurwase/API-Calling-Flow) , [AndroidDesignPatterns](https://github.com/RohitSurwase/AndroidDesignPatterns) , [News App Using Kotlin, MVP](https://github.com/RohitSurwase/News-Kotlin-MVP) , [Linkaive - Android App on Play Store](https://play.google.com/store/apps/details?id=com.rohitss.saveme)
98 |
99 | ## License
100 | Copyright © 2018 Rohit Sahebrao Surwase.
101 | This project is licensed under the Apache License, Version 2.0 - see the [LICENSE.md](LICENSE.md) file for details
102 |
--------------------------------------------------------------------------------
/art/WechatIMG751.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingideayou/UCE-Handler/e44fd8085fa378757d17df2423fbe136408bac81/art/WechatIMG751.jpeg
--------------------------------------------------------------------------------
/art/uce_feature.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingideayou/UCE-Handler/e44fd8085fa378757d17df2423fbe136408bac81/art/uce_feature.png
--------------------------------------------------------------------------------
/art/uce_handler_example.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingideayou/UCE-Handler/e44fd8085fa378757d17df2423fbe136408bac81/art/uce_handler_example.gif
--------------------------------------------------------------------------------
/art/uce_handler_feature.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingideayou/UCE-Handler/e44fd8085fa378757d17df2423fbe136408bac81/art/uce_handler_feature.png
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 |
5 | repositories {
6 | google()
7 | jcenter()
8 | maven { url "https://jitpack.io" }
9 | }
10 | dependencies {
11 | classpath 'com.android.tools.build:gradle:3.2.0'
12 | classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
13 |
14 | // NOTE: Do not place your application dependencies here; they belong
15 | // in the individual module build.gradle files
16 | }
17 | }
18 |
19 | allprojects {
20 | repositories {
21 | google()
22 | jcenter()
23 | maven { url "https://jitpack.io" }
24 | }
25 | }
26 |
27 | task clean(type: Delete) {
28 | delete rootProject.buildDir
29 | }
30 |
--------------------------------------------------------------------------------
/example_app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/example_app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 27
5 | defaultConfig {
6 | applicationId "com.next.uce_handler"
7 | minSdkVersion 14
8 | targetSdkVersion 27
9 | versionCode 1
10 | versionName "1.0"
11 | }
12 | buildTypes {
13 | release {
14 | minifyEnabled false
15 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
16 | }
17 | }
18 | }
19 |
20 | dependencies {
21 | implementation fileTree(include: ['*.jar'], dir: 'libs')
22 | implementation 'com.android.support:appcompat-v7:27.0.2'
23 | implementation project(':uce_handler')
24 | // implementation project(':uce_handler_no_op')
25 | // debugImplementation 'com.github.kingideayou.UCE-Handler:uce_handler:1.5.1'
26 | // releaseImplementation 'com.github.kingideayou.UCE-Handler:uce_handler_no_op:1.5.1'
27 | implementation project(':ignore-dummy-module')
28 | }
29 |
--------------------------------------------------------------------------------
/example_app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/example_app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/example_app/src/main/java/com/next/uceh_example/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.next.uceh_example;
2 |
3 | import android.support.v7.app.AppCompatActivity;
4 | import android.os.Bundle;
5 | import android.view.View;
6 | import android.widget.Toast;
7 |
8 | public class MainActivity extends AppCompatActivity {
9 | @Override
10 | protected void onCreate(Bundle savedInstanceState) {
11 | super.onCreate(savedInstanceState);
12 | setContentView(R.layout.activity_main);
13 | }
14 |
15 | public void onCrashButtonClicked(View view) {
16 | Toast.makeText(this, "App Crashed", Toast.LENGTH_SHORT).show();
17 | throw new RuntimeException("Hey! App Crashed.");
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/example_app/src/main/java/com/next/uceh_example/MyApplication.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * * Copyright © 2018 Rohit Sahebrao Surwase.
4 | * *
5 | * * Licensed under the Apache License, Version 2.0 (the "License");
6 | * * you may not use this file except in compliance with the License.
7 | * * You may obtain a copy of the License at
8 | * *
9 | * * http://www.apache.org/licenses/LICENSE-2.0
10 | * *
11 | * * Unless required by applicable law or agreed to in writing, software
12 | * * distributed under the License is distributed on an "AS IS" BASIS,
13 | * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * * See the License for the specific language governing permissions and
15 | * * limitations under the License.
16 | *
17 | */
18 | package com.next.uceh_example;
19 |
20 | import android.app.Application;
21 |
22 | import com.next.uceh.UCEHandler;
23 |
24 | /**
25 | *
26 | *
This class is used to
27 | * Created by Rohit.
28 | */
29 | public class MyApplication extends Application {
30 | @Override
31 | public void onCreate() {
32 | super.onCreate();
33 | //Initialize UCE Handler library
34 | new UCEHandler.Builder(getApplicationContext())
35 | .setTrackActivitiesEnabled(true)
36 | // 手动处理崩溃信息
37 | // .setUCEHCallback(new UCECallback() {
38 | // @Override
39 | // public void exceptionInfo(@Nullable ExceptionInfoBean exceptionInfoBean) {
40 | // Log.e("UCE-Handler", "exceptionInfo...");
41 | // }
42 | //
43 | // @Override
44 | // public void throwable(@Nullable Throwable throwable) {
45 | // Log.e("UCE-Handler", "throwable...");
46 | // }
47 | // })
48 | .build();
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/example_app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/example_app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
11 |
16 |
21 |
26 |
31 |
36 |
41 |
46 |
51 |
56 |
61 |
66 |
71 |
76 |
81 |
86 |
91 |
96 |
101 |
106 |
111 |
116 |
121 |
126 |
131 |
136 |
141 |
146 |
151 |
156 |
161 |
166 |
171 |
172 |
--------------------------------------------------------------------------------
/example_app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
16 |
--------------------------------------------------------------------------------
/example_app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/example_app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/example_app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingideayou/UCE-Handler/e44fd8085fa378757d17df2423fbe136408bac81/example_app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example_app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingideayou/UCE-Handler/e44fd8085fa378757d17df2423fbe136408bac81/example_app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/example_app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingideayou/UCE-Handler/e44fd8085fa378757d17df2423fbe136408bac81/example_app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example_app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingideayou/UCE-Handler/e44fd8085fa378757d17df2423fbe136408bac81/example_app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/example_app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingideayou/UCE-Handler/e44fd8085fa378757d17df2423fbe136408bac81/example_app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example_app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingideayou/UCE-Handler/e44fd8085fa378757d17df2423fbe136408bac81/example_app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/example_app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingideayou/UCE-Handler/e44fd8085fa378757d17df2423fbe136408bac81/example_app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example_app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingideayou/UCE-Handler/e44fd8085fa378757d17df2423fbe136408bac81/example_app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/example_app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingideayou/UCE-Handler/e44fd8085fa378757d17df2423fbe136408bac81/example_app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example_app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingideayou/UCE-Handler/e44fd8085fa378757d17df2423fbe136408bac81/example_app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/example_app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/example_app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | UCE-Handler
3 |
4 |
--------------------------------------------------------------------------------
/example_app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingideayou/UCE-Handler/e44fd8085fa378757d17df2423fbe136408bac81/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Tue Sep 25 16:51:44 CST 2018
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/ignore-dummy-module/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/ignore-dummy-module/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 27
5 |
6 |
7 |
8 | defaultConfig {
9 | minSdkVersion 14
10 | targetSdkVersion 27
11 | versionCode 1
12 | versionName "1.0"
13 |
14 | }
15 |
16 | buildTypes {
17 | release {
18 | minifyEnabled false
19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
20 | }
21 | }
22 |
23 | }
24 |
25 | dependencies {
26 | implementation fileTree(dir: 'libs', include: ['*.jar'])
27 | }
28 |
--------------------------------------------------------------------------------
/ignore-dummy-module/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/ignore-dummy-module/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':example_app', ':uce_handler', ':ignore-dummy-module', ':uce_handler_no_op'
2 |
--------------------------------------------------------------------------------
/uce_handler/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/uce_handler/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'com.github.dcendents.android-maven'
3 | group='com.github.kingideayou'
4 | android {
5 | compileSdkVersion 27
6 |
7 | defaultConfig {
8 | minSdkVersion 14
9 | targetSdkVersion 27
10 | versionCode 1
11 | versionName "1.0"
12 | }
13 |
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | implementation fileTree(dir: 'libs', include: ['*.jar'])
24 | implementation 'com.android.support:appcompat-v7:27.0.2'
25 | }
26 |
--------------------------------------------------------------------------------
/uce_handler/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/uce_handler/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/uce_handler/src/main/java/com/next/uceh/ExceptionInfoBean.java:
--------------------------------------------------------------------------------
1 | package com.next.uceh;
2 |
3 | import android.os.Parcel;
4 | import android.os.Parcelable;
5 |
6 | /**
7 | *
8 | * author : NeXT
9 | * time : 2018/09/25
10 | * desc :
11 | *
12 | */
13 | public class ExceptionInfoBean implements Parcelable {
14 |
15 | private int lineNumber;
16 | private String cause;
17 | private String className;
18 | private String methodName;
19 | private String exceptionType;
20 | private String stackTraceString;
21 | private String activityLogString;
22 |
23 | public static ExceptionInfoBean newInstance() {
24 | return new ExceptionInfoBean();
25 | }
26 |
27 | public String getExceptionType() {
28 | return exceptionType;
29 | }
30 |
31 | public void setExceptionType(String exceptionType) {
32 | this.exceptionType = exceptionType;
33 | }
34 |
35 | public int getLineNumber() {
36 | return lineNumber;
37 | }
38 |
39 | public void setLineNumber(int lineNumber) {
40 | this.lineNumber = lineNumber;
41 | }
42 |
43 | public String getMethodName() {
44 | return methodName;
45 | }
46 |
47 | public void setMethodName(String methodName) {
48 | this.methodName = methodName;
49 | }
50 |
51 | public String getClassName() {
52 | return className;
53 | }
54 |
55 | public void setClassName(String className) {
56 | this.className = className;
57 | }
58 |
59 | public String getStackTraceString() {
60 | return stackTraceString;
61 | }
62 |
63 | public void setStackTraceString(String stackTraceString) {
64 | this.stackTraceString = stackTraceString;
65 | }
66 |
67 | public String getActivityLogString() {
68 | return activityLogString;
69 | }
70 |
71 | public void setActivityLogString(String activityLogString) {
72 | this.activityLogString = activityLogString;
73 | }
74 |
75 | public String getCause() {
76 | return cause;
77 | }
78 |
79 | public void setCause(String cause) {
80 | this.cause = cause;
81 | }
82 |
83 | @Override
84 | public String toString() {
85 | return "ExceptionInfoBean{" +
86 | "lineNumber=" + lineNumber +
87 | ", methodName='" + methodName + '\'' +
88 | ", cause='" + cause + '\'' +
89 | ", className='" + className + '\'' +
90 | ", exceptionType='" + exceptionType + '\'' +
91 | ", stackTraceString='" + stackTraceString + '\'' +
92 | ", activityLogString='" + activityLogString + '\'' +
93 | '}';
94 | }
95 |
96 | public ExceptionInfoBean() {
97 | }
98 |
99 | public ExceptionInfoBean lineNumber(int val) {
100 | lineNumber = val;
101 | return this;
102 | }
103 |
104 | public ExceptionInfoBean methodName(String val) {
105 | methodName = val;
106 | return this;
107 | }
108 |
109 | public ExceptionInfoBean className(String val) {
110 | className = val;
111 | return this;
112 | }
113 |
114 | public ExceptionInfoBean stackTraceString(String val) {
115 | stackTraceString = val;
116 | return this;
117 | }
118 |
119 | public ExceptionInfoBean activityLogString(String val) {
120 | activityLogString = val;
121 | return this;
122 | }
123 |
124 | public ExceptionInfoBean cause(String val) {
125 | cause = val;
126 | return this;
127 | }
128 |
129 | public ExceptionInfoBean exceptionType(String val) {
130 | exceptionType = val;
131 | return this;
132 | }
133 |
134 | @Override
135 | public int describeContents() {
136 | return 0;
137 | }
138 |
139 | @Override
140 | public void writeToParcel(Parcel dest, int flags) {
141 | dest.writeInt(this.lineNumber);
142 | dest.writeString(this.cause);
143 | dest.writeString(this.className);
144 | dest.writeString(this.methodName);
145 | dest.writeString(this.exceptionType);
146 | dest.writeString(this.stackTraceString);
147 | dest.writeString(this.activityLogString);
148 | }
149 |
150 | protected ExceptionInfoBean(Parcel in) {
151 | this.lineNumber = in.readInt();
152 | this.cause = in.readString();
153 | this.className = in.readString();
154 | this.methodName = in.readString();
155 | this.exceptionType = in.readString();
156 | this.stackTraceString = in.readString();
157 | this.activityLogString = in.readString();
158 | }
159 |
160 | public static final Creator CREATOR = new Creator() {
161 | @Override
162 | public ExceptionInfoBean createFromParcel(Parcel source) {
163 | return new ExceptionInfoBean(source);
164 | }
165 |
166 | @Override
167 | public ExceptionInfoBean[] newArray(int size) {
168 | return new ExceptionInfoBean[size];
169 | }
170 | };
171 | }
172 |
--------------------------------------------------------------------------------
/uce_handler/src/main/java/com/next/uceh/UCECallback.java:
--------------------------------------------------------------------------------
1 | package com.next.uceh;
2 |
3 | import android.support.annotation.Nullable;
4 |
5 | /**
6 | *
7 | * author : NeXT
8 | * time : 2018/09/25
9 | * desc :
10 | *
11 | */
12 | public interface UCECallback {
13 |
14 | void exceptionInfo(@Nullable ExceptionInfoBean exceptionInfoBean);
15 |
16 | void throwable(@Nullable Throwable throwable);
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/uce_handler/src/main/java/com/next/uceh/UCEDefaultActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * * Copyright © 2018 Rohit Sahebrao Surwase.
4 | * *
5 | * * Licensed under the Apache License, Version 2.0 (the "License");
6 | * * you may not use this file except in compliance with the License.
7 | * * You may obtain a copy of the License at
8 | * *
9 | * * http://www.apache.org/licenses/LICENSE-2.0
10 | * *
11 | * * Unless required by applicable law or agreed to in writing, software
12 | * * distributed under the License is distributed on an "AS IS" BASIS,
13 | * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * * See the License for the specific language governing permissions and
15 | * * limitations under the License.
16 | *
17 | */
18 | package com.next.uceh;
19 |
20 | import android.annotation.SuppressLint;
21 | import android.content.ClipData;
22 | import android.content.ClipboardManager;
23 | import android.content.Context;
24 | import android.content.Intent;
25 | import android.content.pm.ApplicationInfo;
26 | import android.os.Bundle;
27 | import android.os.Environment;
28 | import android.support.v7.app.AppCompatActivity;
29 | import android.support.v7.widget.Toolbar;
30 | import android.text.Html;
31 | import android.text.TextUtils;
32 | import android.util.Log;
33 | import android.view.Menu;
34 | import android.view.MenuItem;
35 | import android.widget.TextView;
36 | import android.widget.Toast;
37 |
38 | import java.io.File;
39 | import java.io.FileOutputStream;
40 | import java.io.IOException;
41 | import java.text.DateFormat;
42 | import java.text.SimpleDateFormat;
43 | import java.util.Date;
44 | import java.util.Locale;
45 |
46 | public final class UCEDefaultActivity extends AppCompatActivity {
47 | private String pureStrCurrentErrorLog;
48 |
49 | @SuppressLint({"PrivateResource", "SetTextI18n"})
50 | @Override
51 | protected void onCreate(Bundle savedInstanceState) {
52 | super.onCreate(savedInstanceState);
53 | setContentView(R.layout.default_error_activity);
54 |
55 | Toolbar mToolbarTb = findViewById(R.id.toolbar);
56 | setSupportActionBar(mToolbarTb);
57 |
58 | TextView tvType = findViewById(R.id.tv_type);
59 | TextView tvMethodName = findViewById(R.id.tv_method_name);
60 | TextView tvLineNumber = findViewById(R.id.tv_line_number);
61 | TextView tvCause = findViewById(R.id.tv_cause);
62 | TextView tvStackTrace = findViewById(R.id.tv_stack_trace);
63 |
64 | ExceptionInfoBean exceptionInfoBean = getIntent().getParcelableExtra(UCEHandler.EXTRA_EXCEPTION_INFO);
65 | if (exceptionInfoBean == null) {
66 | return;
67 | }
68 | String errorInfo = getExceptionInfoString(this, exceptionInfoBean);
69 | tvType.setText(Html.fromHtml("ExceptionType:
" + getHtmlCodeBlueStr(exceptionInfoBean.getExceptionType())));
70 | String methodName = getHtmlCodeBlueStr(exceptionInfoBean.getClassName()) + "." + getHtmlCodeStr(exceptionInfoBean.getMethodName());
71 | tvMethodName.setText(Html.fromHtml("MethodName:
" + methodName));
72 | tvLineNumber.setText(Html.fromHtml(getHtmlCodeBlueStr("LineNumber: " + exceptionInfoBean.getLineNumber())));
73 | tvCause.setText(exceptionInfoBean.getCause());
74 | tvStackTrace.setText(errorInfo);
75 | }
76 |
77 | private void saveErrorLogToFile(boolean isShowToast) {
78 | Boolean isSDPresent = Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED);
79 | if (isSDPresent && isExternalStorageWritable()) {
80 | Date currentDate = new Date();
81 | DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
82 | String strCurrentDate = dateFormat.format(currentDate);
83 | strCurrentDate = strCurrentDate.replace(" ", "_");
84 | String errorLogFileName = getApplicationName(UCEDefaultActivity.this) + "_Error-Log_" + strCurrentDate;
85 | String errorLog = getPureErrorDetailsFromIntent(UCEDefaultActivity.this, getIntent());
86 | String fullPath = Environment.getExternalStorageDirectory() + "/AppErrorLogs_UCEH/";
87 | FileOutputStream outputStream;
88 | try {
89 | File file = new File(fullPath);
90 | file.mkdir();
91 | File txtFile = new File(fullPath + errorLogFileName + ".txt");
92 | txtFile.createNewFile();
93 | outputStream = new FileOutputStream(txtFile);
94 | outputStream.write(errorLog.getBytes());
95 | outputStream.close();
96 | if (txtFile.exists() && isShowToast) {
97 | Toast.makeText(this, "File Saved Successfully", Toast.LENGTH_SHORT).show();
98 | }
99 | } catch (IOException e) {
100 | Log.e("REQUIRED", "This app does not have write storage permission to save log file.");
101 | if (isShowToast) {
102 | Toast.makeText(this, "Storage Permission Not Found", Toast.LENGTH_SHORT).show();
103 | }
104 | e.printStackTrace();
105 | }
106 | }
107 | }
108 |
109 | private void shareErrorLog() {
110 | if (TextUtils.isEmpty(pureStrCurrentErrorLog)) {
111 | pureStrCurrentErrorLog = getPureErrorDetailsFromIntent(UCEDefaultActivity.this, getIntent());
112 | }
113 | Intent share = new Intent(Intent.ACTION_SEND);
114 | share.setType("text/plain");
115 | share.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
116 | share.putExtra(Intent.EXTRA_SUBJECT, "Application Crash Error Log");
117 | share.putExtra(Intent.EXTRA_TEXT, pureStrCurrentErrorLog);
118 | startActivity(Intent.createChooser(share, "Share Error Log"));
119 | }
120 |
121 | private void copyErrorToClipboard() {
122 | String errorInformation = getPureErrorDetailsFromIntent(UCEDefaultActivity.this, getIntent());
123 | ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
124 | if (clipboard != null) {
125 | ClipData clip = ClipData.newPlainText("View Error Log", errorInformation);
126 | clipboard.setPrimaryClip(clip);
127 | Toast.makeText(UCEDefaultActivity.this, "Error Log Copied", Toast.LENGTH_SHORT).show();
128 | }
129 | }
130 |
131 | private String getPureErrorDetailsFromIntent(Context context, Intent intent) {
132 | ExceptionInfoBean exceptionInfoBean = intent.getParcelableExtra(UCEHandler.EXTRA_EXCEPTION_INFO);
133 | if (TextUtils.isEmpty(pureStrCurrentErrorLog)) {
134 | StringBuilder errorReport = UCEHandlerHelper.getFullExceptionInfoString(context, exceptionInfoBean);
135 | pureStrCurrentErrorLog = errorReport.toString();
136 | return pureStrCurrentErrorLog;
137 | } else {
138 | return pureStrCurrentErrorLog;
139 | }
140 | }
141 |
142 | private String getExceptionInfoString(Context context, ExceptionInfoBean exceptionInfoBean) {
143 | return UCEHandlerHelper.getExceptionInfoString(context, exceptionInfoBean).toString();
144 | }
145 |
146 | public boolean isExternalStorageWritable() {
147 | String state = Environment.getExternalStorageState();
148 | return Environment.MEDIA_MOUNTED.equals(state);
149 | }
150 |
151 | public String getApplicationName(Context context) {
152 | ApplicationInfo applicationInfo = context.getApplicationInfo();
153 | int stringId = applicationInfo.labelRes;
154 | return stringId == 0 ? applicationInfo.nonLocalizedLabel.toString() : context.getString(stringId);
155 | }
156 |
157 | private static String getHtmlCodeStr(String string) {
158 | return "" + string + "";
159 | }
160 |
161 | private static String getHtmlCodeBlueStr(String string) {
162 | return "" + string + "";
163 | }
164 |
165 | private static String getHtmlCodeBlueStr(int value) {
166 | return getHtmlCodeBlueStr(Integer.toString(value));
167 | }
168 |
169 | @Override
170 | public boolean onCreateOptionsMenu(Menu menu) {
171 | getMenuInflater().inflate(R.menu.crash_info_options, menu);
172 | return super.onCreateOptionsMenu(menu);
173 | }
174 |
175 | @Override
176 | public boolean onOptionsItemSelected(MenuItem item) {
177 | int i = item.getItemId();
178 | if (i == R.id.action_copy) {
179 | copyErrorToClipboard();
180 | } else if (i == R.id.action_save) {
181 | saveErrorLogToFile(true);
182 | } else if (i == R.id.action_share) {
183 | shareErrorLog();
184 | }
185 | return super.onOptionsItemSelected(item);
186 | }
187 | }
188 |
--------------------------------------------------------------------------------
/uce_handler/src/main/java/com/next/uceh/UCEHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * * Copyright © 2018 Rohit Sahebrao Surwase.
4 | * *
5 | * * Licensed under the Apache License, Version 2.0 (the "License");
6 | * * you may not use this file except in compliance with the License.
7 | * * You may obtain a copy of the License at
8 | * *
9 | * * http://www.apache.org/licenses/LICENSE-2.0
10 | * *
11 | * * Unless required by applicable law or agreed to in writing, software
12 | * * distributed under the License is distributed on an "AS IS" BASIS,
13 | * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * * See the License for the specific language governing permissions and
15 | * * limitations under the License.
16 | *
17 | */
18 | package com.next.uceh;
19 |
20 | import android.annotation.SuppressLint;
21 | import android.app.Activity;
22 | import android.app.Application;
23 | import android.content.Context;
24 | import android.content.Intent;
25 | import android.os.Bundle;
26 | import android.util.Log;
27 |
28 | import java.lang.ref.WeakReference;
29 | import java.text.DateFormat;
30 | import java.text.SimpleDateFormat;
31 | import java.util.ArrayDeque;
32 | import java.util.Date;
33 | import java.util.Deque;
34 | import java.util.Locale;
35 |
36 | public final class UCEHandler {
37 | static final String EXTRA_EXCEPTION_INFO = "EXTRA_EXCEPTION_INFO";
38 | private final static String TAG = "UCEHandler";
39 | private static final String UCE_HANDLER_PACKAGE_NAME = "me.next.me.next.uceh";
40 | private static final String DEFAULT_HANDLER_PACKAGE_NAME = "com.android.internal.os";
41 | private static final String SHARED_PREFERENCES_FILE = "uceh_preferences";
42 | private static final String SHARED_PREFERENCES_FIELD_TIMESTAMP = "last_crash_timestamp";
43 | private static final int MAX_ACTIVITIES_IN_LOG = 50;
44 | private static final Deque activityLog = new ArrayDeque<>(MAX_ACTIVITIES_IN_LOG);
45 | private Application application;
46 | private boolean isInBackground = true;
47 | private boolean isBackgroundMode;
48 | private boolean isUCEHEnabled;
49 | static boolean isTrackActivitiesEnabled;
50 | private UCECallback mUCECallback = null;
51 | private static WeakReference lastActivityCreated = new WeakReference<>(null);
52 |
53 | private UCEHandler(Builder builder) {
54 | mUCECallback = builder.mUCECallback;
55 | isUCEHEnabled = builder.isUCEHEnabled;
56 | isTrackActivitiesEnabled = builder.isTrackActivitiesEnabled;
57 | isBackgroundMode = builder.isBackgroundModeEnabled;
58 | setUCEHandler(builder.context);
59 | }
60 |
61 | private void setUCEHandler(final Context context) {
62 | try {
63 | if (context != null) {
64 | final Thread.UncaughtExceptionHandler oldHandler = Thread.getDefaultUncaughtExceptionHandler();
65 | if (oldHandler != null && oldHandler.getClass().getName().startsWith(UCE_HANDLER_PACKAGE_NAME)) {
66 | Log.e(TAG, "UCEHandler was already installed, doing nothing!");
67 | } else {
68 | if (oldHandler != null && !oldHandler.getClass().getName().startsWith(DEFAULT_HANDLER_PACKAGE_NAME)) {
69 | Log.e(TAG, "You already have an UncaughtExceptionHandler. If you use a custom UncaughtExceptionHandler, it should be initialized after UCEHandler! Installing anyway, but your original handler will not be called.");
70 | }
71 | application = (Application) context.getApplicationContext();
72 | //Setup UCE Handler.
73 | setDefaultUncaughtExceptionHandler(oldHandler);
74 | registerLifecycleCallback();
75 | }
76 | Log.i(TAG, "UCEHandler has been installed.");
77 | } else {
78 | Log.e(TAG, "Context can not be null");
79 | }
80 | } catch (Throwable throwable) {
81 | Log.e(TAG, "UCEHandler can not be initialized. Help making it better by reporting this as a bug.", throwable);
82 | }
83 | }
84 |
85 | private void setDefaultUncaughtExceptionHandler(final Thread.UncaughtExceptionHandler oldHandler) {
86 | Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
87 | @Override
88 | public void uncaughtException(Thread thread, Throwable throwable) {
89 | if (isUCEHEnabled) {
90 | Log.e(TAG, "App crashed, executing UCEHandler's UncaughtExceptionHandler", throwable);
91 | if (hasCrashedInTheLastSeconds(application)) {
92 | Log.e(TAG, "App already crashed recently, not starting custom error activity because we could enter a restart loop. Are you sure that your app does not crash directly on init?", throwable);
93 | if (oldHandler != null) {
94 | oldHandler.uncaughtException(thread, throwable);
95 | return;
96 | }
97 | } else {
98 | setLastCrashTimestamp(application, new Date().getTime());
99 | if (!isInBackground || isBackgroundMode) {
100 | ExceptionInfoBean exceptionInfoBean = UCEHandlerHelper.getExceptionInfoBean(throwable, activityLog);
101 | if (mUCECallback != null) {
102 | mUCECallback.exceptionInfo(exceptionInfoBean);
103 | mUCECallback.throwable(throwable);
104 | return;
105 | }
106 | final Intent intent = new Intent(application, UCEDefaultActivity.class);
107 | intent.putExtra(EXTRA_EXCEPTION_INFO, exceptionInfoBean);
108 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
109 | application.startActivity(intent);
110 | } else {
111 | if (oldHandler != null) {
112 | oldHandler.uncaughtException(thread, throwable);
113 | return;
114 | }
115 | //If it is null (should not be), we let it continue and kill the process or it will be stuck
116 | }
117 | }
118 | final Activity lastActivity = lastActivityCreated.get();
119 | if (lastActivity != null) {
120 | lastActivity.finish();
121 | lastActivityCreated.clear();
122 | }
123 | killCurrentProcess();
124 | } else if (oldHandler != null) {
125 | //Pass control to old uncaught exception handler
126 | oldHandler.uncaughtException(thread, throwable);
127 | }
128 | }
129 | });
130 | }
131 |
132 | private void registerLifecycleCallback() {
133 | application.registerActivityLifecycleCallbacks(new Application.ActivityLifecycleCallbacks() {
134 | final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
135 | int currentlyStartedActivities = 0;
136 |
137 | @Override
138 | public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
139 | if (activity.getClass() != UCEDefaultActivity.class) {
140 | lastActivityCreated = new WeakReference<>(activity);
141 | }
142 | if (isTrackActivitiesEnabled) {
143 | activityLog.add(dateFormat.format(new Date()) + ": " + activity.getClass().getSimpleName() + " created\n");
144 | }
145 | }
146 |
147 | @Override
148 | public void onActivityStarted(Activity activity) {
149 | currentlyStartedActivities++;
150 | isInBackground = (currentlyStartedActivities == 0);
151 | }
152 |
153 | @Override
154 | public void onActivityResumed(Activity activity) {
155 | if (isTrackActivitiesEnabled) {
156 | activityLog.add(dateFormat.format(new Date()) + ": " + activity.getClass().getSimpleName() + " resumed\n");
157 | }
158 | }
159 |
160 | @Override
161 | public void onActivityPaused(Activity activity) {
162 | if (isTrackActivitiesEnabled) {
163 | activityLog.add(dateFormat.format(new Date()) + ": " + activity.getClass().getSimpleName() + " paused\n");
164 | }
165 | }
166 |
167 | @Override
168 | public void onActivityStopped(Activity activity) {
169 | currentlyStartedActivities--;
170 | isInBackground = (currentlyStartedActivities == 0);
171 | }
172 |
173 | @Override
174 | public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
175 | }
176 |
177 | @Override
178 | public void onActivityDestroyed(Activity activity) {
179 | if (isTrackActivitiesEnabled) {
180 | activityLog.add(dateFormat.format(new Date()) + ": " + activity.getClass().getSimpleName() + " destroyed\n");
181 | }
182 | }
183 | });
184 | }
185 |
186 | /**
187 | * INTERNAL method that tells if the app has crashed in the last seconds.
188 | * This is used to avoid restart loops.
189 | *
190 | * @return true if the app has crashed in the last seconds, false otherwise.
191 | */
192 | private static boolean hasCrashedInTheLastSeconds(Context context) {
193 | long lastTimestamp = getLastCrashTimestamp(context);
194 | long currentTimestamp = new Date().getTime();
195 | return (lastTimestamp <= currentTimestamp && currentTimestamp - lastTimestamp < 3000);
196 | }
197 |
198 | @SuppressLint("ApplySharedPref")
199 | private static void setLastCrashTimestamp(Context context, long timestamp) {
200 | context.getSharedPreferences(SHARED_PREFERENCES_FILE, Context.MODE_PRIVATE).edit().putLong(SHARED_PREFERENCES_FIELD_TIMESTAMP, timestamp).commit();
201 | }
202 |
203 | private static void killCurrentProcess() {
204 | android.os.Process.killProcess(android.os.Process.myPid());
205 | System.exit(10);
206 | }
207 |
208 | private static long getLastCrashTimestamp(Context context) {
209 | return context.getSharedPreferences(SHARED_PREFERENCES_FILE, Context.MODE_PRIVATE).getLong(SHARED_PREFERENCES_FIELD_TIMESTAMP, -1);
210 | }
211 |
212 | static void closeApplication(Activity activity) {
213 | activity.finish();
214 | killCurrentProcess();
215 | }
216 |
217 | public static class Builder {
218 | private Context context;
219 | private boolean isUCEHEnabled = true;
220 | private boolean isTrackActivitiesEnabled = false;
221 | private boolean isBackgroundModeEnabled = true;
222 | private UCECallback mUCECallback = null;
223 |
224 | public Builder(Context context) {
225 | this.context = context;
226 | }
227 |
228 | public Builder setUCEHCallback(UCECallback ucehCallback) {
229 | this.mUCECallback = ucehCallback;
230 | return this;
231 | }
232 |
233 | public Builder setUCEHEnabled(boolean isUCEHEnabled) {
234 | this.isUCEHEnabled = isUCEHEnabled;
235 | return this;
236 | }
237 |
238 | public Builder setTrackActivitiesEnabled(boolean isTrackActivitiesEnabled) {
239 | this.isTrackActivitiesEnabled = isTrackActivitiesEnabled;
240 | return this;
241 | }
242 |
243 | public Builder setBackgroundModeEnabled(boolean isBackgroundModeEnabled) {
244 | this.isBackgroundModeEnabled = isBackgroundModeEnabled;
245 | return this;
246 | }
247 |
248 | public UCEHandler build() {
249 | return new UCEHandler(this);
250 | }
251 | }
252 | }
253 |
--------------------------------------------------------------------------------
/uce_handler/src/main/java/com/next/uceh/UCEHandlerHelper.java:
--------------------------------------------------------------------------------
1 | package com.next.uceh;
2 |
3 | import android.content.Context;
4 | import android.content.pm.PackageInfo;
5 | import android.content.pm.PackageManager;
6 | import android.os.Build;
7 | import android.support.annotation.NonNull;
8 | import android.text.TextUtils;
9 |
10 | import java.io.PrintWriter;
11 | import java.io.StringWriter;
12 | import java.text.DateFormat;
13 | import java.text.SimpleDateFormat;
14 | import java.util.Date;
15 | import java.util.Deque;
16 | import java.util.Locale;
17 |
18 | /**
19 | *
20 | * author : NeXT
21 | * time : 2018/09/25
22 | * desc :
23 | *
24 | */
25 | public class UCEHandlerHelper {
26 |
27 | private static final int MAX_STACK_TRACE_SIZE = 131071; //128 KB - 1
28 | private static final String LINE_SEPARATOR = "\n";
29 |
30 | public static ExceptionInfoBean getExceptionInfoBean(Throwable throwable) {
31 | return getExceptionInfoBean(throwable, null);
32 | }
33 |
34 | public static ExceptionInfoBean getExceptionInfoBean(Throwable throwable, Deque activityLog) {
35 | StringWriter sw = new StringWriter();
36 | PrintWriter pw = new PrintWriter(sw);
37 | throwable.printStackTrace(pw);
38 | String stackTraceString = sw.toString();
39 | if (stackTraceString.length() > MAX_STACK_TRACE_SIZE) {
40 | String disclaimer = " [stack trace too large]";
41 | stackTraceString = stackTraceString.substring(0, MAX_STACK_TRACE_SIZE - disclaimer.length()) + disclaimer;
42 | }
43 |
44 | Throwable rootTr = throwable;
45 | String cause = throwable.getMessage();
46 | while (throwable.getCause() != null) {
47 | throwable = throwable.getCause();
48 | if (throwable.getStackTrace() != null && throwable.getStackTrace().length > 0) {
49 | rootTr = throwable;
50 | }
51 | String msg = throwable.getMessage();
52 | if (!TextUtils.isEmpty(msg))
53 | cause = msg;
54 | }
55 |
56 | String exceptionType = rootTr.getClass().getName();
57 |
58 | String throwClassName;
59 | String throwMethodName;
60 | int throwLineNumber;
61 |
62 | if (rootTr.getStackTrace().length > 0) {
63 | StackTraceElement trace = rootTr.getStackTrace()[0];
64 | throwClassName = trace.getClassName();
65 | throwMethodName = trace.getMethodName();
66 | throwLineNumber = trace.getLineNumber();
67 | } else {
68 | throwClassName = "unknown";
69 | throwMethodName = "unknown";
70 | throwLineNumber = -1;
71 | }
72 |
73 | StringBuilder activityLogStringBuilder = new StringBuilder();
74 | if (UCEHandler.isTrackActivitiesEnabled) {
75 | while (!activityLog.isEmpty()) {
76 | activityLogStringBuilder.append(activityLog.poll());
77 | }
78 | }
79 |
80 | return ExceptionInfoBean.newInstance()
81 | .cause(cause)
82 | .className(throwClassName)
83 | .methodName(throwMethodName)
84 | .exceptionType(exceptionType)
85 | .lineNumber(throwLineNumber)
86 | .stackTraceString(stackTraceString)
87 | .activityLogString(activityLogStringBuilder.toString());
88 | }
89 |
90 | public static StringBuilder getExceptionInfoString(Context context, ExceptionInfoBean exceptionInfoBean) {
91 | return getExceptionInfoString(context, exceptionInfoBean, false);
92 | }
93 |
94 | static StringBuilder getFullExceptionInfoString(Context context, ExceptionInfoBean exceptionInfoBean) {
95 | return getExceptionInfoString(context, exceptionInfoBean, true);
96 | }
97 |
98 | @NonNull
99 | private static StringBuilder getExceptionInfoString(Context context, ExceptionInfoBean exceptionInfoBean, boolean useHeader) {
100 | StringBuilder errorReport = new StringBuilder();
101 | if (useHeader) {
102 | getExceptionHeaderInfo(exceptionInfoBean, errorReport);
103 | }
104 | errorReport.append(LINE_SEPARATOR);
105 | errorReport.append("\n------------ ERROR LOG ------------\n");
106 | errorReport.append(LINE_SEPARATOR);
107 | if (exceptionInfoBean != null) {
108 | errorReport.append(exceptionInfoBean.getStackTraceString());
109 | }
110 | errorReport.append(LINE_SEPARATOR);
111 | if (exceptionInfoBean != null) {
112 | errorReport.append("\n------------ USER ACTIVITIES ------------\n");
113 | errorReport.append(LINE_SEPARATOR);
114 | errorReport.append(exceptionInfoBean.getActivityLogString());
115 | errorReport.append(LINE_SEPARATOR);
116 | }
117 | errorReport.append("\n------------ DEVICE INFO ------------\n");
118 | errorReport.append(LINE_SEPARATOR);
119 | errorReport.append("Brand: ");
120 | errorReport.append(Build.BRAND);
121 | errorReport.append(LINE_SEPARATOR);
122 | errorReport.append("Device: ");
123 | errorReport.append(Build.DEVICE);
124 | errorReport.append(LINE_SEPARATOR);
125 | errorReport.append("Model: ");
126 | errorReport.append(Build.MODEL);
127 | errorReport.append(LINE_SEPARATOR);
128 | errorReport.append("Manufacturer: ");
129 | errorReport.append(Build.MANUFACTURER);
130 | errorReport.append(LINE_SEPARATOR);
131 | errorReport.append("Product: ");
132 | errorReport.append(Build.PRODUCT);
133 | errorReport.append(LINE_SEPARATOR);
134 | errorReport.append("SDK: ");
135 | errorReport.append(Build.VERSION.SDK);
136 | errorReport.append(LINE_SEPARATOR);
137 | errorReport.append("Release: ");
138 | errorReport.append(Build.VERSION.RELEASE);
139 | errorReport.append(LINE_SEPARATOR);
140 | errorReport.append("\n------------ APP INFO ------------\n");
141 | errorReport.append(LINE_SEPARATOR);
142 | String versionName = getVersionName(context);
143 | errorReport.append("Version: ");
144 | errorReport.append(versionName);
145 | errorReport.append(LINE_SEPARATOR);
146 | Date currentDate = new Date();
147 | DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
148 | String firstInstallTime = getFirstInstallTimeAsString(context, dateFormat);
149 | if (!TextUtils.isEmpty(firstInstallTime)) {
150 | errorReport.append("Installed On: ");
151 | errorReport.append(firstInstallTime);
152 | errorReport.append(LINE_SEPARATOR);
153 | }
154 | String lastUpdateTime = getLastUpdateTimeAsString(context, dateFormat);
155 | if (!TextUtils.isEmpty(lastUpdateTime)) {
156 | errorReport.append("Updated On: ");
157 | errorReport.append(lastUpdateTime);
158 | errorReport.append(LINE_SEPARATOR);
159 | }
160 | errorReport.append("Current Date: ");
161 | errorReport.append(dateFormat.format(currentDate));
162 | errorReport.append(LINE_SEPARATOR);
163 | errorReport.append("\n------------ END OF LOG ------------\n");
164 | return errorReport;
165 | }
166 |
167 | private static void getExceptionHeaderInfo(ExceptionInfoBean exceptionInfoBean, @NonNull StringBuilder errorReport) {
168 | errorReport.append("------------ UCE HANDLER Library ------------");
169 | errorReport.append("\n------------ by NeXT ------------\n");
170 | errorReport.append(LINE_SEPARATOR);
171 | if (exceptionInfoBean != null) {
172 | errorReport.append("Exception Type: ");
173 | errorReport.append(LINE_SEPARATOR);
174 | errorReport.append(exceptionInfoBean.getExceptionType());
175 | errorReport.append(LINE_SEPARATOR);
176 | errorReport.append(LINE_SEPARATOR);
177 | errorReport.append("Class Name: ");
178 | errorReport.append(LINE_SEPARATOR);
179 | errorReport.append(exceptionInfoBean.getClassName()).append(".").append(exceptionInfoBean.getMethodName());
180 | errorReport.append(LINE_SEPARATOR);
181 | errorReport.append(LINE_SEPARATOR);
182 | errorReport.append("LineNumber: ").append(exceptionInfoBean.getLineNumber());
183 | errorReport.append(LINE_SEPARATOR);
184 | errorReport.append(LINE_SEPARATOR);
185 | errorReport.append("Cause: ");
186 | errorReport.append(LINE_SEPARATOR);
187 | errorReport.append(exceptionInfoBean.getCause());
188 | errorReport.append(LINE_SEPARATOR);
189 | }
190 | }
191 |
192 | private static String getVersionName(Context context) {
193 | try {
194 | PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
195 | return packageInfo.versionName;
196 | } catch (Exception e) {
197 | return "Unknown";
198 | }
199 | }
200 |
201 | private static String getFirstInstallTimeAsString(Context context, DateFormat dateFormat) {
202 | long firstInstallTime;
203 | try {
204 | firstInstallTime = context
205 | .getPackageManager()
206 | .getPackageInfo(context.getPackageName(), 0)
207 | .firstInstallTime;
208 | return dateFormat.format(new Date(firstInstallTime));
209 | } catch (PackageManager.NameNotFoundException e) {
210 | return "";
211 | }
212 | }
213 |
214 | private static String getLastUpdateTimeAsString(Context context, DateFormat dateFormat) {
215 | long lastUpdateTime;
216 | try {
217 | lastUpdateTime = context
218 | .getPackageManager()
219 | .getPackageInfo(context.getPackageName(), 0)
220 | .lastUpdateTime;
221 | return dateFormat.format(new Date(lastUpdateTime));
222 | } catch (PackageManager.NameNotFoundException e) {
223 | return "";
224 | }
225 | }
226 |
227 | }
228 |
--------------------------------------------------------------------------------
/uce_handler/src/main/res/layout/default_error_activity.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
17 |
18 |
25 |
26 |
30 |
31 |
41 |
42 |
47 |
48 |
52 |
53 |
66 |
67 |
80 |
81 |
95 |
96 |
97 |
107 |
108 |
113 |
114 |
128 |
129 |
139 |
140 |
141 |
142 |
143 |
144 |
--------------------------------------------------------------------------------
/uce_handler/src/main/res/menu/crash_info_options.xml:
--------------------------------------------------------------------------------
1 |
2 |
20 |
--------------------------------------------------------------------------------
/uce_handler/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #2b2b2b
4 | #3b3b3b
5 | #bababa
6 |
7 | #bababa
8 | #be383f
9 | #9976a8
10 | #919191
11 | #6a98b9
12 | #2b2b2b
13 |
--------------------------------------------------------------------------------
/uce_handler/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 8dp
5 | 4dp
6 |
7 | 14sp
8 |
9 |
--------------------------------------------------------------------------------
/uce_handler/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | UCE Handler
3 | An unexpected error has occurred.\nHelp developers by providing error details.\nThank you for your support.
4 | Dear Dev Team,\n\nApplication is just crashed, please check following error log for more details.\n\n\n
5 | UCE Handler\nCopyright © 2018 Rohit Sahebrao Surwase.
6 |
7 |
--------------------------------------------------------------------------------
/uce_handler_no_op/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/uce_handler_no_op/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'com.github.dcendents.android-maven'
3 | group='com.github.kingideayou'
4 | android {
5 | compileSdkVersion 27
6 |
7 |
8 |
9 | defaultConfig {
10 | minSdkVersion 14
11 | targetSdkVersion 27
12 | versionCode 1
13 | versionName "1.0"
14 |
15 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
16 |
17 | }
18 |
19 | buildTypes {
20 | release {
21 | minifyEnabled false
22 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
23 | }
24 | }
25 |
26 | }
27 |
28 | dependencies {
29 | implementation fileTree(dir: 'libs', include: ['*.jar'])
30 |
31 | implementation 'com.android.support:appcompat-v7:27.0.2'
32 | testImplementation 'junit:junit:4.12'
33 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
34 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
35 | }
36 |
--------------------------------------------------------------------------------
/uce_handler_no_op/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/uce_handler_no_op/src/androidTest/java/me/next/uce_handler_no_op/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package me.next.uce_handler_no_op;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("me.next.uce_handler_no_op.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/uce_handler_no_op/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/uce_handler_no_op/src/main/java/com/next/uceh/ExceptionInfoBean.java:
--------------------------------------------------------------------------------
1 | package com.next.uceh;
2 |
3 | /**
4 | *
5 | * author : NeXT
6 | * time : 2018/09/27
7 | * desc :
8 | *
9 | */
10 | public class ExceptionInfoBean {
11 | }
12 |
--------------------------------------------------------------------------------
/uce_handler_no_op/src/main/java/com/next/uceh/UCECallback.java:
--------------------------------------------------------------------------------
1 | package com.next.uceh;
2 |
3 | import android.support.annotation.Nullable;
4 |
5 | /**
6 | *
7 | * author : NeXT
8 | * time : 2018/09/25
9 | * desc :
10 | *
11 | */
12 | public interface UCECallback {
13 |
14 | void exceptionInfo(@Nullable ExceptionInfoBean exceptionInfoBean);
15 |
16 | void throwable(@Nullable Throwable throwable);
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/uce_handler_no_op/src/main/java/com/next/uceh/UCEHandler.java:
--------------------------------------------------------------------------------
1 | package com.next.uceh;
2 |
3 | import android.content.Context;
4 |
5 | /**
6 | *
7 | * author : NeXT
8 | * time : 2018/09/26
9 | * desc :
10 | *
11 | */
12 | public class UCEHandler {
13 |
14 | private UCEHandler(Builder builder) {
15 | }
16 |
17 | public static class Builder {
18 | private Context context;
19 | private boolean isUCEHEnabled = true;
20 | private boolean isTrackActivitiesEnabled = false;
21 | private boolean isBackgroundModeEnabled = true;
22 | private UCECallback mUCECallback = null;
23 |
24 | public Builder(Context context) {
25 | this.context = context;
26 | }
27 |
28 | public Builder setUCEHCallback(UCECallback ucehCallback) {
29 | this.mUCECallback = ucehCallback;
30 | return this;
31 | }
32 |
33 | public Builder setUCEHEnabled(boolean isUCEHEnabled) {
34 | this.isUCEHEnabled = isUCEHEnabled;
35 | return this;
36 | }
37 |
38 | public Builder setTrackActivitiesEnabled(boolean isTrackActivitiesEnabled) {
39 | this.isTrackActivitiesEnabled = isTrackActivitiesEnabled;
40 | return this;
41 | }
42 |
43 | public Builder setBackgroundModeEnabled(boolean isBackgroundModeEnabled) {
44 | this.isBackgroundModeEnabled = isBackgroundModeEnabled;
45 | return this;
46 | }
47 |
48 | public UCEHandler build() {
49 | return new UCEHandler(this);
50 | }
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/uce_handler_no_op/src/test/java/me/next/uce_handler_no_op/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package me.next.uce_handler_no_op;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------