├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── values
│ │ │ │ ├── colors.xml
│ │ │ │ ├── styles.xml
│ │ │ │ └── strings.xml
│ │ │ └── layout
│ │ │ │ └── activity_main.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── balsikandar
│ │ │ │ └── crashreporter
│ │ │ │ └── sample
│ │ │ │ ├── CrashReporterSampleApplication.java
│ │ │ │ └── MainActivity.java
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── balsikandar
│ │ │ └── crashreporter
│ │ │ └── sample
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── balsikandar
│ │ └── crashreporter
│ │ └── sample
│ │ └── ExampleInstrumentedTest.java
├── proguard-rules.pro
└── build.gradle
├── crashreporter
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── layout
│ │ │ │ ├── crash_log.xml
│ │ │ │ ├── exception_log.xml
│ │ │ │ ├── custom_item.xml
│ │ │ │ ├── crash_reporter_activity.xml
│ │ │ │ └── activity_log_message.xml
│ │ │ ├── values
│ │ │ │ ├── colors.xml
│ │ │ │ ├── styles.xml
│ │ │ │ └── strings.xml
│ │ │ ├── drawable
│ │ │ │ ├── ic_warning_black_24dp.xml
│ │ │ │ ├── ic_menu_delete_white_24dp.xml
│ │ │ │ ├── ic_search_white_24dp.xml
│ │ │ │ └── ic_menu_share_white_24dp.xml
│ │ │ └── menu
│ │ │ │ ├── crash_detail_menu.xml
│ │ │ │ └── log_main_menu.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── balsikandar
│ │ │ │ └── crashreporter
│ │ │ │ ├── utils
│ │ │ │ ├── SimplePageChangeListener.java
│ │ │ │ ├── Constants.java
│ │ │ │ ├── CrashReporterExceptionHandler.java
│ │ │ │ ├── CrashReporterNotInitializedException.java
│ │ │ │ ├── CrashReporterException.java
│ │ │ │ ├── FileUtils.java
│ │ │ │ ├── AppUtils.java
│ │ │ │ └── CrashUtil.java
│ │ │ │ ├── adapter
│ │ │ │ ├── MainPagerAdapter.java
│ │ │ │ └── CrashLogAdapter.java
│ │ │ │ ├── CrashReporterInitProvider.java
│ │ │ │ ├── CrashReporter.java
│ │ │ │ └── ui
│ │ │ │ ├── LogMessageActivity.java
│ │ │ │ ├── CrashLogFragment.java
│ │ │ │ ├── ExceptionLogFragment.java
│ │ │ │ └── CrashReporterActivity.java
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── balsikandar
│ │ │ └── crashreporter
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── balsikandar
│ │ └── crashreporter
│ │ └── ExampleInstrumentedTest.java
├── proguard-rules.pro
├── build.gradle
└── upload.gradle
├── settings.gradle
├── assets
├── crash_reporter_banner.png
├── sample_app_screenshot.png
└── crash_reporter_work_flow.gif
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── gradle.properties
├── gradlew.bat
├── gradlew
├── README.md
└── LICENSE
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/crashreporter/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':crashreporter'
2 |
--------------------------------------------------------------------------------
/assets/crash_reporter_banner.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MindorksOpenSource/CrashReporter/HEAD/assets/crash_reporter_banner.png
--------------------------------------------------------------------------------
/assets/sample_app_screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MindorksOpenSource/CrashReporter/HEAD/assets/sample_app_screenshot.png
--------------------------------------------------------------------------------
/assets/crash_reporter_work_flow.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MindorksOpenSource/CrashReporter/HEAD/assets/crash_reporter_work_flow.gif
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MindorksOpenSource/CrashReporter/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MindorksOpenSource/CrashReporter/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MindorksOpenSource/CrashReporter/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MindorksOpenSource/CrashReporter/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MindorksOpenSource/CrashReporter/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MindorksOpenSource/CrashReporter/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 | /.idea
11 |
--------------------------------------------------------------------------------
/crashreporter/src/main/res/layout/crash_log.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/crashreporter/src/main/res/layout/exception_log.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Nov 07 17:05:35 CET 2018
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.4-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #ff4081
4 | #f50057
5 | #cf1162
6 | #ffffff
7 | #000000
8 |
9 |
--------------------------------------------------------------------------------
/crashreporter/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #ff4081
4 | #f50057
5 | #cf1162
6 | #000000
7 |
--------------------------------------------------------------------------------
/crashreporter/src/main/res/drawable/ic_warning_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/crashreporter/src/main/res/drawable/ic_menu_delete_white_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
--------------------------------------------------------------------------------
/crashreporter/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | CrashReporterSample
3 | Null Pointer
4 | IndexOutOfBound
5 | ClassCast Exeption
6 | ArrayStoreException
7 | Add your own crash and check if it gets logged
8 |
9 |
--------------------------------------------------------------------------------
/crashreporter/src/test/java/com/balsikandar/crashreporter/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.balsikandar.crashreporter;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/app/src/test/java/com/balsikandar/crashreporter/sample/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.balsikandar.crashreporter.sample;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/crashreporter/src/main/res/drawable/ic_search_white_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/crashreporter/src/main/res/menu/crash_detail_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/crashreporter/src/main/java/com/balsikandar/crashreporter/utils/SimplePageChangeListener.java:
--------------------------------------------------------------------------------
1 | package com.balsikandar.crashreporter.utils;
2 |
3 | import android.support.v4.view.ViewPager;
4 |
5 | /**
6 | * Created by bali on 11/08/17.
7 | */
8 |
9 | public abstract class SimplePageChangeListener implements ViewPager.OnPageChangeListener {
10 | @Override
11 | public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {}
12 | @Override
13 | public abstract void onPageSelected(int position);
14 | @Override
15 | public void onPageScrollStateChanged(int state) {}
16 | }
17 |
--------------------------------------------------------------------------------
/crashreporter/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | CrashReporter
3 | Crashes
4 | Exceptions
5 | View Crash Report
6 | Crash Reporter notifications
7 | Check your crashes and exceptions here.
8 | Are you sure to delete all the crash logs
9 | CANCEL
10 | OK
11 |
12 |
--------------------------------------------------------------------------------
/crashreporter/src/main/java/com/balsikandar/crashreporter/utils/Constants.java:
--------------------------------------------------------------------------------
1 | package com.balsikandar.crashreporter.utils;
2 |
3 | /**
4 | * Created by bali on 15/08/17.
5 | */
6 |
7 | public class Constants {
8 | public static final String EXCEPTION_SUFFIX = "_exception";
9 | public static final String CRASH_SUFFIX = "_crash";
10 | public static final String FILE_EXTENSION = ".txt";
11 | public static final String CRASH_REPORT_DIR = "crashReports";
12 | public static final int NOTIFICATION_ID = 1;
13 | public static final String CHANNEL_NOTIFICATION_ID = "crashreporter_channel_id";
14 | public static final String LANDING = "landing";
15 | }
16 |
--------------------------------------------------------------------------------
/crashreporter/src/main/java/com/balsikandar/crashreporter/utils/CrashReporterExceptionHandler.java:
--------------------------------------------------------------------------------
1 | package com.balsikandar.crashreporter.utils;
2 |
3 | public class CrashReporterExceptionHandler implements Thread.UncaughtExceptionHandler {
4 |
5 | private Thread.UncaughtExceptionHandler exceptionHandler;
6 |
7 | public CrashReporterExceptionHandler() {
8 | this.exceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
9 | }
10 |
11 | @Override
12 | public void uncaughtException(Thread thread, Throwable throwable) {
13 |
14 | CrashUtil.saveCrashReport(throwable);
15 |
16 | exceptionHandler.uncaughtException(thread, throwable);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/app/src/main/java/com/balsikandar/crashreporter/sample/CrashReporterSampleApplication.java:
--------------------------------------------------------------------------------
1 | package com.balsikandar.crashreporter.sample;
2 |
3 | import android.app.Application;
4 | import android.os.Environment;
5 |
6 | import com.balsikandar.crashreporter.CrashReporter;
7 |
8 | import java.io.File;
9 |
10 | /**
11 | * Created by bali on 02/08/17.
12 | */
13 |
14 | public class CrashReporterSampleApplication extends Application {
15 |
16 | @Override
17 | public void onCreate() {
18 | super.onCreate();
19 |
20 | if (BuildConfig.DEBUG) {
21 | //initialise reporter with external path
22 | CrashReporter.initialize(this);
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/crashreporter/src/main/res/menu/log_main_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/crashreporter/src/main/res/drawable/ic_menu_share_white_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/crashreporter/src/androidTest/java/com/balsikandar/crashreporter/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.balsikandar.crashreporter;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.balsikandar.crashreporter.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/balsikandar/crashreporter/sample/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.balsikandar.crashreporter.sample;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.balsikandar.crashreporter.sample", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/crashreporter/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
8 |
9 |
14 |
15 |
20 |
21 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/bali/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/crashreporter/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/bali/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion rootProject.ext.compile_sdk_version
5 | buildToolsVersion rootProject.ext.build_tools_version
6 | defaultConfig {
7 | applicationId "com.balsikandar.crashreporter.sample"
8 | minSdkVersion 15
9 | targetSdkVersion rootProject.ext.compile_sdk_version
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | api fileTree(include: ['*.jar'], dir: 'libs')
24 | androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
25 | exclude group: 'com.android.support', module: 'support-annotations'
26 | })
27 | api 'com.android.support:appcompat-v7:' + rootProject.ext.support_version
28 | testImplementation 'junit:junit:4.12'
29 | api project(':crashreporter')
30 | api 'com.google.android:flexbox:0.3.0'
31 | }
32 |
--------------------------------------------------------------------------------
/crashreporter/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion rootProject.ext.compile_sdk_version
5 | buildToolsVersion rootProject.ext.build_tools_version
6 |
7 | defaultConfig {
8 | minSdkVersion 15
9 | targetSdkVersion rootProject.ext.compile_sdk_version
10 | versionCode 1
11 | versionName "1.0"
12 |
13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
14 |
15 | }
16 | buildTypes {
17 | release {
18 | minifyEnabled false
19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
20 | }
21 | }
22 | }
23 |
24 | dependencies {
25 | api fileTree(dir: 'libs', include: ['*.jar'])
26 | androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
27 | exclude group: 'com.android.support', module: 'support-annotations'
28 | })
29 | api 'com.android.support:recyclerview-v7:' + rootProject.ext.support_version
30 | api 'com.android.support:appcompat-v7:' + rootProject.ext.support_version
31 | api 'com.android.support:design:' + rootProject.ext.support_version
32 | testImplementation 'junit:junit:4.12'
33 | }
34 |
35 | //apply from: 'upload.gradle'
--------------------------------------------------------------------------------
/crashreporter/src/main/java/com/balsikandar/crashreporter/adapter/MainPagerAdapter.java:
--------------------------------------------------------------------------------
1 | package com.balsikandar.crashreporter.adapter;
2 |
3 | import android.support.v4.app.Fragment;
4 | import android.support.v4.app.FragmentManager;
5 | import android.support.v4.app.FragmentPagerAdapter;
6 |
7 | import com.balsikandar.crashreporter.ui.CrashLogFragment;
8 | import com.balsikandar.crashreporter.ui.ExceptionLogFragment;
9 |
10 | /**
11 | * Created by bali on 11/08/17.
12 | */
13 |
14 | public class MainPagerAdapter extends FragmentPagerAdapter {
15 |
16 | private CrashLogFragment crashLogFragment;
17 | private ExceptionLogFragment exceptionLogFragment;
18 | private String[] titles;
19 |
20 | public MainPagerAdapter(FragmentManager fm, String[] titles) {
21 | super(fm);
22 | this.titles = titles;
23 | }
24 |
25 | @Override
26 | public Fragment getItem(int position) {
27 | if (position == 0) {
28 | return crashLogFragment = new CrashLogFragment();
29 | } else if (position == 1) {
30 | return exceptionLogFragment = new ExceptionLogFragment();
31 | } else {
32 | return new CrashLogFragment();
33 | }
34 | }
35 |
36 | @Override
37 | public int getCount() {
38 | return 2;
39 | }
40 |
41 | @Override
42 | public CharSequence getPageTitle(int position) {
43 | return titles[position];
44 | }
45 |
46 | public void clearLogs() {
47 | crashLogFragment.clearLog();
48 | exceptionLogFragment.clearLog();
49 | }
50 | }
--------------------------------------------------------------------------------
/crashreporter/src/main/res/layout/custom_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
19 |
20 |
34 |
35 |
41 |
--------------------------------------------------------------------------------
/crashreporter/src/main/java/com/balsikandar/crashreporter/utils/CrashReporterNotInitializedException.java:
--------------------------------------------------------------------------------
1 | package com.balsikandar.crashreporter.utils;
2 |
3 | /**
4 | * Created by bali on 02/08/17.
5 | */
6 |
7 | /**
8 | * An Exception indicating that the Crash Reporter has not been correctly initialized.
9 | */
10 | public class CrashReporterNotInitializedException extends CrashReporterException {
11 | static final long serialVersionUID = 1;
12 |
13 | /**
14 | * Constructs a CrashReporterNotInitializedException with no additional information.
15 | */
16 | public CrashReporterNotInitializedException() {
17 | super();
18 | }
19 |
20 | /**
21 | * Constructs a CrashReporterNotInitializedException with a message.
22 | *
23 | * @param message A String to be returned from getMessage.
24 | */
25 | public CrashReporterNotInitializedException(String message) {
26 | super(message);
27 | }
28 |
29 | /**
30 | * Constructs a CrashReporterNotInitializedException with a message and inner error.
31 | *
32 | * @param message A String to be returned from getMessage.
33 | * @param throwable A Throwable to be returned from getCause.
34 | */
35 | public CrashReporterNotInitializedException(String message, Throwable throwable) {
36 | super(message, throwable);
37 | }
38 |
39 | /**
40 | * Constructs a CrashReporterNotInitializedException with an inner error.
41 | *
42 | * @param throwable A Throwable to be returned from getCause.
43 | */
44 | public CrashReporterNotInitializedException(Throwable throwable) {
45 | super(throwable);
46 | }
47 | }
--------------------------------------------------------------------------------
/crashreporter/src/main/res/layout/crash_reporter_activity.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
16 |
17 |
23 |
24 |
28 |
29 |
30 |
31 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/crashreporter/src/main/java/com/balsikandar/crashreporter/utils/CrashReporterException.java:
--------------------------------------------------------------------------------
1 | package com.balsikandar.crashreporter.utils;
2 |
3 | /**
4 | * Created by bali on 02/08/17.
5 | */
6 |
7 | /**
8 | * Represents an error condition specific to the Crash Reporter for Android.
9 | */
10 | public class CrashReporterException extends RuntimeException {
11 | static final long serialVersionUID = 1;
12 |
13 | /**
14 | * Constructs a new CrashReporterException.
15 | */
16 | public CrashReporterException() {
17 | super();
18 | }
19 |
20 | /**
21 | * Constructs a new CrashReporterException.
22 | *
23 | * @param message the detail message of this exception
24 | */
25 | public CrashReporterException(String message) {
26 | super(message);
27 | }
28 |
29 | /**
30 | * Constructs a new CrashReporterException.
31 | *
32 | * @param format the format string (see {@link java.util.Formatter#format})
33 | * @param args the list of arguments passed to the formatter.
34 | */
35 | public CrashReporterException(String format, Object... args) {
36 | this(String.format(format, args));
37 | }
38 |
39 | /**
40 | * Constructs a new CrashReporterException.
41 | *
42 | * @param message the detail message of this exception
43 | * @param throwable the cause of this exception
44 | */
45 | public CrashReporterException(String message, Throwable throwable) {
46 | super(message, throwable);
47 | }
48 |
49 | /**
50 | * Constructs a new CrashReporterException.
51 | *
52 | * @param throwable the cause of this exception
53 | */
54 | public CrashReporterException(Throwable throwable) {
55 | super(throwable);
56 | }
57 |
58 | @Override
59 | public String toString() {
60 | // Throwable.toString() returns "CrashReporterException:{message}". Returning just "{message}"
61 | // should be fine here.
62 | return getMessage();
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/crashreporter/src/main/res/layout/activity_log_message.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
19 |
20 |
26 |
27 |
28 |
29 |
32 |
33 |
39 |
40 |
41 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/crashreporter/src/main/java/com/balsikandar/crashreporter/CrashReporterInitProvider.java:
--------------------------------------------------------------------------------
1 | package com.balsikandar.crashreporter;
2 |
3 | /**
4 | * Created by bali on 02/08/17.
5 | */
6 |
7 | import android.content.ContentProvider;
8 | import android.content.ContentValues;
9 | import android.content.Context;
10 | import android.content.pm.ProviderInfo;
11 | import android.database.Cursor;
12 | import android.net.Uri;
13 |
14 | /**
15 | * Created by amitshekhar on 16/11/16.
16 | */
17 |
18 | public class CrashReporterInitProvider extends ContentProvider {
19 |
20 |
21 | public CrashReporterInitProvider() {
22 | }
23 |
24 | @Override
25 | public boolean onCreate() {
26 | CrashReporter.initialize(getContext());
27 | return true;
28 | }
29 |
30 | @Override
31 | public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
32 | return null;
33 | }
34 |
35 | @Override
36 | public String getType(Uri uri) {
37 | return null;
38 | }
39 |
40 | @Override
41 | public Uri insert(Uri uri, ContentValues values) {
42 | return null;
43 | }
44 |
45 | @Override
46 | public int delete(Uri uri, String selection, String[] selectionArgs) {
47 | return 0;
48 | }
49 |
50 | @Override
51 | public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
52 | return 0;
53 | }
54 |
55 | @Override
56 | public void attachInfo(Context context, ProviderInfo providerInfo) {
57 | if (providerInfo == null) {
58 | throw new NullPointerException("CrashReporterInitProvider ProviderInfo cannot be null.");
59 | }
60 | // So if the authorities equal the library internal ones, the developer forgot to set his applicationId
61 | if ("com.balsikandar.crashreporter.CrashReporterInitProvider".equals(providerInfo.authority)) {
62 | throw new IllegalStateException("Incorrect provider authority in manifest. Most likely due to a "
63 | + "missing applicationId variable in application\'s build.gradle.");
64 | }
65 | super.attachInfo(context, providerInfo);
66 | }
67 |
68 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
16 |
17 |
24 |
25 |
32 |
33 |
40 |
41 |
48 |
49 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/crashreporter/src/main/java/com/balsikandar/crashreporter/CrashReporter.java:
--------------------------------------------------------------------------------
1 | package com.balsikandar.crashreporter;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 |
6 | import com.balsikandar.crashreporter.ui.CrashReporterActivity;
7 | import com.balsikandar.crashreporter.utils.CrashReporterNotInitializedException;
8 | import com.balsikandar.crashreporter.utils.CrashReporterExceptionHandler;
9 | import com.balsikandar.crashreporter.utils.CrashUtil;
10 |
11 | public class CrashReporter {
12 |
13 | private static Context applicationContext;
14 |
15 | private static String crashReportPath;
16 |
17 | private static boolean isNotificationEnabled = true;
18 |
19 | private CrashReporter() {
20 | // This class in not publicly instantiable
21 | }
22 |
23 | public static void initialize(Context context) {
24 | applicationContext = context;
25 | setUpExceptionHandler();
26 | }
27 |
28 | public static void initialize(Context context, String crashReportSavePath) {
29 | applicationContext = context;
30 | crashReportPath = crashReportSavePath;
31 | setUpExceptionHandler();
32 | }
33 |
34 | private static void setUpExceptionHandler() {
35 | if (!(Thread.getDefaultUncaughtExceptionHandler() instanceof CrashReporterExceptionHandler)) {
36 | Thread.setDefaultUncaughtExceptionHandler(new CrashReporterExceptionHandler());
37 | }
38 | }
39 |
40 | public static Context getContext() {
41 | if (applicationContext == null) {
42 | try {
43 | throw new CrashReporterNotInitializedException("Initialize CrashReporter : call CrashReporter.initialize(context, crashReportPath)");
44 | } catch (Exception e) {
45 | e.printStackTrace();
46 | }
47 | }
48 | return applicationContext;
49 | }
50 |
51 | public static String getCrashReportPath() {
52 | return crashReportPath;
53 | }
54 |
55 | public static boolean isNotificationEnabled() {
56 | return isNotificationEnabled;
57 | }
58 |
59 | //LOG Exception APIs
60 | public static void logException(Exception exception) {
61 | CrashUtil.logException(exception);
62 | }
63 |
64 | public static Intent getLaunchIntent() {
65 | return new Intent(applicationContext, CrashReporterActivity.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
66 | }
67 |
68 | public static void disableNotification() {
69 | isNotificationEnabled = false;
70 | }
71 |
72 | }
73 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/app/src/main/java/com/balsikandar/crashreporter/sample/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.balsikandar.crashreporter.sample;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.view.View;
8 |
9 | import com.balsikandar.crashreporter.CrashReporter;
10 | import com.balsikandar.crashreporter.ui.CrashReporterActivity;
11 |
12 | import java.util.ArrayList;
13 |
14 | public class MainActivity extends AppCompatActivity {
15 | Context context;
16 | Context mContext;
17 |
18 | @Override
19 | protected void onCreate(Bundle savedInstanceState) {
20 | super.onCreate(savedInstanceState);
21 | setContentView(R.layout.activity_main);
22 |
23 | findViewById(R.id.nullPointer).setOnClickListener(new View.OnClickListener() {
24 | @Override
25 | public void onClick(View v) {
26 | context = null;
27 | context.getResources();
28 | }
29 | });
30 |
31 | findViewById(R.id.indexOutOfBound).setOnClickListener(new View.OnClickListener() {
32 | @Override
33 | public void onClick(View v) {
34 | ArrayList list = new ArrayList();
35 | list.add("hello");
36 | String crashMe = list.get(2);
37 | }
38 | });
39 |
40 | findViewById(R.id.classCastExeption).setOnClickListener(new View.OnClickListener() {
41 | @Override
42 | public void onClick(View v) {
43 | Object x = new Integer(0);
44 | System.out.println((String)x);
45 |
46 | }
47 | });
48 |
49 | findViewById(R.id.arrayStoreException).setOnClickListener(new View.OnClickListener() {
50 | @Override
51 | public void onClick(View v) {
52 | Object x[] = new String[3];
53 | x[0] = new Integer(0);
54 |
55 | }
56 | });
57 |
58 |
59 | //Crashes and exceptions are also captured from other threads
60 | new Thread(new Runnable() {
61 | @Override
62 | public void run() {
63 | try {
64 | context = null;
65 | context.getResources();
66 | } catch (Exception e) {
67 | //log caught Exception
68 | CrashReporter.logException(e);
69 | }
70 |
71 | }
72 | }).start();
73 |
74 | mContext = this;
75 | findViewById(R.id.crashLogActivity).setOnClickListener(new View.OnClickListener() {
76 | @Override
77 | public void onClick(View v) {
78 | Intent intent = new Intent(mContext, CrashReporterActivity.class);
79 | startActivity(intent);
80 | }
81 | });
82 |
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/crashreporter/src/main/java/com/balsikandar/crashreporter/adapter/CrashLogAdapter.java:
--------------------------------------------------------------------------------
1 | package com.balsikandar.crashreporter.adapter;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.support.v7.widget.RecyclerView;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.TextView;
10 |
11 | import com.balsikandar.crashreporter.R;
12 | import com.balsikandar.crashreporter.ui.LogMessageActivity;
13 | import com.balsikandar.crashreporter.utils.CrashUtil;
14 | import com.balsikandar.crashreporter.utils.FileUtils;
15 |
16 | import java.io.File;
17 | import java.util.ArrayList;
18 |
19 | /**
20 | * Created by bali on 10/08/17.
21 | */
22 |
23 | public class CrashLogAdapter extends RecyclerView.Adapter {
24 |
25 | private Context context;
26 | private ArrayList crashFileList;
27 |
28 | public CrashLogAdapter(Context context, ArrayList allCrashLogs) {
29 | this.context = context;
30 | crashFileList = allCrashLogs;
31 | }
32 |
33 | @Override
34 | public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
35 | View view = LayoutInflater.from(context).inflate(R.layout.custom_item, null);
36 | return new CrashLogViewHolder(view);
37 | }
38 |
39 | @Override
40 | public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
41 | ((CrashLogViewHolder) holder).setUpViewHolder(context, crashFileList.get(position));
42 | }
43 |
44 | @Override
45 | public int getItemCount() {
46 | return crashFileList.size();
47 | }
48 |
49 |
50 | public void updateList(ArrayList allCrashLogs) {
51 | crashFileList = allCrashLogs;
52 | notifyDataSetChanged();
53 | }
54 |
55 |
56 | private class CrashLogViewHolder extends RecyclerView.ViewHolder {
57 | private TextView textViewMsg, messageLogTime;
58 |
59 | CrashLogViewHolder(View itemView) {
60 | super(itemView);
61 | messageLogTime = (TextView) itemView.findViewById(R.id.messageLogTime);
62 | textViewMsg = (TextView) itemView.findViewById(R.id.textViewMsg);
63 | }
64 |
65 | void setUpViewHolder(final Context context, final File file) {
66 | final String filePath = file.getAbsolutePath();
67 | messageLogTime.setText(file.getName().replaceAll("[a-zA-Z_.]", ""));
68 | textViewMsg.setText(FileUtils.readFirstLineFromFile(new File(filePath)));
69 |
70 | textViewMsg.setOnClickListener(new View.OnClickListener() {
71 | @Override
72 | public void onClick(View v) {
73 | Intent intent = new Intent(context, LogMessageActivity.class);
74 | intent.putExtra("LogMessage", filePath);
75 | context.startActivity(intent);
76 | }
77 | });
78 | }
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/crashreporter/src/main/java/com/balsikandar/crashreporter/ui/LogMessageActivity.java:
--------------------------------------------------------------------------------
1 | package com.balsikandar.crashreporter.ui;
2 |
3 | import android.content.Intent;
4 | import android.net.Uri;
5 | import android.os.Bundle;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.support.v7.widget.Toolbar;
8 | import android.view.Menu;
9 | import android.view.MenuItem;
10 | import android.widget.TextView;
11 |
12 | import com.balsikandar.crashreporter.R;
13 | import com.balsikandar.crashreporter.utils.AppUtils;
14 | import com.balsikandar.crashreporter.utils.FileUtils;
15 |
16 | import java.io.File;
17 |
18 | public class LogMessageActivity extends AppCompatActivity {
19 |
20 | private TextView appInfo;
21 |
22 | @Override
23 | protected void onCreate(Bundle savedInstanceState) {
24 | super.onCreate(savedInstanceState);
25 | setContentView(R.layout.activity_log_message);
26 | appInfo = (TextView) findViewById(R.id.appInfo);
27 |
28 | Intent intent = getIntent();
29 | if (intent != null) {
30 | String dirPath = intent.getStringExtra("LogMessage");
31 | File file = new File(dirPath);
32 | String crashLog = FileUtils.readFromFile(file);
33 | TextView textView = (TextView) findViewById(R.id.logMessage);
34 | textView.setText(crashLog);
35 | }
36 |
37 | Toolbar myToolbar = (Toolbar) findViewById(R.id.toolbar);
38 | myToolbar.setTitle(getString(R.string.crash_reporter));
39 | setSupportActionBar(myToolbar);
40 |
41 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
42 |
43 | getAppInfo();
44 | }
45 |
46 | private void getAppInfo() {
47 | appInfo.setText(AppUtils.getDeviceDetails(this));
48 | }
49 |
50 | @Override
51 | public boolean onCreateOptionsMenu(Menu menu) {
52 | getMenuInflater().inflate(R.menu.crash_detail_menu, menu);
53 | return true;
54 | }
55 |
56 | @Override
57 | public boolean onOptionsItemSelected(MenuItem item) {
58 | Intent intent = getIntent();
59 | String filePath = null;
60 | if (intent != null) {
61 | filePath = intent.getStringExtra("LogMessage");
62 | }
63 |
64 | if (item.getItemId() == R.id.delete_log) {
65 | if (FileUtils.delete(filePath)) {
66 | finish();
67 | }
68 | return true;
69 | } else if (item.getItemId() == R.id.share_crash_log) {
70 | shareCrashReport(filePath);
71 | return true;
72 | } else {
73 | return super.onOptionsItemSelected(item);
74 | }
75 | }
76 |
77 | private void shareCrashReport(String filePath) {
78 | Intent intent = new Intent(Intent.ACTION_SEND);
79 | intent.setType("*/*");
80 | intent.putExtra(Intent.EXTRA_TEXT, appInfo.getText().toString());
81 | intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(filePath)));
82 | startActivity(Intent.createChooser(intent, "Share via"));
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/crashreporter/upload.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Bal Sikandar yadav
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | apply plugin: 'com.github.dcendents.android-maven'
19 | apply plugin: "com.jfrog.bintray"
20 |
21 | def siteUrl = 'https://github.com/balsikandar/CrashReporter'
22 | def gitUrl = 'https://github.com/balsikandar/CrashReporter.git'
23 |
24 | group = "com.balsikandar.android"
25 | version = '1.1.0'
26 |
27 | install {
28 | repositories.mavenInstaller {
29 | pom.project {
30 | packaging 'aar'
31 |
32 | name 'Crash Reporter'
33 | description 'Crash Reporter is a handly tool to capture crashes and save in file'
34 |
35 | url siteUrl
36 |
37 | licenses {
38 | license {
39 | name 'The Apache Software License, Version 2.0'
40 | url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
41 | }
42 | }
43 |
44 | developers {
45 | developer {
46 | id 'balsikandar'
47 | name 'Bal sikandar yadav'
48 | email 'balsikandar.nsit@gmail.com'
49 | }
50 | }
51 |
52 | scm {
53 | connection gitUrl
54 | developerConnection gitUrl
55 | url siteUrl
56 | }
57 | }
58 | }
59 | }
60 |
61 | task sourcesJar(type: Jar) {
62 | from android.sourceSets.main.java.srcDirs
63 | classifier = 'sources'
64 | }
65 |
66 | task javadoc(type: Javadoc) {
67 | source = android.sourceSets.main.java.srcDirs
68 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
69 | classpath += configurations.compile
70 | }
71 |
72 | task javadocJar(type: Jar, dependsOn: javadoc) {
73 | classifier = 'javadoc'
74 | from javadoc.destinationDir
75 | }
76 | artifacts {
77 | archives javadocJar
78 | archives sourcesJar
79 | }
80 |
81 | if (project.rootProject.file("local.properties").exists()) {
82 | Properties properties = new Properties()
83 | properties.load(project.rootProject.file('local.properties').newDataInputStream())
84 |
85 | bintray {
86 | user = properties.getProperty("bintray.user")
87 | key = properties.getProperty("bintray.apikey")
88 |
89 | configurations = ['archives']
90 | dryRun = false
91 |
92 | pkg {
93 | repo = "maven"
94 | name = "Crash-Reporter"
95 | websiteUrl = siteUrl
96 | vcsUrl = gitUrl
97 | licenses = ["Apache-2.0"]
98 | publish = true
99 | }
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/crashreporter/src/main/java/com/balsikandar/crashreporter/ui/CrashLogFragment.java:
--------------------------------------------------------------------------------
1 | package com.balsikandar.crashreporter.ui;
2 |
3 | import android.content.Context;
4 | import android.os.Bundle;
5 | import android.support.annotation.Nullable;
6 | import android.support.v4.app.Fragment;
7 | import android.support.v7.widget.LinearLayoutManager;
8 | import android.support.v7.widget.RecyclerView;
9 | import android.text.TextUtils;
10 | import android.view.LayoutInflater;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 |
14 | import com.balsikandar.crashreporter.CrashReporter;
15 | import com.balsikandar.crashreporter.R;
16 | import com.balsikandar.crashreporter.adapter.CrashLogAdapter;
17 | import com.balsikandar.crashreporter.utils.Constants;
18 | import com.balsikandar.crashreporter.utils.CrashUtil;
19 |
20 | import java.io.File;
21 | import java.util.ArrayList;
22 | import java.util.Arrays;
23 | import java.util.Collections;
24 | import java.util.Iterator;
25 |
26 | /**
27 | * Created by bali on 11/08/17.
28 | */
29 |
30 | public class CrashLogFragment extends Fragment {
31 |
32 | private CrashLogAdapter logAdapter;
33 |
34 | private RecyclerView crashRecyclerView;
35 |
36 | @Override
37 | public void onCreate(@Nullable Bundle savedInstanceState) {
38 | super.onCreate(savedInstanceState);
39 | }
40 |
41 | @Nullable
42 | @Override
43 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
44 | View view = inflater.inflate(R.layout.crash_log, container, false);
45 | crashRecyclerView = (RecyclerView) view.findViewById(R.id.crashRecyclerView);
46 |
47 | return view;
48 | }
49 |
50 | @Override
51 | public void onResume() {
52 | super.onResume();
53 | loadAdapter(getActivity(), crashRecyclerView);
54 | }
55 |
56 | private void loadAdapter(Context context, RecyclerView crashRecyclerView) {
57 |
58 | logAdapter = new CrashLogAdapter(context, getAllCrashes());
59 | crashRecyclerView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
60 | crashRecyclerView.setAdapter(logAdapter);
61 | }
62 |
63 | public void clearLog() {
64 | if (logAdapter != null) {
65 | logAdapter.updateList(getAllCrashes());
66 | }
67 | }
68 |
69 |
70 | private ArrayList getAllCrashes() {
71 | String directoryPath;
72 | String crashReportPath = CrashReporter.getCrashReportPath();
73 |
74 | if (TextUtils.isEmpty(crashReportPath)) {
75 | directoryPath = CrashUtil.getDefaultPath();
76 | } else {
77 | directoryPath = crashReportPath;
78 | }
79 | File directory = new File(directoryPath);
80 | if (!directory.exists() || !directory.isDirectory()) {
81 | throw new RuntimeException("The path provided doesn't exists : " + directoryPath);
82 | }
83 | ArrayList listOfFiles = new ArrayList<>(Arrays.asList(directory.listFiles()));
84 | for (Iterator iterator = listOfFiles.iterator(); iterator.hasNext(); ) {
85 | if (iterator.next().getName().contains(Constants.EXCEPTION_SUFFIX)) {
86 | iterator.remove();
87 | }
88 | }
89 | Collections.sort(listOfFiles, Collections.reverseOrder());
90 | return listOfFiles;
91 | }
92 |
93 | }
94 |
--------------------------------------------------------------------------------
/crashreporter/src/main/java/com/balsikandar/crashreporter/ui/ExceptionLogFragment.java:
--------------------------------------------------------------------------------
1 | package com.balsikandar.crashreporter.ui;
2 |
3 | import android.content.Context;
4 | import android.os.Bundle;
5 | import android.support.annotation.Nullable;
6 | import android.support.v4.app.Fragment;
7 | import android.support.v7.widget.LinearLayoutManager;
8 | import android.support.v7.widget.RecyclerView;
9 | import android.text.TextUtils;
10 | import android.view.LayoutInflater;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 |
14 | import com.balsikandar.crashreporter.CrashReporter;
15 | import com.balsikandar.crashreporter.R;
16 | import com.balsikandar.crashreporter.adapter.CrashLogAdapter;
17 | import com.balsikandar.crashreporter.utils.Constants;
18 | import com.balsikandar.crashreporter.utils.CrashUtil;
19 |
20 | import java.io.File;
21 | import java.util.ArrayList;
22 | import java.util.Arrays;
23 | import java.util.Collections;
24 | import java.util.Iterator;
25 |
26 | /**
27 | * Created by bali on 11/08/17.
28 | */
29 |
30 | public class ExceptionLogFragment extends Fragment {
31 |
32 | private CrashLogAdapter logAdapter;
33 |
34 | private RecyclerView exceptionRecyclerView;
35 |
36 | @Override
37 | public void onCreate(@Nullable Bundle savedInstanceState) {
38 | super.onCreate(savedInstanceState);
39 | }
40 |
41 | @Nullable
42 | @Override
43 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
44 | View view = inflater.inflate(R.layout.exception_log, container, false);
45 | exceptionRecyclerView = (RecyclerView) view.findViewById(R.id.exceptionRecyclerView);
46 |
47 | return view;
48 | }
49 |
50 | @Override
51 | public void onResume() {
52 | super.onResume();
53 | loadAdapter(getActivity(), exceptionRecyclerView);
54 | }
55 |
56 | private void loadAdapter(Context context, RecyclerView exceptionRecyclerView) {
57 |
58 | logAdapter = new CrashLogAdapter(context, getAllExceptions());
59 | exceptionRecyclerView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
60 | exceptionRecyclerView.setAdapter(logAdapter);
61 | }
62 |
63 | public void clearLog() {
64 | if (logAdapter != null) {
65 | logAdapter.updateList(getAllExceptions());
66 | }
67 | }
68 |
69 | public ArrayList getAllExceptions() {
70 | String directoryPath;
71 | String crashReportPath = CrashReporter.getCrashReportPath();
72 |
73 | if (TextUtils.isEmpty(crashReportPath)){
74 | directoryPath = CrashUtil.getDefaultPath();
75 | } else{
76 | directoryPath = crashReportPath;
77 | }
78 |
79 | File directory = new File(directoryPath);
80 | if (!directory.exists() || !directory.isDirectory()){
81 | throw new RuntimeException("The path provided doesn't exists : " + directoryPath);
82 | }
83 |
84 | ArrayList listOfFiles = new ArrayList<>(Arrays.asList(directory.listFiles()));
85 | for (Iterator iterator = listOfFiles.iterator(); iterator.hasNext(); ) {
86 | if (iterator.next().getName().contains(Constants.CRASH_SUFFIX)) {
87 | iterator.remove();
88 | }
89 | }
90 | Collections.sort(listOfFiles, Collections.reverseOrder());
91 | return listOfFiles;
92 | }
93 |
94 | }
95 |
--------------------------------------------------------------------------------
/crashreporter/src/main/java/com/balsikandar/crashreporter/utils/FileUtils.java:
--------------------------------------------------------------------------------
1 | package com.balsikandar.crashreporter.utils;
2 |
3 | import android.text.TextUtils;
4 |
5 | import java.io.BufferedReader;
6 | import java.io.File;
7 | import java.io.FileReader;
8 | import java.io.IOException;
9 |
10 | /**
11 | * Created by bali on 10/08/17.
12 | */
13 |
14 | public class FileUtils {
15 |
16 | public static final String TAG = FileUtils.class.getSimpleName();
17 |
18 | private FileUtils() {
19 | //this class is not publicly instantiable
20 | }
21 |
22 | public static boolean delete(String absPath) {
23 | if (TextUtils.isEmpty(absPath)) {
24 | return false;
25 | }
26 |
27 | File file = new File(absPath);
28 | return delete(file);
29 | }
30 |
31 | public static boolean delete(File file) {
32 | if (!exists(file)) {
33 | return true;
34 | }
35 |
36 | if (file.isFile()) {
37 | return file.delete();
38 | }
39 |
40 | boolean result = true;
41 | File files[] = file.listFiles();
42 | if (files == null) return false;
43 | for (int index = 0; index < files.length; index++) {
44 | result |= delete(files[index]);
45 | }
46 | result |= file.delete();
47 |
48 | return result;
49 | }
50 |
51 | public static boolean exists(File file) {
52 | return file != null && file.exists();
53 | }
54 |
55 | public static String cleanPath(String absPath) {
56 | if (TextUtils.isEmpty(absPath)) {
57 | return absPath;
58 | }
59 | try {
60 | File file = new File(absPath);
61 | absPath = file.getCanonicalPath();
62 | } catch (Exception e) {
63 |
64 | }
65 | return absPath;
66 | }
67 |
68 | public final static String getParent(File file) {
69 | return file == null ? null : file.getParent();
70 | }
71 |
72 | public final static String getParent(String absPath) {
73 | if (TextUtils.isEmpty(absPath)) {
74 | return null;
75 | }
76 | absPath = cleanPath(absPath);
77 | File file = new File(absPath);
78 | return getParent(file);
79 | }
80 |
81 | public static boolean deleteFiles(String directoryPath) {
82 | String directoryToDelete;
83 | if (!TextUtils.isEmpty(directoryPath)) {
84 | directoryToDelete = directoryPath;
85 | } else {
86 | directoryToDelete = CrashUtil.getDefaultPath();
87 | }
88 |
89 | return delete(directoryToDelete);
90 | }
91 |
92 | public static String readFirstLineFromFile(File file) {
93 | String line = "";
94 | try {
95 | BufferedReader reader = new BufferedReader(new FileReader(file));
96 | line = reader.readLine();
97 | reader.close();
98 | } catch (IOException e) {
99 | e.printStackTrace();
100 | }
101 | return line;
102 | }
103 |
104 | public static String readFromFile(File file) {
105 | StringBuilder crash = new StringBuilder();
106 | try {
107 | BufferedReader reader = new BufferedReader(new FileReader(file));
108 | String line;
109 | while ((line = reader.readLine()) != null) {
110 | crash.append(line);
111 | crash.append('\n');
112 | }
113 | reader.close();
114 | } catch (IOException e) {
115 | e.printStackTrace();
116 | }
117 | return crash.toString();
118 | }
119 | }
120 |
--------------------------------------------------------------------------------
/crashreporter/src/main/java/com/balsikandar/crashreporter/ui/CrashReporterActivity.java:
--------------------------------------------------------------------------------
1 | package com.balsikandar.crashreporter.ui;
2 |
3 | import android.content.Intent;
4 | import android.content.pm.ApplicationInfo;
5 | import android.os.Bundle;
6 | import android.support.design.widget.TabLayout;
7 | import android.support.v4.view.ViewPager;
8 | import android.support.v7.app.AppCompatActivity;
9 | import android.support.v7.widget.Toolbar;
10 | import android.text.TextUtils;
11 | import android.view.Menu;
12 | import android.view.MenuItem;
13 |
14 | import com.balsikandar.crashreporter.CrashReporter;
15 | import com.balsikandar.crashreporter.R;
16 | import com.balsikandar.crashreporter.adapter.MainPagerAdapter;
17 | import com.balsikandar.crashreporter.utils.Constants;
18 | import com.balsikandar.crashreporter.utils.CrashUtil;
19 | import com.balsikandar.crashreporter.utils.FileUtils;
20 | import com.balsikandar.crashreporter.utils.SimplePageChangeListener;
21 |
22 | import java.io.File;
23 |
24 | public class CrashReporterActivity extends AppCompatActivity {
25 |
26 | private MainPagerAdapter mainPagerAdapter;
27 | private int selectedTabPosition = 0;
28 |
29 | //region activity callbacks
30 | @Override
31 | public boolean onCreateOptionsMenu(Menu menu) {
32 | getMenuInflater().inflate(R.menu.log_main_menu, menu);
33 | return true;
34 | }
35 |
36 | @Override
37 | public boolean onOptionsItemSelected(MenuItem item) {
38 | if (item.getItemId() == R.id.delete_crash_logs) {
39 | clearCrashLog();
40 | return true;
41 | } else {
42 | return super.onOptionsItemSelected(item);
43 | }
44 | }
45 |
46 | @Override
47 | protected void onCreate(Bundle savedInstanceState) {
48 | super.onCreate(savedInstanceState);
49 | setContentView(R.layout.crash_reporter_activity);
50 |
51 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
52 | toolbar.setTitle(getString(R.string.crash_reporter));
53 | toolbar.setSubtitle(getApplicationName());
54 | setSupportActionBar(toolbar);
55 |
56 | ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
57 | if (viewPager != null) {
58 | setupViewPager(viewPager);
59 | }
60 |
61 | TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
62 | tabLayout.setupWithViewPager(viewPager);
63 | }
64 | //endregion
65 |
66 | private void clearCrashLog() {
67 | new Thread(new Runnable() {
68 | @Override
69 | public void run() {
70 | String crashReportPath = TextUtils.isEmpty(CrashReporter.getCrashReportPath()) ?
71 | CrashUtil.getDefaultPath() : CrashReporter.getCrashReportPath();
72 |
73 | File[] logs = new File(crashReportPath).listFiles();
74 | for (File file : logs) {
75 | FileUtils.delete(file);
76 | }
77 | runOnUiThread(new Runnable() {
78 | @Override
79 | public void run() {
80 | mainPagerAdapter.clearLogs();
81 | }
82 | });
83 | }
84 | }).start();
85 | }
86 |
87 | private void setupViewPager(ViewPager viewPager) {
88 | String[] titles = {getString(R.string.crashes), getString(R.string.exceptions)};
89 | mainPagerAdapter = new MainPagerAdapter(getSupportFragmentManager(), titles);
90 | viewPager.setAdapter(mainPagerAdapter);
91 |
92 | viewPager.addOnPageChangeListener(new SimplePageChangeListener() {
93 | @Override
94 | public void onPageSelected(int position) {
95 | selectedTabPosition = position;
96 | }
97 | });
98 |
99 | Intent intent = getIntent();
100 | if (intent != null && !intent.getBooleanExtra(Constants.LANDING, false)) {
101 | selectedTabPosition = 1;
102 | }
103 | viewPager.setCurrentItem(selectedTabPosition);
104 | }
105 |
106 | private String getApplicationName() {
107 | ApplicationInfo applicationInfo = getApplicationInfo();
108 | int stringId = applicationInfo.labelRes;
109 | return stringId == 0 ? applicationInfo.nonLocalizedLabel.toString() : getString(stringId);
110 | }
111 |
112 | }
113 |
--------------------------------------------------------------------------------
/crashreporter/src/main/java/com/balsikandar/crashreporter/utils/AppUtils.java:
--------------------------------------------------------------------------------
1 | package com.balsikandar.crashreporter.utils;
2 |
3 | import android.Manifest;
4 | import android.accounts.Account;
5 | import android.accounts.AccountManager;
6 | import android.content.Context;
7 | import android.content.Intent;
8 | import android.content.pm.PackageInfo;
9 | import android.content.pm.PackageManager;
10 | import android.content.pm.ResolveInfo;
11 | import android.os.Build;
12 | import android.support.v4.app.ActivityCompat;
13 | import android.util.Log;
14 |
15 | import java.util.TimeZone;
16 | import java.util.UUID;
17 |
18 | /**
19 | * Created by bali on 12/08/17.
20 | */
21 |
22 | public class AppUtils {
23 | private static String getCurrentLauncherApp(Context context) {
24 | String str = "";
25 | PackageManager localPackageManager = context.getPackageManager();
26 | Intent intent = new Intent("android.intent.action.MAIN");
27 | intent.addCategory("android.intent.category.HOME");
28 | try {
29 | ResolveInfo resolveInfo = localPackageManager.resolveActivity(intent,
30 | PackageManager.MATCH_DEFAULT_ONLY);
31 | if (resolveInfo != null && resolveInfo.activityInfo != null) {
32 | str = resolveInfo.activityInfo.packageName;
33 | }
34 | } catch (Exception e) {
35 | Log.e("AppUtils", "Exception : " + e.getMessage());
36 | }
37 | return str;
38 | }
39 |
40 | private static String getUserIdentity(Context context) {
41 | if (ActivityCompat.checkSelfPermission(context, Manifest.permission.GET_ACCOUNTS) ==
42 | PackageManager.PERMISSION_GRANTED) {
43 | AccountManager manager = (AccountManager) context.getSystemService(Context.ACCOUNT_SERVICE);
44 | Account[] list = manager.getAccounts();
45 | String emailId = null;
46 | for (Account account : list) {
47 | if (account.type.equalsIgnoreCase("com.google")) {
48 | emailId = account.name;
49 | break;
50 | }
51 | }
52 | if (emailId != null) {
53 | return emailId;
54 | }
55 | }
56 | return "";
57 | }
58 |
59 | public static String getDeviceDetails(Context context) {
60 |
61 | return "Device Information\n"
62 | + "\nDEVICE.ID : " + getDeviceId(context)
63 | + "\nUSER.ID : " + getUserIdentity(context)
64 | + "\nAPP.VERSION : " + getAppVersion(context)
65 | + "\nLAUNCHER.APP : " + getCurrentLauncherApp(context)
66 | + "\nTIMEZONE : " + timeZone()
67 | + "\nVERSION.RELEASE : " + Build.VERSION.RELEASE
68 | + "\nVERSION.INCREMENTAL : " + Build.VERSION.INCREMENTAL
69 | + "\nVERSION.SDK.NUMBER : " + Build.VERSION.SDK_INT
70 | + "\nBOARD : " + Build.BOARD
71 | + "\nBOOTLOADER : " + Build.BOOTLOADER
72 | + "\nBRAND : " + Build.BRAND
73 | + "\nCPU_ABI : " + Build.CPU_ABI
74 | + "\nCPU_ABI2 : " + Build.CPU_ABI2
75 | + "\nDISPLAY : " + Build.DISPLAY
76 | + "\nFINGERPRINT : " + Build.FINGERPRINT
77 | + "\nHARDWARE : " + Build.HARDWARE
78 | + "\nHOST : " + Build.HOST
79 | + "\nID : " + Build.ID
80 | + "\nMANUFACTURER : " + Build.MANUFACTURER
81 | + "\nMODEL : " + Build.MODEL
82 | + "\nPRODUCT : " + Build.PRODUCT
83 | + "\nSERIAL : " + Build.SERIAL
84 | + "\nTAGS : " + Build.TAGS
85 | + "\nTIME : " + Build.TIME
86 | + "\nTYPE : " + Build.TYPE
87 | + "\nUNKNOWN : " + Build.UNKNOWN
88 | + "\nUSER : " + Build.USER;
89 | }
90 |
91 | private static String timeZone() {
92 | TimeZone tz = TimeZone.getDefault();
93 | return tz.getID();
94 | }
95 |
96 | private static String getDeviceId(Context context) {
97 | String androidDeviceId = getAndroidDeviceId(context);
98 | if (androidDeviceId == null)
99 | androidDeviceId = UUID.randomUUID().toString();
100 | return androidDeviceId;
101 |
102 | }
103 |
104 | private static String getAndroidDeviceId(Context context) {
105 | final String INVALID_ANDROID_ID = "9774d56d682e549c";
106 | final String androidId = android.provider.Settings.Secure.getString(
107 | context.getContentResolver(),
108 | android.provider.Settings.Secure.ANDROID_ID);
109 | if (androidId == null
110 | || androidId.toLowerCase().equals(INVALID_ANDROID_ID)) {
111 | return null;
112 | }
113 | return androidId;
114 | }
115 |
116 | private static int getAppVersion(Context context) {
117 | try {
118 | PackageInfo packageInfo = context.getPackageManager()
119 | .getPackageInfo(context.getPackageName(), 0);
120 | return packageInfo.versionCode;
121 | } catch (PackageManager.NameNotFoundException e) {
122 | throw new RuntimeException("Could not get package name: " + e);
123 | }
124 | }
125 | }
126 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | # CrashReporter
4 |
5 | [](https://mindorks.com/open-source-projects)
6 | [](https://mindorks.com/join-community)
7 | [](https://android-arsenal.com/details/1/6190) [](https://android-arsenal.com/api?level=15)
8 | [  ](https://bintray.com/balsikandarnsit/maven/Crash-Reporter/_latestVersion)
9 | [](https://opensource.org/licenses/Apache-2.0)
10 | [](https://github.com/balsikandar/CrashReporter/blob/master/LICENSE)
11 |
12 | ### CrashReporter is a handy tool to capture app crashes and save them in a file.
13 | Here is an [article](https://blog.mindorks.com/android-debugging-crashreporter-on-duty-f8ecfc63f3c6) related to this library.
14 |
15 | ### Why CrashReporter?
16 |
17 | While developing features we get crashes and if device is not connected to logcat we miss the crash log. In worst case scenario we might not be able to reproduce the crash and endup wasting effort. This library captures all unhandled crashes and saves them locally on device. I found a problem with other libraries that they capture crashes and then uploads them to server and sometimes few crashes aren't logged to server. That's the purpose of this library use it as a debug feature to capture crashes locally and immediately.
18 |
19 | ### Run the sample
20 |
21 |
22 | ### Crash Reporter APIs
23 |
24 | - Track all crashes
25 | - Use Log Exception API to log Exception
26 | - All crashes and exceptions are saved in device
27 | - Choose your own path to save crash reports and exceptions
28 | - Share Instantly crash log with your team with other device data.
29 |
30 | ### Crash reporter doesn't takes any permission or root access
31 | ### Using Crash Reporter Library in your application
32 | add below dependency in your app's gradle
33 | ```
34 | compile 'com.balsikandar.android:crashreporter:1.1.0'
35 | ```
36 | ### If you only want to use Crash reporter in debug builds only add
37 | ```
38 | debugCompile 'com.balsikandar.android:crashreporter:1.1.0'
39 | ```
40 | Note : If you get error like this "no resource identifier found for attribute 'alpha' in package 'android'" use below dependency. This may happen due to two different versions of design support library as CrashReporter also uses design support library internally.
41 |
42 | ```
43 | debugCompile('com.balsikandar.android:crashreporter:1.1.0') {
44 | exclude group: 'com.android.support', module: 'design'
45 | }
46 | ```
47 |
48 | ## Crash Reporter On Duty
49 | - It'll capture all unhandled crashes and write them to a file in below directory
50 | ```
51 | /Android/data/your-app-package-name/files/crashReports
52 | ```
53 | - To save crashes in a path of your choice, add below line in onCreate method of your Application class
54 | ```
55 | CrashReporter.initialize(this, crashReporterPath);
56 | ```
57 | Note: You don't need to call CrashReporter.initialize() if you want logs to be saved in default directory. If you want to use external storage then add storage permission in you manifest file.
58 |
59 | ```
60 |
61 | ```
62 |
63 | ### Using log Exception API
64 | ### If you want to capture exceptions then you can use below API
65 | for ex :
66 | ```
67 | try {
68 | // Do your stuff
69 | } catch (Exception e) {
70 | CrashReporter.logException(e);
71 | }
72 | ```
73 | Pass exception thrown in below method
74 |
75 | ```
76 | logException(Exception exception)
77 | ```
78 |
79 | ### To get default crash reports path
80 | ```
81 | CrashUtil.getDefaultPath()
82 | ```
83 | you can access all crash/exception log files from this path and upload them to server for your need. Remember it's default path
84 | if you provide your own path you know where to find the logs...
85 |
86 | ### TODO
87 | Context awareness to track crashes and fix them.
88 | Identify crashes and categorise them in groups
89 |
90 | ### Find this project useful ? :heart:
91 | * Support it by clicking the :star: button on the upper right of this page. :v:
92 |
93 | ### That's it for now
94 |
95 | ### Contact - Let's connect and share knowledge
96 | - [Twitter](https://twitter.com/balsikandar)
97 | - [Github](https://github.com/balsikandar)
98 | - [Medium](https://medium.com/@balsikandar.nsit)
99 | - [Facebook](https://www.facebook.com/balsikandar)
100 |
101 | ### License
102 |
103 | ```
104 | Copyright (C) 2016 Bal Sikandar
105 | Copyright (C) 2011 Android Open Source Project
106 |
107 | Licensed under the Apache License, Version 2.0 (the "License");
108 | you may not use this file except in compliance with the License.
109 | You may obtain a copy of the License at
110 |
111 | http://www.apache.org/licenses/LICENSE-2.0
112 |
113 | Unless required by applicable law or agreed to in writing, software
114 | distributed under the License is distributed on an "AS IS" BASIS,
115 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
116 | See the License for the specific language governing permissions and
117 | limitations under the License.
118 | ```
119 | ### Contributing to this Repo
120 | Create a pull request and Dive In.
121 |
--------------------------------------------------------------------------------
/crashreporter/src/main/java/com/balsikandar/crashreporter/utils/CrashUtil.java:
--------------------------------------------------------------------------------
1 | package com.balsikandar.crashreporter.utils;
2 |
3 | import android.app.NotificationChannel;
4 | import android.app.NotificationManager;
5 | import android.app.PendingIntent;
6 | import android.content.Context;
7 | import android.content.Intent;
8 | import android.os.Build;
9 | import android.support.v4.app.NotificationCompat;
10 | import android.support.v4.content.ContextCompat;
11 | import android.text.TextUtils;
12 | import android.util.Log;
13 |
14 | import com.balsikandar.crashreporter.CrashReporter;
15 | import com.balsikandar.crashreporter.R;
16 |
17 | import java.io.BufferedWriter;
18 | import java.io.File;
19 | import java.io.FileWriter;
20 | import java.io.PrintWriter;
21 | import java.io.StringWriter;
22 | import java.io.Writer;
23 | import java.text.SimpleDateFormat;
24 | import java.util.Date;
25 | import java.util.Locale;
26 |
27 | import static android.content.Context.NOTIFICATION_SERVICE;
28 | import static com.balsikandar.crashreporter.utils.Constants.CHANNEL_NOTIFICATION_ID;
29 |
30 | public class CrashUtil {
31 |
32 | private static final String TAG = CrashUtil.class.getSimpleName();
33 |
34 | private CrashUtil() {
35 | //this class is not publicly instantiable
36 | }
37 |
38 | private static String getCrashLogTime() {
39 | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
40 | return dateFormat.format(new Date());
41 | }
42 |
43 | public static void saveCrashReport(final Throwable throwable) {
44 |
45 | String crashReportPath = CrashReporter.getCrashReportPath();
46 | String filename = getCrashLogTime() + Constants.CRASH_SUFFIX + Constants.FILE_EXTENSION;
47 | writeToFile(crashReportPath, filename, getStackTrace(throwable));
48 |
49 | showNotification(throwable.getLocalizedMessage(), true);
50 | }
51 |
52 | public static void logException(final Exception exception) {
53 |
54 | new Thread(new Runnable() {
55 | @Override
56 | public void run() {
57 |
58 | String crashReportPath = CrashReporter.getCrashReportPath();
59 | final String filename = getCrashLogTime() + Constants.EXCEPTION_SUFFIX + Constants.FILE_EXTENSION;
60 | writeToFile(crashReportPath, filename, getStackTrace(exception));
61 |
62 | showNotification(exception.getLocalizedMessage(), false);
63 | }
64 | }).start();
65 | }
66 |
67 | private static void writeToFile(String crashReportPath, String filename, String crashLog) {
68 |
69 | if (TextUtils.isEmpty(crashReportPath)) {
70 | crashReportPath = getDefaultPath();
71 | }
72 |
73 | File crashDir = new File(crashReportPath);
74 | if (!crashDir.exists() || !crashDir.isDirectory()) {
75 | crashReportPath = getDefaultPath();
76 | Log.e(TAG, "Path provided doesn't exists : " + crashDir + "\nSaving crash report at : " + getDefaultPath());
77 | }
78 |
79 | BufferedWriter bufferedWriter;
80 | try {
81 | bufferedWriter = new BufferedWriter(new FileWriter(
82 | crashReportPath + File.separator + filename));
83 |
84 | bufferedWriter.write(crashLog);
85 | bufferedWriter.flush();
86 | bufferedWriter.close();
87 | Log.d(TAG, "crash report saved in : " + crashReportPath);
88 | } catch (Exception e) {
89 | e.printStackTrace();
90 | }
91 | }
92 |
93 | private static void showNotification(String localisedMsg, boolean isCrash) {
94 |
95 | if (CrashReporter.isNotificationEnabled()) {
96 | Context context = CrashReporter.getContext();
97 | NotificationManager notificationManager = (NotificationManager) context.
98 | getSystemService(NOTIFICATION_SERVICE);
99 | createNotificationChannel(notificationManager, context);
100 | NotificationCompat.Builder builder = new NotificationCompat.Builder(context, CHANNEL_NOTIFICATION_ID);
101 | builder.setSmallIcon(R.drawable.ic_warning_black_24dp);
102 |
103 | Intent intent = CrashReporter.getLaunchIntent();
104 | intent.putExtra(Constants.LANDING, isCrash);
105 | intent.setAction(Long.toString(System.currentTimeMillis()));
106 |
107 | PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
108 | builder.setContentIntent(pendingIntent);
109 |
110 | builder.setContentTitle(context.getString(R.string.view_crash_report));
111 |
112 | if (TextUtils.isEmpty(localisedMsg)) {
113 | builder.setContentText(context.getString(R.string.check_your_message_here));
114 | } else {
115 | builder.setContentText(localisedMsg);
116 | }
117 |
118 | builder.setAutoCancel(true);
119 | builder.setColor(ContextCompat.getColor(context, R.color.colorAccent_CrashReporter));
120 |
121 | notificationManager.notify(Constants.NOTIFICATION_ID, builder.build());
122 | }
123 | }
124 |
125 | private static void createNotificationChannel(NotificationManager notificationManager, Context context) {
126 | if (Build.VERSION.SDK_INT >= 26) {
127 | CharSequence name = context.getString(R.string.notification_crash_report_title);
128 | String description = "";
129 | NotificationChannel channel = new NotificationChannel(CHANNEL_NOTIFICATION_ID, name, NotificationManager.IMPORTANCE_DEFAULT);
130 | channel.setDescription(description);
131 | notificationManager.createNotificationChannel(channel);
132 | }
133 | }
134 |
135 | private static String getStackTrace(Throwable e) {
136 | final Writer result = new StringWriter();
137 | final PrintWriter printWriter = new PrintWriter(result);
138 |
139 | e.printStackTrace(printWriter);
140 | String crashLog = result.toString();
141 | printWriter.close();
142 | return crashLog;
143 | }
144 |
145 | public static String getDefaultPath() {
146 | String defaultPath = CrashReporter.getContext().getExternalFilesDir(null).getAbsolutePath()
147 | + File.separator + Constants.CRASH_REPORT_DIR;
148 |
149 | File file = new File(defaultPath);
150 | file.mkdirs();
151 | return defaultPath;
152 | }
153 | }
154 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------