Skip to content

Commit 69f3131

Browse files
author
TutorialsAndroid
committed
UPDATED DEPENDENCIES
1 parent 9c72429 commit 69f3131

File tree

10 files changed

+108
-137
lines changed

10 files changed

+108
-137
lines changed

Diff for: .github/workflows/android.yml

-17
This file was deleted.

Diff for: README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
![](https://github.com/TutorialsAndroid/crashx/blob/master/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png)
22

3-
# CrashX [![API](https://img.shields.io/badge/API-21%2B-brightgreen.svg?style=flat)](https://android-arsenal.com/api?level=21) [![Known Vulnerabilities](https://snyk.io/test/github/TutorialsAndroid/CrashX/badge.svg?targetFile=library%2Fbuild.gradle)](https://snyk.io/test/github/TutorialsAndroid/CrashX?targetFile=library%2Fbuild.gradle) [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-CrashX-red.svg?style=flat-square)](https://android-arsenal.com/details/1/7581) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://GitHub.com/TutorialsAndroid/crashx)
3+
# CrashX [![API](https://img.shields.io/badge/API-15%2B-brightgreen.svg?style=flat)](https://android-arsenal.com/api?level=15) [![Known Vulnerabilities](https://snyk.io/test/github/TutorialsAndroid/CrashX/badge.svg?targetFile=library%2Fbuild.gradle)](https://snyk.io/test/github/TutorialsAndroid/CrashX?targetFile=library%2Fbuild.gradle) [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-CrashX-red.svg?style=flat-square)](https://android-arsenal.com/details/1/7581) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://GitHub.com/TutorialsAndroid/crashx)
44

55
This library allows launching a crash activity when the app crashes, instead of showing the hated "Unfortunately, X has stopped" dialog.
66

@@ -32,7 +32,7 @@ Add it in your root build.gradle at the end of repositories:
3232
Step 2. Add the dependency
3333

3434
dependencies {
35-
implementation 'com.github.TutorialsAndroid:crashx:v4.0.19'
35+
implementation 'com.github.TutorialsAndroid:crashx:v5.0.19'
3636
}
3737

3838
...and you are done!

Diff for: build.gradle

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ buildscript {
44
jcenter()
55
}
66
dependencies {
7-
classpath 'com.android.tools.build:gradle:3.4.1'
7+
classpath 'com.android.tools.build:gradle:3.6.3'
88
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
99
}
1010
}
@@ -13,6 +13,10 @@ allprojects {
1313
repositories {
1414
google()
1515
jcenter()
16+
mavenCentral()
17+
maven {
18+
url 'https://jitpack.io'
19+
}
1620
}
1721
}
1822

Diff for: gradle/wrapper/gradle-wrapper.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Mon Nov 13 17:16:27 CET 2017
1+
#Sat Jan 20 01:13:22 IRST 2018
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip

Diff for: library/build.gradle

+12-8
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,31 @@ android {
88
resourcePrefix 'crash_'
99

1010
defaultConfig {
11-
minSdkVersion 21
11+
minSdkVersion 15
1212
targetSdkVersion 29
13-
versionCode 7
14-
versionName "4.0.19"
13+
versionCode 8
14+
versionName "5.0.19"
1515
}
1616
buildTypes {
1717
release {
1818
minifyEnabled false
1919
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
2020
}
2121
}
22+
compileOptions {
23+
sourceCompatibility 1.8
24+
targetCompatibility 1.8
25+
}
2226
}
2327

2428
dependencies {
2529
implementation fileTree(include: ['*.jar'], dir: 'libs')
2630

27-
//ANDROID SUPPORT LIBRARIES
28-
implementation 'androidx.appcompat:appcompat:1.0.2'
31+
//ANDROIDX JETPACK LIBRARIES
32+
implementation 'androidx.appcompat:appcompat:1.1.0'
2933
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
30-
implementation 'androidx.recyclerview:recyclerview:1.0.0'
31-
implementation 'com.google.android.material:material:1.0.0'
32-
implementation 'androidx.preference:preference:1.0.0'
34+
implementation 'androidx.recyclerview:recyclerview:1.1.0'
35+
implementation 'com.google.android.material:material:1.1.0'
36+
implementation 'androidx.preference:preference:1.1.1'
3337
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
3438
}

Diff for: library/src/main/java/com/developer/crashx/CrashActivity.java

+58-61
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import com.developer.crashx.config.CrashConfig;
3434

3535
/**
36-
* @author akshay sunil masram
36+
* @author tkdco , TutorialsAndroid
3737
*/
3838
public final class CrashActivity {
3939

@@ -81,81 +81,78 @@ public static void install(@Nullable final Context context) {
8181

8282
application = (Application) context.getApplicationContext();
8383

84-
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
85-
@Override
86-
public void uncaughtException(Thread thread, final Throwable throwable) {
87-
if (config.isEnabled()) {
88-
Log.e(TAG, "App has crashed, executing CrashActivity's UncaughtExceptionHandler", throwable);
84+
Thread.setDefaultUncaughtExceptionHandler((thread, throwable) -> {
85+
if (config.isEnabled()) {
86+
Log.e(TAG, "App has crashed, executing CrashActivity's UncaughtExceptionHandler", throwable);
87+
88+
if (hasCrashedInTheLastSeconds(application)) {
89+
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);
90+
if (oldHandler != null) {
91+
oldHandler.uncaughtException(thread, throwable);
92+
return;
93+
}
94+
} else {
95+
setLastCrashTimestamp(application, new Date().getTime());
96+
97+
Class<? extends Activity> errorActivityClass = config.getErrorActivityClass();
98+
99+
if (errorActivityClass == null) {
100+
errorActivityClass = guessErrorActivityClass(application);
101+
}
89102

90-
if (hasCrashedInTheLastSeconds(application)) {
91-
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);
103+
if (isStackTraceLikelyConflictive(throwable, errorActivityClass)) {
104+
Log.e(TAG, "Your application class or your error activity have crashed, the custom activity will not be launched!");
92105
if (oldHandler != null) {
93106
oldHandler.uncaughtException(thread, throwable);
94107
return;
95108
}
96-
} else {
97-
setLastCrashTimestamp(application, new Date().getTime());
109+
} else if (config.getBackgroundMode() == CrashConfig.BACKGROUND_MODE_SHOW_CUSTOM || !isInBackground) {
98110

99-
Class<? extends Activity> errorActivityClass = config.getErrorActivityClass();
111+
final Intent intent = new Intent(application, errorActivityClass);
112+
StringWriter sw = new StringWriter();
113+
PrintWriter pw = new PrintWriter(sw);
114+
throwable.printStackTrace(pw);
115+
String stackTraceString = sw.toString();
100116

101-
if (errorActivityClass == null) {
102-
errorActivityClass = guessErrorActivityClass(application);
117+
if (stackTraceString.length() > MAX_STACK_TRACE_SIZE) {
118+
String disclaimer = " [stack trace too large]";
119+
stackTraceString = stackTraceString.substring(0, MAX_STACK_TRACE_SIZE - disclaimer.length()) + disclaimer;
103120
}
121+
intent.putExtra(EXTRA_STACK_TRACE, stackTraceString);
104122

105-
if (isStackTraceLikelyConflictive(throwable, errorActivityClass)) {
106-
Log.e(TAG, "Your application class or your error activity have crashed, the custom activity will not be launched!");
107-
if (oldHandler != null) {
108-
oldHandler.uncaughtException(thread, throwable);
109-
return;
110-
}
111-
} else if (config.getBackgroundMode() == CrashConfig.BACKGROUND_MODE_SHOW_CUSTOM || !isInBackground) {
112-
113-
final Intent intent = new Intent(application, errorActivityClass);
114-
StringWriter sw = new StringWriter();
115-
PrintWriter pw = new PrintWriter(sw);
116-
throwable.printStackTrace(pw);
117-
String stackTraceString = sw.toString();
118-
119-
if (stackTraceString.length() > MAX_STACK_TRACE_SIZE) {
120-
String disclaimer = " [stack trace too large]";
121-
stackTraceString = stackTraceString.substring(0, MAX_STACK_TRACE_SIZE - disclaimer.length()) + disclaimer;
122-
}
123-
intent.putExtra(EXTRA_STACK_TRACE, stackTraceString);
124-
125-
if (config.isTrackActivities()) {
126-
StringBuilder activityLogStringBuilder = new StringBuilder();
127-
while (!activityLog.isEmpty()) {
128-
activityLogStringBuilder.append(activityLog.poll());
129-
}
130-
intent.putExtra(EXTRA_ACTIVITY_LOG, activityLogStringBuilder.toString());
123+
if (config.isTrackActivities()) {
124+
StringBuilder activityLogStringBuilder = new StringBuilder();
125+
while (!activityLog.isEmpty()) {
126+
activityLogStringBuilder.append(activityLog.poll());
131127
}
128+
intent.putExtra(EXTRA_ACTIVITY_LOG, activityLogStringBuilder.toString());
129+
}
132130

133-
if (config.isShowRestartButton() && config.getRestartActivityClass() == null) {
134-
config.setRestartActivityClass(guessRestartActivityClass(application));
135-
}
131+
if (config.isShowRestartButton() && config.getRestartActivityClass() == null) {
132+
config.setRestartActivityClass(guessRestartActivityClass(application));
133+
}
136134

137-
intent.putExtra(EXTRA_CONFIG, config);
138-
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
139-
if (config.getEventListener() != null) {
140-
config.getEventListener().onLaunchErrorActivity();
141-
}
142-
application.startActivity(intent);
143-
} else if (config.getBackgroundMode() == CrashConfig.BACKGROUND_MODE_CRASH) {
144-
if (oldHandler != null) {
145-
oldHandler.uncaughtException(thread, throwable);
146-
return;
147-
}
135+
intent.putExtra(EXTRA_CONFIG, config);
136+
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
137+
if (config.getEventListener() != null) {
138+
config.getEventListener().onLaunchErrorActivity();
139+
}
140+
application.startActivity(intent);
141+
} else if (config.getBackgroundMode() == CrashConfig.BACKGROUND_MODE_CRASH) {
142+
if (oldHandler != null) {
143+
oldHandler.uncaughtException(thread, throwable);
144+
return;
148145
}
149146
}
150-
final Activity lastActivity = lastActivityCreated.get();
151-
if (lastActivity != null) {
152-
lastActivity.finish();
153-
lastActivityCreated.clear();
154-
}
155-
killCurrentProcess();
156-
} else if (oldHandler != null) {
157-
oldHandler.uncaughtException(thread, throwable);
158147
}
148+
final Activity lastActivity = lastActivityCreated.get();
149+
if (lastActivity != null) {
150+
lastActivity.finish();
151+
lastActivityCreated.clear();
152+
}
153+
killCurrentProcess();
154+
} else if (oldHandler != null) {
155+
oldHandler.uncaughtException(thread, throwable);
159156
}
160157
});
161158
application.registerActivityLifecycleCallbacks(new Application.ActivityLifecycleCallbacks() {

Diff for: library/src/main/java/com/developer/crashx/activity/DefaultErrorActivity.java

+14-33
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import android.annotation.SuppressLint;
44
import android.content.ClipData;
55
import android.content.ClipboardManager;
6-
import android.content.DialogInterface;
76
import android.content.res.TypedArray;
87
import android.os.Build;
98
import android.os.Bundle;
@@ -25,7 +24,7 @@
2524
import com.developer.crashx.config.CrashConfig;
2625

2726
/**
28-
* @author akshay sunil masram
27+
* @author tkdco , TutorialsAndroid
2928
*/
3029
public final class DefaultErrorActivity extends AppCompatActivity {
3130

@@ -60,43 +59,25 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
6059

6160
if (config.isShowRestartButton() && config.getRestartActivityClass() != null) {
6261
restartButton.setText(R.string.customactivityoncrash_error_activity_restart_app);
63-
restartButton.setOnClickListener(new View.OnClickListener() {
64-
@Override
65-
public void onClick(View v) {
66-
CrashActivity.restartApplication(DefaultErrorActivity.this, config);
67-
}
68-
});
62+
restartButton.setOnClickListener(v -> CrashActivity.restartApplication(DefaultErrorActivity.this, config));
6963
} else {
70-
restartButton.setOnClickListener(new View.OnClickListener() {
71-
@Override
72-
public void onClick(View v) {
73-
CrashActivity.closeApplication(DefaultErrorActivity.this, config);
74-
}
75-
});
64+
restartButton.setOnClickListener(v -> CrashActivity.closeApplication(DefaultErrorActivity.this, config));
7665
}
7766

7867
Button moreInfoButton = findViewById(R.id.crash_error_activity_more_info_button);
7968

8069
if (config.isShowErrorDetails()) {
81-
moreInfoButton.setOnClickListener(new View.OnClickListener() {
82-
@Override
83-
public void onClick(View v) {
84-
AlertDialog dialog = new AlertDialog.Builder(DefaultErrorActivity.this)
85-
.setTitle(R.string.customactivityoncrash_error_activity_error_details_title)
86-
.setMessage(CrashActivity.getAllErrorDetailsFromIntent(DefaultErrorActivity.this, getIntent()))
87-
.setPositiveButton(R.string.customactivityoncrash_error_activity_error_details_close, null)
88-
.setNeutralButton(R.string.customactivityoncrash_error_activity_error_details_copy,
89-
new DialogInterface.OnClickListener() {
90-
@Override
91-
public void onClick(DialogInterface dialog, int which) {
92-
copyErrorToClipboard();
93-
}
94-
})
95-
.show();
96-
TextView textView = dialog.findViewById(android.R.id.message);
97-
if (textView != null) {
98-
textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.customactivityoncrash_error_activity_error_details_text_size));
99-
}
70+
moreInfoButton.setOnClickListener(v -> {
71+
AlertDialog dialog = new AlertDialog.Builder(DefaultErrorActivity.this)
72+
.setTitle(R.string.customactivityoncrash_error_activity_error_details_title)
73+
.setMessage(CrashActivity.getAllErrorDetailsFromIntent(DefaultErrorActivity.this, getIntent()))
74+
.setPositiveButton(R.string.customactivityoncrash_error_activity_error_details_close, null)
75+
.setNeutralButton(R.string.customactivityoncrash_error_activity_error_details_copy,
76+
(dialog1, which) -> copyErrorToClipboard())
77+
.show();
78+
TextView textView = dialog.findViewById(android.R.id.message);
79+
if (textView != null) {
80+
textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.customactivityoncrash_error_activity_error_details_text_size));
10081
}
10182
});
10283
} else {

Diff for: library/src/main/java/com/developer/crashx/config/CrashConfig.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,13 @@
1414
import com.developer.crashx.CrashActivity;
1515

1616
/**
17-
* @author akshay sunil masram
17+
* @author tkdco , TutorialsAndroid
1818
*/
1919
public class CrashConfig implements Serializable {
2020

2121
@IntDef({BACKGROUND_MODE_CRASH, BACKGROUND_MODE_SHOW_CUSTOM, BACKGROUND_MODE_SILENT})
2222
@Retention(RetentionPolicy.SOURCE)
23-
private @interface BackgroundMode {
24-
//I hate empty blocks
25-
}
23+
private @interface BackgroundMode { }
2624

2725
static final int BACKGROUND_MODE_SILENT = 0;
2826
public static final int BACKGROUND_MODE_SHOW_CUSTOM = 1;

Diff for: library/src/main/java/com/developer/crashx/provider/CrashInitProvider.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import com.developer.crashx.CrashActivity;
1111

1212
/**
13-
* @author akshay sunil masram
13+
* @author tkdco , TutorialsAndroid
1414
*/
1515
public class CrashInitProvider extends ContentProvider {
1616

0 commit comments

Comments
 (0)