From 0d71432be7a5f61d1e1995646fd21209a93e3d82 Mon Sep 17 00:00:00 2001 From: zhujinhu Date: Thu, 7 Jun 2018 12:10:15 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=B2=A1=E6=9C=89=E5=B4=A9=E6=BA=83?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E4=B9=9F=E5=8F=AF=E4=BB=A5=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/gradle.xml | 8 +-- .idea/misc.xml | 49 +------------------ .idea/vcs.xml | 2 +- app/build.gradle | 14 ++++-- build.gradle | 2 +- gradle.properties | 1 + gradle/wrapper/gradle-wrapper.properties | 5 +- logreport/build.gradle | 14 ++++-- .../java/com/wenming/library/LogReport.java | 10 ++++ .../wenming/library/upload/UploadService.java | 18 +++++-- 10 files changed, 49 insertions(+), 74 deletions(-) diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 50f9773..e13b496 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -12,13 +12,7 @@ - + diff --git a/.idea/misc.xml b/.idea/misc.xml index 51959bf..885bd34 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,15 +1,5 @@ - - - - - - - - - - - - - - - - - + - - - - - 1.7 - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml index 94a25f7..35eb1dd 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index f68935d..61735be 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,13 +1,13 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 22 - buildToolsVersion "23.0.3" + compileSdkVersion 19 + buildToolsVersion "26.0.2" defaultConfig { applicationId "com.wenming.crashcachedemo" minSdkVersion 14 - targetSdkVersion 22 + targetSdkVersion 19 versionCode 1 versionName "1.0" } @@ -17,11 +17,15 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_7 + targetCompatibility JavaVersion.VERSION_1_7 + } } dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) + compile fileTree(include: ['*.jar'], dir: 'libs') testCompile 'junit:junit:4.12' - compile 'com.android.support:appcompat-v7:22.2.1' + compile 'com.android.support:appcompat-v7:26.1.0' compile project(path: ':logreport') } diff --git a/build.gradle b/build.gradle index 12e80f1..55db7aa 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.1.0' + classpath 'com.android.tools.build:gradle:3.0.1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } diff --git a/gradle.properties b/gradle.properties index 1dc775f..a712dd9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -18,3 +18,4 @@ systemProp.http.proxyPort=1080 org.gradle.jvmargs=-Xmx3062m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 org.gradle.parallel=true org.gradle.daemon=true +android.enableAapt2=false diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 122a0dc..a6ae57b 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ -#Mon Dec 28 10:00:20 PST 2015 +#Thu Jun 07 11:54:53 CST 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip +#distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip \ No newline at end of file diff --git a/logreport/build.gradle b/logreport/build.gradle index 828b8e2..d859cd3 100644 --- a/logreport/build.gradle +++ b/logreport/build.gradle @@ -1,19 +1,23 @@ apply plugin: 'com.android.library' android { - compileSdkVersion 22 - buildToolsVersion "23.0.3" + compileSdkVersion 19 + buildToolsVersion "26.0.2" defaultConfig { minSdkVersion 14 - targetSdkVersion 22 + targetSdkVersion 19 versionCode 1 versionName "1.0" } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_7 + targetCompatibility JavaVersion.VERSION_1_7 + } } dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) + compile fileTree(include: ['*.jar'], dir: 'libs') testCompile 'junit:junit:4.12' - compile 'com.android.support:appcompat-v7:22.2.1' + compile 'com.android.support:appcompat-v7:26.1.0' } diff --git a/logreport/src/main/java/com/wenming/library/LogReport.java b/logreport/src/main/java/com/wenming/library/LogReport.java index a92e56a..62db04a 100644 --- a/logreport/src/main/java/com/wenming/library/LogReport.java +++ b/logreport/src/main/java/com/wenming/library/LogReport.java @@ -49,6 +49,10 @@ public class LogReport { */ private boolean mWifiOnly = true; + /** + * 设置是否在奔溃下才上传,true为只在奔溃模式下上传,false是都上传 + */ + private boolean mCrashOnly=true; private LogReport() { } @@ -85,6 +89,11 @@ public LogReport setWifiOnly(boolean wifiOnly) { return this; } + public LogReport setCrashOnly(boolean crashOnly) { + mCrashOnly = crashOnly; + return this; + } + public LogReport setLogDir(Context context, String logDir) { if (TextUtils.isEmpty(logDir)) { @@ -149,6 +158,7 @@ public void upload(Context applicationContext) { return; } Intent intent = new Intent(applicationContext, UploadService.class); + intent.putExtra("mCrashOnly", mCrashOnly); applicationContext.startService(intent); } diff --git a/logreport/src/main/java/com/wenming/library/upload/UploadService.java b/logreport/src/main/java/com/wenming/library/upload/UploadService.java index e4bc7fa..0c17ef3 100644 --- a/logreport/src/main/java/com/wenming/library/upload/UploadService.java +++ b/logreport/src/main/java/com/wenming/library/upload/UploadService.java @@ -20,7 +20,7 @@ public class UploadService extends IntentService { public static final String TAG = "UploadService"; - + boolean mCrashOnly; /** * 压缩包名称的一部分:时间戳 */ @@ -39,6 +39,11 @@ public void onCreate() { super.onCreate(); } + @Override + public int onStartCommand(Intent intent, int flags, int startId) { + mCrashOnly = intent.getBooleanExtra("mCrashOnly",true); + return super.onStartCommand(intent, flags, startId); + } /** * 同一时间只会有一个耗时任务被执行,其他的请求还要在后面排队, * onHandleIntent()方法不会多线程并发执行,所有无需考虑同步问题 @@ -53,12 +58,15 @@ protected void onHandleIntent(Intent intent) { LogUtil.d("Log文件夹都不存在,无需上传"); return; } - //只存在log文件,但是不存在崩溃日志,也不会上传 ArrayList crashFileList = FileUtil.getCrashList(logfolder); - if (crashFileList.size() == 0) { - LogUtil.d(TAG, "只存在log文件,但是不存在崩溃日志,所以不上传"); - return; + if(mCrashOnly){ + //只存在log文件,但是不存在崩溃日志,也不会上传 + if (crashFileList.size() == 0) { + LogUtil.d(TAG, "只存在log文件,但是不存在崩溃日志,所以不上传"); + return; + } } + File zipfolder = new File(LogReport.getInstance().getROOT() + "AlreadyUploadLog/"); File zipfile = new File(zipfolder, "UploadOn" + ZIP_FOLDER_TIME_FORMAT.format(System.currentTimeMillis()) + ".zip"); final File rootdir = new File(LogReport.getInstance().getROOT()); From 7883b6491fd9a9cfd2648cde7b9f6157feba1e16 Mon Sep 17 00:00:00 2001 From: zhujinhu Date: Thu, 7 Jun 2018 14:32:08 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/.name | 1 - .idea/compiler.xml | 23 ------------------- .idea/copyright/profiles_settings.xml | 3 --- .idea/dictionaries/wenmingvs.xml | 3 --- .idea/encodings.xml | 6 ----- .idea/inspectionProfiles/Project_Default.xml | 13 ----------- .../inspectionProfiles/profiles_settings.xml | 7 ------ app/build.gradle | 12 ++++------ .../wenming/crashcachedemo/MyApplication.java | 3 ++- logreport/build.gradle | 12 ++++------ 10 files changed, 10 insertions(+), 73 deletions(-) delete mode 100644 .idea/.name delete mode 100644 .idea/compiler.xml delete mode 100644 .idea/copyright/profiles_settings.xml delete mode 100644 .idea/dictionaries/wenmingvs.xml delete mode 100644 .idea/encodings.xml delete mode 100644 .idea/inspectionProfiles/Project_Default.xml delete mode 100644 .idea/inspectionProfiles/profiles_settings.xml diff --git a/.idea/.name b/.idea/.name deleted file mode 100644 index e70611d..0000000 --- a/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -LogReport \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml deleted file mode 100644 index 734b743..0000000 --- a/.idea/compiler.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml deleted file mode 100644 index e7bedf3..0000000 --- a/.idea/copyright/profiles_settings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/.idea/dictionaries/wenmingvs.xml b/.idea/dictionaries/wenmingvs.xml deleted file mode 100644 index 9ff1912..0000000 --- a/.idea/dictionaries/wenmingvs.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml deleted file mode 100644 index 97626ba..0000000 --- a/.idea/encodings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml deleted file mode 100644 index 6c0f412..0000000 --- a/.idea/inspectionProfiles/Project_Default.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml deleted file mode 100644 index 3b31283..0000000 --- a/.idea/inspectionProfiles/profiles_settings.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 61735be..28a09f8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,13 +1,13 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 19 + compileSdkVersion 22 buildToolsVersion "26.0.2" defaultConfig { applicationId "com.wenming.crashcachedemo" minSdkVersion 14 - targetSdkVersion 19 + targetSdkVersion 22 versionCode 1 versionName "1.0" } @@ -17,15 +17,11 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_7 - targetCompatibility JavaVersion.VERSION_1_7 - } } dependencies { - compile fileTree(include: ['*.jar'], dir: 'libs') + compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' - compile 'com.android.support:appcompat-v7:26.1.0' + compile 'com.android.support:appcompat-v7:22.2.1' compile project(path: ':logreport') } diff --git a/app/src/main/java/com/wenming/crashcachedemo/MyApplication.java b/app/src/main/java/com/wenming/crashcachedemo/MyApplication.java index 4e19339..6b64b9d 100644 --- a/app/src/main/java/com/wenming/crashcachedemo/MyApplication.java +++ b/app/src/main/java/com/wenming/crashcachedemo/MyApplication.java @@ -22,6 +22,7 @@ private void initCrashReport() { .setCacheSize(30 * 1024 * 1024)//支持设置缓存大小,超出后清空 .setLogDir(getApplicationContext(), "sdcard/" + this.getString(this.getApplicationInfo().labelRes) + "/")//定义路径为:sdcard/[app name]/ .setWifiOnly(true)//设置只在Wifi状态下上传,设置为false为Wifi和移动网络都上传 + .setCrashOnly(false) .setLogSaver(new CrashWriter(getApplicationContext()))//支持自定义保存崩溃信息的样式 //.setEncryption(new AESEncode()) //支持日志到AES加密或者DES加密,默认不开启 .init(getApplicationContext()); @@ -33,7 +34,7 @@ private void initCrashReport() { */ private void initEmailReporter() { EmailReporter email = new EmailReporter(this); - email.setReceiver("wenmingvs@gmail.com");//收件人 + email.setReceiver("zhujinhu21@163.com");//收件人 email.setSender("wenmingvs@163.com");//发送人邮箱 email.setSendPassword("apptest1234");//邮箱密码 email.setSMTPHost("smtp.163.com");//SMTP地址 diff --git a/logreport/build.gradle b/logreport/build.gradle index d859cd3..afc049e 100644 --- a/logreport/build.gradle +++ b/logreport/build.gradle @@ -1,23 +1,19 @@ apply plugin: 'com.android.library' android { - compileSdkVersion 19 + compileSdkVersion 22 buildToolsVersion "26.0.2" defaultConfig { minSdkVersion 14 - targetSdkVersion 19 + targetSdkVersion 22 versionCode 1 versionName "1.0" } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_7 - targetCompatibility JavaVersion.VERSION_1_7 - } } dependencies { - compile fileTree(include: ['*.jar'], dir: 'libs') + compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' - compile 'com.android.support:appcompat-v7:26.1.0' + compile 'com.android.support:appcompat-v7:22.2.1' }