Skip to content

Commit

Permalink
Resolved issue causing crash on EMAIL ERROR LOG on newer APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
Rohit Surwase committed Mar 9, 2019
1 parent 5e8fd89 commit 29f0453
Show file tree
Hide file tree
Showing 18 changed files with 71 additions and 30 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

/gradle.properties

.DS_Store

# Files for the ART/Dalvik VM
*.dex

Expand Down Expand Up @@ -45,6 +47,9 @@ captures/
.idea/gradle.xml
.idea/dictionaries
.idea/libraries
.idea/caches
.idea/markdown-navigator.xml
.idea/markdown-navigator/

# Keystore files
*.jks
Expand Down
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
4 changes: 4 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright © 2018 Rohit Sahebrao Surwase
Copyright © 2018-2019 Rohit Sahebrao Surwase

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.android.tools.build:gradle:3.4.0-rc01'


// NOTE: Do not place your application dependencies here; they belong
Expand Down
6 changes: 3 additions & 3 deletions example_app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 27
compileSdkVersion 28
defaultConfig {
applicationId "com.rohitss.uce_handler"
minSdkVersion 14
targetSdkVersion 27
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
Expand All @@ -19,7 +19,7 @@ android {

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.0.2'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation project(':uce_handler')
implementation project(':ignore-dummy-module')
}
2 changes: 2 additions & 0 deletions example_app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.rohitss.uceh_example">

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

<application
android:name=".MyApplication"
android:allowBackup="true"
Expand Down
16 changes: 13 additions & 3 deletions example_app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.rohitss.uceh_example.MainActivity">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="20dp"
android:layout_marginTop="40dp"
android:layout_marginRight="20dp"
android:text="If you also want to check the SAVE and EMAIL ERROR LOG functionality, you need to enable storage permission manually for this App."
android:textColor="@android:color/black"
android:textSize="16sp" />

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:onClick="onCrashButtonClicked"
android:text="Crash This App"/>
android:text="Crash This App" />
</RelativeLayout>
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Jan 17 20:13:49 IST 2018
#Wed Oct 03 15:02:51 IST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
7 changes: 2 additions & 5 deletions ignore-dummy-module/build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 27


compileSdkVersion 28

defaultConfig {
minSdkVersion 14
targetSdkVersion 27
targetSdkVersion 28
versionCode 1
versionName "1.0"

}

buildTypes {
Expand Down
6 changes: 3 additions & 3 deletions uce_handler/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 27
compileSdkVersion 28

defaultConfig {
minSdkVersion 14
targetSdkVersion 27
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
Expand All @@ -20,5 +20,5 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.0.2'
implementation 'com.android.support:appcompat-v7:28.0.0'
}
14 changes: 12 additions & 2 deletions uce_handler/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.rohitss.uceh">
package="com.rohitss.uceh">

<application>
<activity
android:name=".UCEDefaultActivity"
android:process=":error_activity"/>
android:process=":error_activity" />

<provider
android:name=".UCEFileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths" />
</provider>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2018 Rohit Sahebrao Surwase.
* * Copyright © 2018-19 Rohit Sahebrao Surwase.
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -32,6 +32,7 @@
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.support.v4.content.FileProvider;
import android.text.TextUtils;
import android.util.Log;
import android.util.TypedValue;
Expand All @@ -48,8 +49,6 @@
import java.util.Locale;

/**
* <b></b>
* <p>This class is used to </p>
* Created by Rohit.
*/
public final class UCEDefaultActivity extends Activity {
Expand Down Expand Up @@ -155,9 +154,10 @@ private void emailErrorLog() {
emailIntent.putExtra(Intent.EXTRA_SUBJECT, getApplicationName(UCEDefaultActivity.this) + " Application Crash Error Log");
emailIntent.putExtra(Intent.EXTRA_TEXT, getString(R.string.email_welcome_note) + errorLog);
if (txtFile.exists()) {
Uri filePath = Uri.fromFile(txtFile);
Uri filePath = FileProvider.getUriForFile(this, this.getApplicationContext().getPackageName() + ".provider", txtFile);
emailIntent.putExtra(Intent.EXTRA_STREAM, filePath);
}
emailIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(Intent.createChooser(emailIntent, "Email Error Log"));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.rohitss.uceh;


import android.support.v4.content.FileProvider;

public class UCEFileProvider extends FileProvider {
}
4 changes: 1 addition & 3 deletions uce_handler/src/main/java/com/rohitss/uceh/UCEHandler.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2018 Rohit Sahebrao Surwase.
* * Copyright © 2018-19 Rohit Sahebrao Surwase.
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -36,8 +36,6 @@
import java.util.Locale;

/**
* <b></b>
* <p>This class is used to </p>
* Created by Rohit.
*/
public final class UCEHandler {
Expand Down
4 changes: 4 additions & 0 deletions uce_handler/src/main/res/xml/provider_paths.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<paths>
<external-path name="external_files" path="."/>
</paths>

0 comments on commit 29f0453

Please sign in to comment.