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/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/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/.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..28a09f8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'com.android.application' android { compileSdkVersion 22 - buildToolsVersion "23.0.3" + buildToolsVersion "26.0.2" defaultConfig { applicationId "com.wenming.crashcachedemo" 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/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..afc049e 100644 --- a/logreport/build.gradle +++ b/logreport/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'com.android.library' android { compileSdkVersion 22 - buildToolsVersion "23.0.3" + buildToolsVersion "26.0.2" defaultConfig { minSdkVersion 14 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());