├── .DS_Store ├── .gitignore ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── sharejoys │ │ └── crashhandlerlib │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── sharejoys │ │ │ └── crashhandlerlib │ │ │ ├── IApplication.java │ │ │ └── MainActivity.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 │ └── test │ └── java │ └── com │ └── sharejoys │ └── crashhandlerlib │ └── ExampleUnitTest.java ├── build.gradle ├── crashlib ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── sharejoys │ │ └── crashlib │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── sharejoys │ │ │ └── crashlib │ │ │ ├── CrashManager.java │ │ │ ├── ui │ │ │ ├── ExceptionCaughtAdapter.java │ │ │ └── ShowExceptionActivity.java │ │ │ └── util │ │ │ ├── CrashFileHelper.java │ │ │ ├── CrashFileProvider.java │ │ │ └── CrashHelper.java │ └── res │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ └── crash_lib_activity_show_exception.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_back_crash_lib_activity.png │ │ ├── ic_launcher.png │ │ ├── ic_launcher_round.png │ │ └── ic_share_crash_lib_activity.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 │ │ └── xml │ │ └── provider_paths.xml │ └── test │ └── java │ └── com │ └── sharejoys │ └── crashlib │ └── ExampleUnitTest.java ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── local.properties └── settings.gradle /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuikes/CrashHandler/e45cd1fae680f715844ab506ffb91a4aa8868fd8/.DS_Store -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the ART/Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | out/ 15 | .idea/ 16 | 17 | # Gradle files 18 | .gradle/ 19 | build/ 20 | 21 | # Local configuration file (sdk path, etc) 22 | local.properties 23 | 24 | # Proguard folder generated by Eclipse 25 | proguard/ 26 | 27 | # Log Files 28 | *.log 29 | 30 | # Android Studio Navigation editor temp files 31 | .navigation/ 32 | 33 | # Android Studio captures folder 34 | captures/ 35 | 36 | # Intellij 37 | *.iml 38 | .idea/workspace.xml 39 | .idea/tasks.xml 40 | .idea/gradle.xml 41 | .idea/dictionaries 42 | .idea/libraries 43 | 44 | # Keystore files 45 | *.jks 46 | 47 | # External native build folder generated in Android Studio 2.2 and later 48 | .externalNativeBuild 49 | 50 | # Google Services (e.g. APIs or Firebase) 51 | google-services.json 52 | 53 | # Freeline 54 | freeline.py 55 | freeline/ 56 | freeline_project_description.json 57 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | CrashHandlerLib 2 | ====== 3 | 一个基于UncaughtExceptionHandler实现的Android奔溃日志捕获依赖库,使用该库可以显性的将奔溃日志展示出来,有助于开发以及测试人员在工作中及时定位奔溃问题.同时支持将奔溃日志分享到微信、QQ等第三方。 4 | 5 | 使用手册 6 | ====== 7 | 8 | step 1.在根目录 build.gradle 上添加配置 9 | -------- 10 | allprojects { 11 | repositories { 12 | ... 13 | maven { url 'https://jitpack.io' } 14 | } 15 | } 16 | step 2.在当前module的build.gradle添加如下依赖 17 | -------- 18 | dependencies { 19 | implementation 'com.github.tuikes:CrashHandler:v2.1' 20 | } 21 | 22 | step 3.在Application中完成初始化 23 | -------- 24 | @Override 25 | public void onCreate() { 26 | super.onCreate(); 27 | CrashManager.getInstance().init(this, BuildConfig.DEBUG); 28 | } 29 | 30 | 效果演示 31 | ====== 32 | step 1.测试代码源码 33 | -------- 34 | 1>>>奔溃日志文件分享到QQ、微信等第三方: 35 | 36 | CrashManager.getInstance().shareCrashFile(MainActivity.this); 37 | 38 | 2>>>类型为TextView的result控件没有findViewById导致奔溃 39 | 40 | @Override 41 | protected void onCreate(Bundle savedInstanceState) { 42 | super.onCreate(savedInstanceState); 43 | setContentView(R.layout.activity_main); 44 | test = findViewById(R.id.test); 45 | 46 | test.setOnClickListener(new View.OnClickListener() { 47 | @Override 48 | public void onClick(View v) { 49 | Log.d("cdx", test2.getText().toString()); 50 | } 51 | }); 52 | 53 | findViewById(R.id.share_crash_file).setOnClickListener(new View.OnClickListener() { 54 | @Override 55 | public void onClick(View v) { 56 | //将奔溃信息分享到第三方 57 | CrashManager.getInstance().shareCrashFile(MainActivity.this); 58 | } 59 | }); 60 | } 61 | 62 | 63 | step 2.运行查看效果 64 | -------- 65 | ![ABC](https://github.com/tuikes/MarkdownPhotos/blob/master/crashHandlerLibTest.gif) 66 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 27 5 | defaultConfig { 6 | applicationId "com.sharejoys.crashhandlerlib" 7 | minSdkVersion 15 8 | targetSdkVersion 27 9 | versionCode 1 10 | versionName "1.0" 11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | implementation fileTree(include: ['*.jar'], dir: 'libs') 23 | implementation 'com.android.support:appcompat-v7:27.1.1' 24 | implementation 'com.android.support.constraint:constraint-layout:1.1.0' 25 | testImplementation 'junit:junit:4.12' 26 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 27 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 28 | // implementation project(':crashlib') 29 | 30 | //奔溃日志捕获显示 31 | api "com.github.tuikes:CrashHandler:v2.3.1" 32 | } 33 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/sharejoys/crashhandlerlib/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.sharejoys.crashhandlerlib; 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() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.sharejoys.crashhandlerlib", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /app/src/main/java/com/sharejoys/crashhandlerlib/IApplication.java: -------------------------------------------------------------------------------- 1 | package com.sharejoys.crashhandlerlib; 2 | 3 | import android.app.Application; 4 | import android.content.Context; 5 | 6 | import com.sharejoys.crashlib.CrashManager; 7 | 8 | import java.lang.annotation.ElementType; 9 | import java.lang.annotation.Retention; 10 | import java.lang.annotation.RetentionPolicy; 11 | import java.lang.annotation.Target; 12 | 13 | /** 14 | * 应用Application 15 | * Created by chendx on 2017/5/18. 16 | */ 17 | 18 | public class IApplication extends Application { 19 | /** 20 | * 应用上下文 21 | */ 22 | private static IApplication gInstance; 23 | 24 | /** 25 | * 获取应用上下文 26 | * 27 | * @return 应用上下文 28 | */ 29 | public static IApplication getInstance() { 30 | return gInstance; 31 | } 32 | 33 | 34 | @Override 35 | public void onCreate() { 36 | super.onCreate(); 37 | if (gInstance != null) { 38 | gInstance = this; 39 | return; 40 | } 41 | gInstance = this; 42 | CrashManager.getInstance().init(this, BuildConfig.DEBUG); 43 | } 44 | 45 | @Override 46 | protected void attachBaseContext(Context base) { 47 | super.attachBaseContext(base); 48 | } 49 | 50 | @Retention(RetentionPolicy.RUNTIME) 51 | @Target(ElementType.FIELD) 52 | public @interface Manager { 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /app/src/main/java/com/sharejoys/crashhandlerlib/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.sharejoys.crashhandlerlib; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.util.Log; 6 | import android.view.View; 7 | import android.widget.Button; 8 | 9 | import com.sharejoys.crashlib.CrashManager; 10 | 11 | public class MainActivity extends AppCompatActivity { 12 | private Button test; 13 | private Button test2; 14 | 15 | @Override 16 | protected void onCreate(Bundle savedInstanceState) { 17 | super.onCreate(savedInstanceState); 18 | setContentView(R.layout.activity_main); 19 | test = findViewById(R.id.test); 20 | 21 | test.setOnClickListener(new View.OnClickListener() { 22 | @Override 23 | public void onClick(View v) { 24 | Log.d("cdx", test2.getText().toString()); 25 | } 26 | }); 27 | 28 | findViewById(R.id.share_crash_file).setOnClickListener(new View.OnClickListener() { 29 | @Override 30 | public void onClick(View v) { 31 | //将奔溃信息分享到第三方 32 | CrashManager.getInstance().shareCrashFile(MainActivity.this); 33 | } 34 | }); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 |