Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ docker_env:
- image: circleci/android:api-28-alpha
environment:
<<: *cache_version_keys
JAVA_OPTS: "-Xms512m -Xmx2048m"
JAVA_OPTS: "-Xmx1024m"
GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError" -Dorg.gradle.daemon=false -Dorg.gradle.parallel=false'

go_defaults: &go_defaults
Expand Down Expand Up @@ -66,7 +66,7 @@ jobs:
name: Assemble apk from App Bundle
command: |
use_debug_keystore
./gradlew bundleDebug --offline
./gradlew bundleStaging --offline
create_universal_apk_from_aab.bash $(find frontend/android/build/outputs -name "*.aab" | head -1)
- store_artifacts:
path: frontend/android/build/outputs
Expand Down Expand Up @@ -104,7 +104,7 @@ jobs:
- restore_cache: *restore_gradle_cache
- run: *download_all_dependencies
- save_cache: *save_gradle_cache
- run: ./gradlew testDebugUnitTest lintDebug ktlint --continue --offline
- run: ./gradlew lintDebug testDebugUnitTest ktlint --continue --offline # we want to check lintRelease as well but RAM shortage... oh my...
- run:
name: Aggregate junit report files into one dir
command: aggregate_junit_results
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ build/

**/vendor/bundle/
**/xcuserdata/

proguard-merged-config.txt
43 changes: 38 additions & 5 deletions frontend/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ android {
storeFile file('debug.keystore')
storePassword 'droidkaigi'
}
release {
keyAlias System.getenv("RELEASE_KEY_ALIAS")
keyPassword System.getenv("RELEASE_KEY_PASSWORD")
storeFile file(System.getenv("RELEASE_STORE_FILE") ?: "debug.keystore")
storePassword System.getenv("RELEASE_PASSWORD")
}
}
defaultConfig {
applicationId "io.github.droidkaigi.confsched2019"
Expand All @@ -33,10 +39,33 @@ android {
manifestPlaceholders = [isCi: String.valueOf(isCi)]
}
buildTypes {
staging {
zipAlignEnabled true

postprocessing {
proguardFiles 'proguard-rules.pro'
obfuscate = true
// if we want to enable optimization, then codeShrinker must be proguard for now
// That may be a bug of r8
optimizeCode = false
removeUnusedCode = true
removeUnusedResources = true
codeShrinker = 'r8'
}
}
release.initWith(staging)
staging {
debuggable true
signingConfig = signingConfigs.debug
matchingFallbacks = ['release']
}
release {
applicationIdSuffix ""
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
applicationIdSuffix null
signingConfig = signingConfigs.release

postprocessing {
proguardFiles 'proguard-rules-production.pro'
}
}
}
dataBinding {
Expand All @@ -50,6 +79,9 @@ android {

xmlOutput file("lint-results.xml")
htmlOutput file("lint-results.html")

checkReleaseBuilds !isCi
abortOnError !isCi
}
packagingOptions {
exclude 'META-INF/*.kotlin_module'
Expand Down Expand Up @@ -98,9 +130,10 @@ dependencies {

implementation Dep.Stetho.stetho

releaseImplementation Dep.LeakCanary.leakCanary
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😇

debugImplementation Dep.LeakCanary.leakCanary
debugImplementation Dep.LeakCanary.leakCanaryFragment
stagingImplementation Dep.LeakCanary.leakCanaryNoOp
releaseImplementation Dep.LeakCanary.leakCanaryNoOp

implementation Dep.Firebase.core
implementation Dep.Firebase.auth
Expand All @@ -123,8 +156,8 @@ dependencies {

Dep.Hyperion.hyperionPlugins.forEach {
debugImplementation it
stagingImplementation it
}
}


apply plugin: 'com.google.gms.google-services'
31 changes: 31 additions & 0 deletions frontend/android/proguard-rules-production.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Remove LogCat Tree anyway
-assumenosideeffects class io.github.droidkaigi.confsched2019.App {
public *** enableLogCatLogging();
}

# Remove Android Log's methods
-assumenosideeffects class android.util.Log {
public static *** e(...);
public static *** d(...);
public static *** i(...);
public static *** v(...);
public static *** w(...);
public static *** wtf(...);
}

# Remove log methods which CrashlyticsTree doesn't support
-assumenosideeffects class timber.log.Timber {
public static *** d(...);
public static *** i(...);
public static *** v(...);
public static *** w(...);
public static *** wtf(...);
}

# Remove our log methods which are lower than ERROR
-assumenosideeffects class io.github.droidkaigi.confsched2019.timber.Timber {
*** info(...);
*** warn(...);
*** debug(...);
*** verbose(...);
}
59 changes: 45 additions & 14 deletions frontend/android/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,48 @@
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
## Extra

# Generate merge config list
-printconfiguration proguard-merged-config.txt

## General

# Do not remove annotations
-keepattributes *Annotation*
-keepattributes EnclosingMethod,Signature

# Replace source file attributes by SourceFile to reduce the size
# report system can de-obfuscate them
-renamesourcefileattribute SourceFile
# To see readable stacktraces
-keepattributes SourceFile,LineNumberTable

-dontwarn org.jetbrains.annotations.**

## Kotlin Coroutine stuff

# ServiceLoader-related stuff should be kept unless we use Dispatchers.Main
-keepnames class kotlinx.coroutines.internal.MainDispatcherFactory
-keepnames class kotlinx.coroutines.CoroutineExceptionHandler

# Most of volatile fields are updated with AFU and should not be mangled
-keepclassmembernames class kotlinx.** {
volatile <fields>;
}

# AFU stuff
-dontwarn kotlinx.atomicfu.**

## OkHttp

-dontwarn okhttp3.**
-dontwarn okio.**
-dontwarn javax.annotation.**
# A resource is loaded with a relative path so the package of this class must be preserved.
-keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase

## Ktor

-dontwarn com.typesafe.**
-dontwarn org.slf4j.**
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import io.github.droidkaigi.confsched2019.di.createAppComponent
import io.github.droidkaigi.confsched2019.ext.android.changedForever
import io.github.droidkaigi.confsched2019.system.actioncreator.SystemActionCreator
import io.github.droidkaigi.confsched2019.system.store.SystemStore
import timber.log.LogcatTree
import timber.log.Timber
import timber.log.Tree
import timber.log.debug
Expand Down Expand Up @@ -87,6 +88,11 @@ open class App : DaggerApplication() {
open fun setupLogHandler() {
Fabric.with(this, Crashlytics())
Timber.plant(CrashlyticsTree())
enableLogCatLogging()
}

fun enableLogCatLogging() {
Timber.plant(LogcatTree("droidkaigi"))
}

class CrashlyticsTree : Tree() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package io.github.droidkaigi.confsched2019

import com.facebook.stetho.Stetho
import com.squareup.leakcanary.LeakCanary
import timber.log.LogcatTree
import timber.log.Timber

class DebugApp : App() {
override fun onCreate() {
Expand All @@ -24,6 +22,6 @@ class DebugApp : App() {
}

override fun setupLogHandler() {
Timber.plant(LogcatTree("droidkaigi"))
enableLogCatLogging()
}
}
46 changes: 45 additions & 1 deletion frontendcomponent/androidcomponent/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ apply plugin: 'androidx.navigation.safeargs'

apply from: rootProject.file('gradle/android.gradle')

android.buildTypes.release {
consumerProguardFiles 'proguard-rules-navigation.pro'
}

dependencies {
api project(":model")
api project(":feature:notification")
Expand Down Expand Up @@ -37,9 +41,14 @@ dependencies {
androidTestImplementation Dep.Test.espressoCore
}
repositories {
if (!isCi) { maven { url "https://maven-central-asia.storage-download.googleapis.com/repos/central/data/" } }
if (!isCi) {
maven {
url "https://maven-central-asia.storage-download.googleapis.com/repos/central/data/"
}
}
mavenCentral()
}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
freeCompilerArgs = [
Expand All @@ -48,3 +57,38 @@ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
]
}
}

task buildNavigationProguard << {
def navigationGraphXml = project.file("src/main/res/navigation/navigation.xml")

// XmlParser didn't work so let me use the dirty hack
if (!navigationGraphXml.text.contains("xmlns:app=\"http://schemas.android.com/apk/res-auto\"")) {
throw new GradleScriptException("the namespace has been changed from app")
}

def fqdns = []

navigationGraphXml.eachLine {
def line = it.trim()

if (line.startsWith("android:name=\"")) {
def className = line.substring("android:name=\"".length(), line.lastIndexOf("\""))

if (className.contains(".")) {
fqdns << className
}
} else if (line.startsWith("app:argType=\"")) {
def className = line.substring("app:argType=\"".length(), line.lastIndexOf("\""))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝


if (className.contains(".")) {
fqdns << className
}
}
}

project.file("proguard-rules-navigation.pro").write(fqdns.sort().collect {
"-keepnames class $it"
}.join("\n"))
}

preBuild.dependsOn(buildNavigationProguard)
17 changes: 17 additions & 0 deletions frontendcomponent/androidcomponent/proguard-rules-navigation.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
-keepnames class com.google.android.gms.oss.licenses.OssLicensesMenuActivity
-keepnames class io.github.droidkaigi.confsched2019.about.ui.AboutFragment
-keepnames class io.github.droidkaigi.confsched2019.announcement.ui.AnnouncementFragment
-keepnames class io.github.droidkaigi.confsched2019.floormap.ui.FloorMapFragment
-keepnames class io.github.droidkaigi.confsched2019.model.SpeechSession
-keepnames class io.github.droidkaigi.confsched2019.session.ui.BottomSheetDaySessionsFragment
-keepnames class io.github.droidkaigi.confsched2019.session.ui.BottomSheetFavoriteSessionsFragment
-keepnames class io.github.droidkaigi.confsched2019.session.ui.SearchFragment
-keepnames class io.github.droidkaigi.confsched2019.session.ui.SessionDetailFragment
-keepnames class io.github.droidkaigi.confsched2019.session.ui.SessionPageFragment
-keepnames class io.github.droidkaigi.confsched2019.session.ui.SessionPagesFragment
-keepnames class io.github.droidkaigi.confsched2019.session.ui.SpeakerFragment
-keepnames class io.github.droidkaigi.confsched2019.session.ui.TabularFormSessionPagesFragment
-keepnames class io.github.droidkaigi.confsched2019.settings.ui.SettingsFragment
-keepnames class io.github.droidkaigi.confsched2019.sponsor.ui.SponsorFragment
-keepnames class io.github.droidkaigi.confsched2019.staff.ui.StaffSearchFragment
-keepnames class io.github.droidkaigi.confsched2019.survey.ui.SessionSurveyFragment
5 changes: 4 additions & 1 deletion gradle/android.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@ android {
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
consumerProguardFiles 'proguard-rules.pro'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

}
}
lintOptions {
def lintFile = file("${project.projectDir}/lint.xml")
if (lintFile.exists()) {
lintConfig lintFile
}

checkReleaseBuilds !isCi
abortOnError !isCi
}
}
kotlin.sourceSets.all {
Expand Down
15 changes: 1 addition & 14 deletions model/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,4 @@
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
-dontwarn io.github.droidkaigi.confsched2019.model.*$Creator