Skip to content

Commit

Permalink
Merge pull request #65 from AAkira/kotlin-1.5
Browse files Browse the repository at this point in the history
Kotlin 1.5
  • Loading branch information
AAkira authored May 11, 2021
2 parents d1f14d1 + 5ee84e4 commit a06a4c4
Show file tree
Hide file tree
Showing 16 changed files with 234 additions and 155 deletions.
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,15 @@ Write this in your application class.
if (BuildConfig.DEBUG) {
// Debug build

// disable firebase crashlytics
FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(false)
// init napier
Napier.base(DebugAntilog())
} else {
// Others(Release build)

// init firebase crashlytics
Fabric.with(this, Crashlytics())
// enable firebase crashlytics
FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(true)
// init napier
Napier.base(CrashlyticsAntilog(this))
}
Expand All @@ -249,18 +251,14 @@ NapierProxyKt.debugBuild()

// init firebase crashlytics
FirebaseApp.configure()
Fabric.with([Crashlytics.self])

// init napier
NapierProxyKt.releaseBuild(antilog: CrashlyticsAntilog(
crashlyticsAddLog: { priority, tag, message in
let args = [tag, message].compactMap { $0 }
CLSLogv("%@", getVaList(args))
return .init()
Crashlytics.crashlytics().log("\(String(describing: tag)): \(String(describing: message))")
},
crashlyticsSendLog: { throwable in
Crashlytics.sharedInstance().recordError(throwable)
return .init()
Crashlytics.crashlytics().record(error: throwable)
}))
#endif
```
Expand Down
3 changes: 0 additions & 3 deletions android/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
/build

# firebase authentication file
google-services.json
7 changes: 6 additions & 1 deletion android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ android {
buildFeatures {
viewBinding = true
}

compileOptions {
sourceCompatibility(JavaVersion.VERSION_1_8)
targetCompatibility(JavaVersion.VERSION_1_8)
}
}

dependencies {
Expand All @@ -52,6 +57,6 @@ dependencies {
implementation(Dep.Android.constraintLayout)

// for crashlytics sample
implementation(Dep.Firebase.core)
implementation(platform(Dep.Firebase.platform))
implementation(Dep.Firebase.crashlytics)
}
83 changes: 83 additions & 0 deletions android/google-services.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
{
"project_info": {
"project_number": "1072620373207",
"firebase_url": "https://napier-82786.firebaseio.com",
"project_id": "napier-82786",
"storage_bucket": "napier-82786.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:1072620373207:android:ab90809f391c88a6",
"android_client_info": {
"package_name": "com.github.aakira.napier.sample"
}
},
"oauth_client": [
{
"client_id": "1072620373207-fvt7g7gejodn5902pcqk3pnu3rarcn2m.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyB2FOeVHSdlKZFYEQSfjG1dVBOUhLCnh5o"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "1072620373207-fvt7g7gejodn5902pcqk3pnu3rarcn2m.apps.googleusercontent.com",
"client_type": 3
},
{
"client_id": "1072620373207-89solc0vol23brafmaho0nnbc9bvucdr.apps.googleusercontent.com",
"client_type": 2,
"ios_info": {
"bundle_id": "io.github.aakira.napier.sample"
}
}
]
}
}
},
{
"client_info": {
"mobilesdk_app_id": "1:1072620373207:android:d95a2b4bcb9bd045481c92",
"android_client_info": {
"package_name": "io.github.aakira.napier.sample"
}
},
"oauth_client": [
{
"client_id": "1072620373207-fvt7g7gejodn5902pcqk3pnu3rarcn2m.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyB2FOeVHSdlKZFYEQSfjG1dVBOUhLCnh5o"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "1072620373207-fvt7g7gejodn5902pcqk3pnu3rarcn2m.apps.googleusercontent.com",
"client_type": 3
},
{
"client_id": "1072620373207-89solc0vol23brafmaho0nnbc9bvucdr.apps.googleusercontent.com",
"client_type": 2,
"ios_info": {
"bundle_id": "io.github.aakira.napier.sample"
}
}
]
}
}
}
],
"configuration_version": "1"
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.github.aakira.napier.sample

import android.content.Context
import com.crashlytics.android.Crashlytics
import com.google.firebase.crashlytics.FirebaseCrashlytics
import io.github.aakira.napier.Antilog
import io.github.aakira.napier.Napier

Expand All @@ -15,16 +15,16 @@ class CrashlyticsAntilog(private val context: Context) : Antilog() {
) {
// send only error log
if (priority < Napier.Level.ERROR) return
Crashlytics.getInstance().core.log(priority.ordinal, tag, message)

throwable?.let {
when {
when (it) {
// e.g. http exception, add a customized your exception message
// it is KtorException -> {
// Crashlytics.getInstance().core.log(priority.ordinal, "HTTP Exception", it.response?.errorBody.toString())
// is KtorException -> {
// FirebaseCrashlytics.getInstance()
// .log("${priority.ordinal}, HTTP Exception, ${it.response?.errorBody}")
// }
else -> FirebaseCrashlytics.getInstance().recordException(it)
}
Crashlytics.getInstance().core.logException(it)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package io.github.aakira.napier.sample

import android.app.Application
import com.crashlytics.android.Crashlytics
import io.fabric.sdk.android.Fabric
import com.google.firebase.crashlytics.FirebaseCrashlytics
import io.github.aakira.napier.DebugAntilog
import io.github.aakira.napier.Napier

Expand All @@ -13,14 +12,14 @@ class NapierApp : Application() {

if (BuildConfig.DEBUG) {
// Debug build
FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(false)

// init napier
Napier.base(DebugAntilog())
} else {
// Others(Release build)
FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(true)

// init firebase crashlytics
Fabric.with(this, Crashlytics())
// init napier
Napier.base(CrashlyticsAntilog(this))
}
Expand Down
14 changes: 7 additions & 7 deletions buildSrc/src/main/kotlin/dependencies/Dep.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package dependencies

object Dep {

private const val kotlin = "1.4.32"
private const val kotlin = "1.5.0"

object GradlePlugin {
const val kotlin = "org.jetbrains.kotlin:kotlin-gradle-plugin:${Dep.kotlin}"

const val android = "com.android.tools.build:gradle:4.1.0"
const val android = "com.android.tools.build:gradle:4.1.3"

const val crashlytics = "com.google.firebase:firebase-crashlytics-gradle:2.5.2"
const val googleService = "com.google.gms:google-services:4.3.5"
Expand All @@ -20,7 +20,7 @@ object Dep {
}

object Coroutines {
private const val version = "1.4.3"
private const val version = "1.5.0-RC"

const val core = "org.jetbrains.kotlinx:kotlinx-coroutines-core:$version"
}
Expand All @@ -33,12 +33,12 @@ object Dep {
}

object Android {
const val appCompat = "androidx.appcompat:appcompat:1.1.0"
const val constraintLayout = "androidx.constraintlayout:constraintlayout:2.0.0-beta4"
const val appCompat = "androidx.appcompat:appcompat:1.2.0"
const val constraintLayout = "androidx.constraintlayout:constraintlayout:2.0.4"
}

object Firebase {
const val core = "com.google.firebase:firebase-core:17.2.3"
const val crashlytics = "com.crashlytics.sdk.android:crashlytics:2.10.1"
const val platform = "com.google.firebase:firebase-bom:27.1.0"
const val crashlytics = "com.google.firebase:firebase-crashlytics-ktx"
}
}
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/dependencies/Versions.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package dependencies

object Versions {
const val versionCode = 14
const val versionName = "1.4.1"
const val versionCode = 15
const val versionName = "1.5.0"

// android
const val androidVersionCode = 1
Expand Down
3 changes: 1 addition & 2 deletions ios/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ xcuserdata/
*.dSYM

Pods/
GoogleService-info.plist
vendor/
vendor/
22 changes: 11 additions & 11 deletions ios/Napier.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
objects = {

/* Begin PBXBuildFile section */
3DCFA34A231D677B00C2CB83 /* Common.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3DCFA349231D677B00C2CB83 /* Common.framework */; };
3DCFA34B231D677B00C2CB83 /* Common.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3DCFA349231D677B00C2CB83 /* Common.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
3B3988B1264ADA500055407D /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3988B0264ADA500055407D /* GoogleService-Info.plist */; };
3B3988B3264AE4F50055407D /* Common.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B3988B2264AE4F40055407D /* Common.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
74AC91897E121EEADF59069F /* Pods_Napier.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 236CB35798B6FF37795E2A6A /* Pods_Napier.framework */; };
7CFB659A22013CF600BD05FC /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7CFB659922013CF600BD05FC /* AppDelegate.swift */; };
7CFB659C22013CF600BD05FC /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7CFB659B22013CF600BD05FC /* ViewController.swift */; };
Expand All @@ -24,7 +24,7 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
3DCFA34B231D677B00C2CB83 /* Common.framework in Embed Frameworks */,
3B3988B3264AE4F50055407D /* Common.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -34,9 +34,9 @@
/* Begin PBXFileReference section */
14D73DDEDA418BBBD3C23B9B /* Pods-Napier.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Napier.release.xcconfig"; path = "Target Support Files/Pods-Napier/Pods-Napier.release.xcconfig"; sourceTree = "<group>"; };
236CB35798B6FF37795E2A6A /* Pods_Napier.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Napier.framework; sourceTree = BUILT_PRODUCTS_DIR; };
3DCFA349231D677B00C2CB83 /* Common.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Common.framework; path = "../mpp-sample/build/bin/ios/CommonDebugFramework/Common.framework"; sourceTree = "<group>"; };
3B3988B0264ADA500055407D /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
3B3988B2264AE4F40055407D /* Common.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Common.framework; path = "../mpp-sample/build/xcode-frameworks/Common.framework"; sourceTree = "<group>"; };
6F88F8388EB37A3B9C7069DF /* Pods-Napier.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Napier.debug.xcconfig"; path = "Target Support Files/Pods-Napier/Pods-Napier.debug.xcconfig"; sourceTree = "<group>"; };
7C4D387022152BC1004168BB /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
7CFB659622013CF500BD05FC /* Napier.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Napier.app; sourceTree = BUILT_PRODUCTS_DIR; };
7CFB659922013CF600BD05FC /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
7CFB659B22013CF600BD05FC /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
Expand All @@ -51,7 +51,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
3DCFA34A231D677B00C2CB83 /* Common.framework in Frameworks */,
74AC91897E121EEADF59069F /* Pods_Napier.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -79,7 +78,7 @@
7CFB658D22013CF500BD05FC = {
isa = PBXGroup;
children = (
3DCFA349231D677B00C2CB83 /* Common.framework */,
3B3988B2264AE4F40055407D /* Common.framework */,
7CFB659822013CF500BD05FC /* Napier */,
7CFB659722013CF500BD05FC /* Products */,
10E92F91406E001698737DB9 /* Pods */,
Expand All @@ -98,7 +97,7 @@
7CFB659822013CF500BD05FC /* Napier */ = {
isa = PBXGroup;
children = (
7C4D387022152BC1004168BB /* GoogleService-Info.plist */,
3B3988B0264ADA500055407D /* GoogleService-Info.plist */,
7CFB659922013CF600BD05FC /* AppDelegate.swift */,
7CFB659B22013CF600BD05FC /* ViewController.swift */,
7CFB659D22013CF600BD05FC /* Main.storyboard */,
Expand Down Expand Up @@ -173,6 +172,7 @@
buildActionMask = 2147483647;
files = (
7CFB65A422013CF900BD05FC /* LaunchScreen.storyboard in Resources */,
3B3988B1264ADA500055407D /* GoogleService-Info.plist in Resources */,
7CFB65A122013CF900BD05FC /* Assets.xcassets in Resources */,
7CFB659F22013CF600BD05FC /* Main.storyboard in Resources */,
);
Expand Down Expand Up @@ -220,7 +220,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Fabric/run\"\n";
shellScript = "\"${PODS_ROOT}/FirebaseCrashlytics/run\"\n";
};
7CFB65CB22013DC300BD05FC /* Kotlin/Native */ = {
isa = PBXShellScriptBuildPhase;
Expand Down Expand Up @@ -418,7 +418,7 @@
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
"$SRCROOT/../mpp-sample/build/bin/ios/CommonDebugFramework",
"$SRCROOT/../mpp-sample/build/xcode-frameworks",
"$(inherited)",
);
INFOPLIST_FILE = Napier/Info.plist;
Expand All @@ -441,7 +441,7 @@
CODE_SIGN_STYLE = Automatic;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
"$SRCROOT/../mpp-sample/build/bin/ios/CommonReleaseFramework",
"$SRCROOT/../mpp-sample/build/bin/ios/ReleaseFramework",
"$(inherited)",
);
INFOPLIST_FILE = Napier/Info.plist;
Expand Down
Loading

0 comments on commit a06a4c4

Please sign in to comment.