├── app ├── .gitignore ├── src │ └── main │ │ ├── res │ │ ├── values │ │ │ ├── strings.xml │ │ │ ├── colors.xml │ │ │ └── styles.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 │ │ ├── mipmap-anydpi-v26 │ │ │ ├── ic_launcher.xml │ │ │ └── ic_launcher_round.xml │ │ ├── layout │ │ │ └── activity_main.xml │ │ ├── drawable-v24 │ │ │ └── ic_launcher_foreground.xml │ │ └── drawable │ │ │ └── ic_launcher_background.xml │ │ ├── java │ │ └── com │ │ │ └── dhcc │ │ │ └── test │ │ │ ├── TestCollectInfo.java │ │ │ ├── MainActivity.java │ │ │ └── MyApplication.java │ │ └── AndroidManifest.xml ├── proguard-rules.pro └── build.gradle ├── CrashLib ├── .gitignore ├── src │ └── main │ │ ├── res │ │ ├── values │ │ │ ├── strings.xml │ │ │ └── public.xml │ │ └── xml │ │ │ └── network_security_config.xml │ │ ├── java │ │ └── com │ │ │ └── dhcc │ │ │ └── crashlib │ │ │ ├── data │ │ │ ├── ICollector.java │ │ │ ├── ReportData.java │ │ │ └── DeviceCollectInfo.java │ │ │ ├── service │ │ │ ├── SerializableHashMap.java │ │ │ └── CrashService.java │ │ │ ├── log │ │ │ ├── CrashLogConfig.java │ │ │ ├── CrashLogBean.java │ │ │ ├── CrashLoggerClient.java │ │ │ └── SaveCrashLogImpl.java │ │ │ ├── send │ │ │ ├── email │ │ │ │ ├── MailConfig.java │ │ │ │ ├── EmailConfigBean.java │ │ │ │ └── EmailSender.java │ │ │ ├── SendWorker.java │ │ │ └── net │ │ │ │ └── NetSender.java │ │ │ ├── utils │ │ │ ├── SingleTaskPool.java │ │ │ └── HttpConnectionUtil.java │ │ │ ├── Configuration.java │ │ │ └── LogCenter.java │ │ └── AndroidManifest.xml ├── build.gradle └── proguard-rules.pro ├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .idea ├── encodings.xml ├── vcs.xml ├── runConfigurations.xml ├── gradle.xml ├── inspectionProfiles │ └── Project_Default.xml ├── codeStyles │ └── Project.xml ├── misc.xml └── dbnavigator.xml ├── .gitignore ├── gradle.properties ├── gradlew.bat ├── gradlew └── README.md /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /CrashLib/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':CrashLib' 2 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 测试CrashLib 3 | 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasoncool/DhccCrashLib/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasoncool/DhccCrashLib/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasoncool/DhccCrashLib/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasoncool/DhccCrashLib/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasoncool/DhccCrashLib/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasoncool/DhccCrashLib/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasoncool/DhccCrashLib/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasoncool/DhccCrashLib/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasoncool/DhccCrashLib/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasoncool/DhccCrashLib/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasoncool/DhccCrashLib/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches/build_file_checksums.ser 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | .DS_Store 9 | /build 10 | /captures 11 | .externalNativeBuild 12 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #008577 4 | #00574B 5 | #D81B60 6 | 7 | -------------------------------------------------------------------------------- /CrashLib/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | smtp 3 | smtp.163.com 4 | true 5 | 6 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri May 10 09:38:32 CST 2019 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.7-all.zip 7 | -------------------------------------------------------------------------------- /CrashLib/src/main/res/values/public.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /CrashLib/src/main/res/xml/network_security_config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/java/com/dhcc/test/TestCollectInfo.java: -------------------------------------------------------------------------------- 1 | package com.dhcc.test; 2 | 3 | import android.content.Context; 4 | 5 | import com.dhcc.crashlib.data.ICollector; 6 | 7 | public class TestCollectInfo implements ICollector { 8 | @Override 9 | public String collectInfo(Context context) { 10 | return "这是一条测试采集异常信息"; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /CrashLib/src/main/java/com/dhcc/crashlib/data/ICollector.java: -------------------------------------------------------------------------------- 1 | package com.dhcc.crashlib.data; 2 | 3 | import android.content.Context; 4 | import android.util.ArrayMap; 5 | 6 | public interface ICollector { 7 | /** 8 | * 用来存储采集信息的ArrayMap 9 | */ 10 | ArrayMap CRASH_INFO_MAP = new ArrayMap<>(); 11 | String collectInfo(Context context); 12 | } 13 | -------------------------------------------------------------------------------- /CrashLib/src/main/java/com/dhcc/crashlib/data/ReportData.java: -------------------------------------------------------------------------------- 1 | package com.dhcc.crashlib.data; 2 | 3 | import android.content.Context; 4 | 5 | public class ReportData { 6 | private ICollector iCollector; 7 | public ReportData(ICollector iCollector){ 8 | this.iCollector=iCollector; 9 | } 10 | public String collectInfo(Context context){ 11 | return iCollector.collectInfo(context); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /CrashLib/src/main/java/com/dhcc/crashlib/service/SerializableHashMap.java: -------------------------------------------------------------------------------- 1 | package com.dhcc.crashlib.service; 2 | 3 | import java.io.Serializable; 4 | import java.util.HashMap; 5 | 6 | public class SerializableHashMap implements Serializable { 7 | 8 | private HashMap map; 9 | 10 | public HashMap getMap() { 11 | return map; 12 | } 13 | 14 | public void setMap(HashMap map) { 15 | this.map = map; 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /CrashLib/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 7 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /CrashLib/src/main/java/com/dhcc/crashlib/log/CrashLogConfig.java: -------------------------------------------------------------------------------- 1 | package com.dhcc.crashlib.log; 2 | 3 | /** 4 | * @author jasoncool 5 | * 崩溃日志的设置文件 6 | */ 7 | class CrashLogConfig { 8 | 9 | private CrashLogConfig(){ 10 | 11 | } 12 | /** 13 | * 是否记录崩溃信息到本地文件 14 | */ 15 | static final boolean ISRECORD = true; 16 | /** 17 | * 单个本地文件的最大的容量 18 | */ 19 | static final int MAX_BYTES = 1024 * 1024; 20 | /** 21 | * 崩溃信息存储的文件夹名 22 | */ 23 | static final String LOG_FLODER_NAME="crash_log"; 24 | 25 | /** 26 | * 崩溃信息存储的文件名 27 | */ 28 | static final String LOG_FILE_NAME="crashLogs"; 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 20 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx1536m 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | android.useAndroidX=true 15 | android.enableJetifier=true 16 | 17 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /CrashLib/src/main/java/com/dhcc/crashlib/log/CrashLogBean.java: -------------------------------------------------------------------------------- 1 | package com.dhcc.crashlib.log; 2 | 3 | /** 4 | * @author jasoncool 5 | * 崩溃信息的实例 6 | */ 7 | public class CrashLogBean { 8 | /** 9 | * 崩溃信息 10 | */ 11 | private String message; 12 | /** 13 | * 崩溃信息写入本地文件后的回调接口 14 | */ 15 | private SaveCrashLogImpl.IFileCloseListener iFileCloseListener; 16 | 17 | public String getMessage() { 18 | return message; 19 | } 20 | 21 | public void setMessage(String message) { 22 | this.message = message; 23 | } 24 | 25 | public SaveCrashLogImpl.IFileCloseListener getiFileCloseListener() { 26 | return iFileCloseListener; 27 | } 28 | 29 | public void setiFileCloseListener(SaveCrashLogImpl.IFileCloseListener iFileCloseListener) { 30 | this.iFileCloseListener = iFileCloseListener; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 28 5 | defaultConfig { 6 | applicationId "com.dhcc.crashlib" 7 | minSdkVersion 21 8 | targetSdkVersion 28 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(dir: 'libs', include: ['*.jar']) 23 | implementation 'androidx.appcompat:appcompat:1.0.2' 24 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3' 25 | implementation project(':CrashLib') 26 | implementation 'com.github.zhaokaiqiang.klog:library:1.6.0' 27 | //Email的发送组件 28 | implementation "com.sun.mail:android-mail:1.6.0" 29 | } 30 | -------------------------------------------------------------------------------- /CrashLib/src/main/java/com/dhcc/crashlib/send/email/MailConfig.java: -------------------------------------------------------------------------------- 1 | package com.dhcc.crashlib.send.email; 2 | 3 | /** 4 | * @author jasoncool 5 | * 邮件配置文件 6 | */ 7 | public class MailConfig { 8 | 9 | private MailConfig() { 10 | 11 | } 12 | 13 | static String MAIL_PROTOCOL_PROPERTY = "mail.transport.protocol"; 14 | static String MAIL_HOST_PROPERTY = "mail.smtp.host"; 15 | static String MAIL_PORT_PROPERTY = "mail.smtp.port"; 16 | static String MAIL_AUTH_PROPERTY = "mail.smtp.auth"; 17 | static String MAIL_TIME_OUT_PROPERTY = "mail.smtp.timeout"; 18 | 19 | 20 | /* static String MAIL_PROTOCOL_VALUE="smtp"; 21 | static String MAIL_HOST_VALUE="smtp.163.com"; 22 | static String MAIL_PORT_VALUE="25"; 23 | static String MAIL_AUTH_VALUE="true"; 24 | static String MAIL_TIME_OUT_VALUE="5000"; 25 | 26 | *//** 27 | 收件人电子邮箱 28 | *//* 29 | static String MAIL_TO_ADDRESS = "jasoncool_521@qq.com"; 30 | *//** 31 | * 发件人电子邮箱 32 | *//* 33 | static String MAIL_FROM_ADDRESS = "jasoncool_521@163.com"; 34 | 35 | static String MAIL_FROM_PASSWORD="7758521@";*/ 36 | 37 | } 38 | -------------------------------------------------------------------------------- /CrashLib/src/main/java/com/dhcc/crashlib/send/SendWorker.java: -------------------------------------------------------------------------------- 1 | package com.dhcc.crashlib.send; 2 | 3 | import android.content.Context; 4 | 5 | import androidx.annotation.Nullable; 6 | 7 | import com.dhcc.crashlib.send.email.EmailConfigBean; 8 | import com.dhcc.crashlib.send.email.EmailSender; 9 | import com.dhcc.crashlib.send.net.NetSender; 10 | import com.socks.library.KLog; 11 | 12 | import java.io.File; 13 | import java.util.HashMap; 14 | 15 | public enum SendWorker { 16 | 17 | /** 18 | * 单例 19 | */ 20 | INSTANCE; 21 | 22 | public void sendWithEmail(Context context, EmailConfigBean emailConfigBean, String content, @Nullable File file){ 23 | 24 | if(file==null||!file.exists()){ 25 | KLog.e("发送的文件不能为空!"); 26 | return; 27 | } 28 | EmailSender.INSTANCE.sendLogWithFile(context,emailConfigBean,content,file); 29 | } 30 | 31 | public void sendWithEmail(Context context, EmailConfigBean emailConfigBean,String content){ 32 | EmailSender.INSTANCE.sendLog(context,emailConfigBean,content); 33 | } 34 | 35 | 36 | public String sendToServer(Context context,String crashServerUrl,HashMap contentArray){ 37 | return NetSender.INSTANCE.sendLog(context,crashServerUrl,contentArray); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 |