Skip to content

Commit

Permalink
Add library to Maven Central and remove lint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Ereza committed Jul 21, 2015
1 parent 705b269 commit 5299267
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 18 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
build
*/build
*/*.iml
*.iml
Expand Down
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ This library allows launching a custom activity when the app crashes, instead of

**Option 1: Gradle dependency:**

(Still pending submission to Maven Central)
Add the following dependency to your build.gradle:
```gradle
dependencies{
compile 'cat.ereza:customactivityoncrash:1.0.1'
}
```

**Option 2: Manually:**

Expand All @@ -17,7 +22,7 @@ This library allows launching a custom activity when the app crashes, instead of

### Make it work

1. Add a custom activity that will be your error activity. Specify in it this additional parameter: `process=":error_report"`.
1. Add a custom activity that will be your error activity. Add this additional parameter to the activity declaration in the manifest: `process=":error_report"`.
2. On your application class, use this snippet:
```java
@Override
Expand All @@ -40,7 +45,7 @@ This library allows launching a custom activity when the app crashes, instead of

### Test it

Make the app crash by using something like this on your code:
Make the app crash by using something like this in your code:
```java
throw new RuntimeException("Boom!");
```
Expand Down Expand Up @@ -68,16 +73,15 @@ The inner workings are based on [ACRA](https://github.com/ACRA/acra)'s dialog re
* With ACRA enabled and reporting mode set to `TOAST` or `DIALOG`.
* With any other custom `UncaughtExceptionHandler` set after initializing the library, that does not call back to the original handler.
* Your `UncaughtExceptionHandler` will not be called if you initialize it before the library initialization (so, Crashlytics or ACRA initialization must be done **after** CustomActivityOnCrash initialization).
* On some rare cases on devices with API<14, the app may enter a restart loop.
* On some rare cases on devices with API<14, the app may enter a restart loop when a crash occurs.
* If your app initialization or error activity crash, there is a possibility of entering an infinite restart loop (this is checked by the library for the most common cases, but could happen in rarer cases).

## Disclaimers

* This will not avoid ANRs from happening.
* This will not catch native errors.
* There is no guarantee that this will work on every device.
* If your app initialization or error activity crash, there is a possibility of entering an infinite restart loop (this is checked by the library for the most common cases, but could happen in rarer cases)
* This library will make you toast for breakfast :)
* Of course, no refunds accepted! ;)
* This library will not make you toast for breakfast :)

## Contributing & license

Expand Down
11 changes: 9 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,22 @@

buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
}
}

def isReleaseBuild() {
return version.contains("SNAPSHOT") == false
}

allprojects {
version = VERSION_NAME
group = GROUP

repositories {
jcenter()
mavenCentral()
}
}
16 changes: 15 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,18 @@
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# org.gradle.parallel=true
VERSION_NAME=1.0.1
VERSION_CODE=2
GROUP=cat.ereza

POM_DESCRIPTION=Android library that allows launching a custom activity when your app crashes, instead of showing the hated "App has stopped unexpectedly" dialog.
POM_URL=https://github.com/Ereza/CustomActivityOnCrash
POM_SCM_URL=https://github.com/Ereza/CustomActivityOnCrash.git
POM_SCM_CONNECTION=scm:[email protected]:Ereza/CustomActivityOnCrash.git
POM_SCM_DEV_CONNECTION=scm:[email protected]:Ereza/CustomActivityOnCrash.git
POM_LICENCE_NAME=The Apache Software License, Version 2.0
POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
POM_LICENCE_DIST=repo
POM_DEVELOPER_ID=Ereza
POM_DEVELOPER_NAME=Eduard Ereza Martínez
Empty file modified gradlew
100644 → 100755
Empty file.
10 changes: 6 additions & 4 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ android {
buildToolsVersion "22.0.1"

defaultConfig {
minSdkVersion 3
minSdkVersion 4
targetSdkVersion 22
versionCode 1
versionName "1.0"
versionCode 2
versionName "1.0.1"
}
}
}

apply from: 'https://raw.github.com/chrisbanes/gradle-mvn-push/master/gradle-mvn-push.gradle'
19 changes: 19 additions & 0 deletions library/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#
# Copyright 2015 Eduard Ereza Martínez
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
#
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

POM_NAME=CustomActivityOnCrash library
POM_ARTIFACT_ID=customactivityoncrash
POM_PACKAGING=jar
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package cat.ereza.customactivityoncrash;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Application;
import android.content.Context;
Expand All @@ -28,6 +29,7 @@
import java.io.StringWriter;
import java.lang.ref.WeakReference;

@SuppressLint("NewApi")
public class CustomActivityOnCrash {
public static final String EXTRA_STACK_TRACE = "cat.ereza.customactivityoncrash.EXTRA_STACK_TACE";

Expand Down
6 changes: 3 additions & 3 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ android {

defaultConfig {
applicationId "cat.ereza.sample.customactivityoncrash"
minSdkVersion 3
minSdkVersion 4
targetSdkVersion 22
versionCode 1
versionName "1.0"
versionCode 2
versionName "1.0.1"
}
buildTypes {
debug {
Expand Down
1 change: 1 addition & 0 deletions sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

<application
android:name="cat.ereza.sample.customactivityoncrash.SampleCrashableApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void onCreate() {
super.onCreate();

//Install CustomActivityOnCrash
CustomActivityOnCrash.init(this, ErrorActivity.class, false);
CustomActivityOnCrash.init(this, ErrorActivity.class, true);

//Now initialize your error handlers as normal, they will most likely keep a reference to the original exception handler
//i.e., ACRA.init(this);
Expand Down

0 comments on commit 5299267

Please sign in to comment.