Skip to content

Commit

Permalink
Added firebase crashlytics support and migrated gradle groovy to kotl…
Browse files Browse the repository at this point in the history
…in dsl (#53)
  • Loading branch information
rob729 committed Jan 1, 2024
1 parent dd3a0c4 commit 22d1d96
Show file tree
Hide file tree
Showing 11 changed files with 224 additions and 190 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ jobs:
- name: Decode google-services.json
env:
GOOGLE_SERVICES: ${{ secrets.GOOGLE_SERVICES }}
run: echo $GOOGLE_SERVICES > app/src/debug/google-services.json
GOOGLE_SERVICES_DEBUG: ${{ secrets.GOOGLE_SERVICES_DEBUG }}
run: |
echo $GOOGLE_SERVICES > app/google-services.json
echo $GOOGLE_SERVICES_DEBUG > app/src/debug/google-services.json
- name: Build debug APK and run jvm tests
env:
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/prod-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ jobs:
echo $KEYSTORE_PROPERTIES | base64 --decode > keystore.properties
echo $KEYSTORE_FILE | base64 --decode > Keystore.p12
- name: Create debug directory
run: mkdir -p app/src/debug

- name: Decode google-services.json
env:
GOOGLE_SERVICES: ${{ secrets.GOOGLE_SERVICES }}
GOOGLE_SERVICES_DEBUG: ${{ secrets.GOOGLE_SERVICES_DEBUG }}
run: |
echo $GOOGLE_SERVICES > app/google-services.json
echo $GOOGLE_SERVICES_DEBUG > app/src/debug/google-services.json
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ keystore.properties
Keystore.p12
app/release
news-feed-play-config.json
google-services.json
166 changes: 0 additions & 166 deletions app/build.gradle

This file was deleted.

174 changes: 174 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
@file:Suppress("UnstableApiUsage")

import java.util.Properties

plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.ksp)
alias(libs.plugins.kotlin.parcelize)
alias(libs.plugins.androidx.baselineprofile)
alias(libs.plugins.detekt)
if (File("app/google-services.json").exists() && File("app/src/debug/google-services.json").exists()) {
alias(libs.plugins.google.services)
alias(libs.plugins.firebase.crashlytics)
}
}

val debugAppSuffix = ".debug"

val localPropertiesFile = rootProject.file("local.properties")
val localProperties = Properties()
var newsFeedApiKey = if (localPropertiesFile.exists()) {
localProperties.load(localPropertiesFile.inputStream())
localProperties.getProperty("NEWS_FEED_API_KEY") ?: "\"${System.getenv("NEWS_FEED_API_KEY")}\""
} else {
"\"${System.getenv("NEWS_FEED_API_KEY")}\""
}

val keystorePropertiesFile = rootProject.file("keystore.properties")
val keystoreProperties = Properties()
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(keystorePropertiesFile.inputStream())
}

android {
experimentalProperties["android.experimental.art-profile-r8-rewriting"] = true
experimentalProperties["android.experimental.r8.dex-startup-optimization"] = true
signingConfigs {
create("release") {
storeFile = file("../Keystore.p12")
storePassword = keystoreProperties["storePassword"] as? String
keyAlias = keystoreProperties["keyAlias"] as? String
keyPassword = keystoreProperties["keyPassword"] as? String
}
}
compileSdk = 34

defaultConfig {
applicationId = "com.rob729.newsfeed"
minSdk = 24
targetSdk = 34
versionCode = 1
versionName = "1.0.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true

buildConfigField("String", "NEWS_FEED_API_KEY", newsFeedApiKey)

ksp {
arg("room.schemaLocation", "$projectDir/schemas")
}
}

buildTypes {
getByName("debug") {
applicationIdSuffix = debugAppSuffix
}
getByName("release") {
isShrinkResources = true
isMinifyEnabled = true
isDebuggable = false

signingConfig = signingConfigs.getByName("release")
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
create("benchmark") {
initWith(getByName("release"))
signingConfig = signingConfigs.getByName("debug")
proguardFiles("benchmark-rules.pro")
matchingFallbacks += listOf("release")
}
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "17"
}
buildFeatures {
compose = true
buildConfig = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.7"
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
namespace = "com.rob729.newsfeed"
}

baselineProfile {
dexLayoutOptimization = true
baselineProfileRulesRewrite = true
baselineProfileOutputDir = "../../src/main/baselineProfiles"
}

dependencies {

implementation(libs.androidx.core.ktx)
implementation(platform(libs.compose.bom))
implementation(libs.compose.ui)
implementation(libs.androidx.compose.ui.tooling.preview)
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(libs.androidx.activity.compose)
testImplementation(libs.junit)

androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
"baselineProfile"(project(":baselineprofile"))
debugImplementation(libs.androidx.compose.ui.tooling)
debugImplementation(libs.androidx.compose.ui.test.manifest)
implementation(libs.androidx.navigation.compose)
implementation(libs.androidx.compose.material.icons.extended)
implementation(libs.androidx.compose.material3)
implementation(libs.androidx.lifecycle.viewmodel.compose)
implementation(libs.androidx.constraintlayout.compose)

implementation(libs.androidx.work.runtime.ktx)
implementation(libs.androidx.browser)
implementation(libs.androidx.profileinstaller)
implementation(libs.androidx.startup.runtime)
implementation(libs.androidx.datastore.preferences)
implementation(libs.androidx.runtime.tracing)

implementation(libs.coil)
implementation(libs.coil.compose)

implementation(libs.moshi.kotlin)
ksp(libs.moshi.codegen)

implementation(libs.orbit.viewmodel)
implementation(libs.orbit.compose)

implementation(libs.retrofit)
implementation(libs.converter.moshi)
implementation(libs.logging.interceptor)

implementation(libs.kotlinx.datetime)

implementation(libs.androidx.room.runtime)
ksp(libs.androidx.room.compiler)
implementation(libs.androidx.room.ktx)

implementation(libs.koin.android)
implementation(libs.koin.androidx.compose)

debugImplementation(libs.pluto)
releaseImplementation(libs.pluto.no.op)

debugImplementation(libs.bundle.core)
releaseImplementation(libs.bundle.core.no.op)

if (File("${project.projectDir}/google-services.json").exists() && File("${project.projectDir}/src/debug/google-services.json").exists()) {
implementation(platform(libs.firebase.bom))
implementation(libs.firebase.analytics)
implementation(libs.firebase.crashlytics)
}
}
4 changes: 2 additions & 2 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
# proguardFiles setting in build.gradle.kts.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
Expand Down Expand Up @@ -31,4 +31,4 @@
# With R8 full mode generic signatures are stripped for classes that are not
# kept. Suspend functions are wrapped in continuations where the type argument
# is used.
-keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation
-keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation
Loading

0 comments on commit 22d1d96

Please sign in to comment.