r/androiddev • Spotify • Apr 25 '20

Github Template for starting an Android app project with: 100% Kotlin + Github Actions + ktlint + Detekt + Gradle Kotlin DSL + buildSrc dependencies already set up.

https://github.com/cortinico/kotlin-android-template
211 Upvotes

22 comments sorted by

15

u/Zhuinden Apr 25 '20

I don't understand why there is a FactorialCalculator, a FactorialCalculatorImpl, and then a FactorialCalculatorProvider.calculator as part of public API, then you could have easily just provided class FactorialCalculator {} or object FactorialCalculator {} or maybe just a top-level function fun computeFactorial() with the right implementation.

I do not see the value of this interface, nor the "provider" that comes with it, from the library module. If the consumer wants to hide it in an interface, that's the consumer's job.

3

u/cortinico Spotify Apr 25 '20

Yeah you're totally right. Thanks for raising the issue.
I've accidentally left those classes/interfaces around, my bad.

As mentioned in the README, the focus of the template is around the static analysis/CI rather than the actually implementation. I'll go with `object FactorialCalculator {}` approach. Fix is here: https://github.com/cortinico/kotlin-android-template/pull/7

2

u/Zhuinden Apr 25 '20 edited Apr 25 '20

Nice, thanks 👍

14

u/SzyQ Apr 25 '20

You have minification disabled for release. I guess that is a miss over.

5

u/cortinico Spotify Apr 25 '20

> I guess that is a miss over.

Actually not. I've crafted the template around the output of the "Start a new Android project" output of Android Studio.

That has minification disabled for release as well.

Happy to discuss/understand what the community thinks about having it enabled by default or not.

-5

u/SzyQ Apr 25 '20

You never want to release an app to public without minification. There is nothing to discuss here.

2

u/smith7018 Apr 25 '20

You're not wrong but Google (mistakenly, imo) recommends that developers disable minification up until their first release. I don't have the documentation link but I read it a few days ago.

1

u/littledot5566 Apr 25 '20

So you're saying disable minify in debug mode, but enable it in release mode?

0

u/[deleted] Apr 25 '20

[deleted]

-2

u/SzyQ Apr 26 '20

You build debug builds for development where R8 should be disabled and you want minified release to check if there are no issues with config. There is no impact on dev speed.

4

u/smith7018 Apr 26 '20

I’m literally just informing you of Google’s recommendation. But go off.

However, when you create a new project using Android Studio, shrinking, obfuscation, and code optimization is not enabled by default. That’s because these compile-time optimizations increase the build time of your project and might introduce bugs if you do not sufficiently customize which code to keep.

So, it’s best to enable these compile-time tasks when building the final version of your app that you test prior to publishing.

https://developer.android.com/studio/build/shrink-code#enable

-5

u/SzyQ Apr 26 '20

Exactly, that’s why you enable it just for release. Imagine, how many ppl following your advise will forget to turn it on for release.

release { // Enables code shrinking, obfuscation, and optimization for only // your project's release build type. minifyEnabled true

3

u/smith7018 Apr 26 '20

It’s not my advice; it’s Google’s.

I’ve said that I disagree with it but the original point was that OP included Google’s standard new app. I added information as to why Google suggests turning off minification for new projects.

→ More replies (0)

2

u/igor-brishkoski Apr 25 '20

This is great, thanks for sharing.

One small note, using allprojects and subprojects will essentially couple all of your modules.

https://docs.gradle.org/current/userguide/multi_project_builds.html#sec:decoupled_projects

This is because these keywords are used in a build.gradle file, which defines a project. Often this is a “root project” that does nothing more than define common configuration, but as far as Gradle is concerned this root project is still a fully-fledged project, and by using allprojects that project is effectively coupled to all other projects.

1

u/cortinico Spotify Apr 25 '20

One small note, using allprojects and subprojects will essentially couple all of your modules.

I'm aware of the issue unfortunately. I've followed the detekt recommended configuration for multi project setup (here https://github.com/detekt/detekt#quick-links).

I'm currently evaluating switching to a Gradle precompiled script plugin (as detekt also did this week here: https://github.com/detekt/detekt/blob/master/buildSrc/src/main/kotlin/detekt.gradle.kts).

That will make slightly move the coupling point from the top level `build.gradle.kts` file to the `buildSrc` folder, but will ease a potential migration to a published Gradle plugin.

4

u/eygraber Apr 26 '20

Unless I'm reading the link from gradle wrong, it seems like using allprojects and subprojects from the root project is fine. Using them from a subproject causes coupling.

1

u/nacholicious is useless (no children, no background, no id, no style) Apr 26 '20

Yeah seems like it. "Avoid a subproject’s build script referencing other subprojects; preferring cross configuration from the root project."

1

u/taqmanplus Oct 19 '20

Great work. Thanks for sharing this. This is an amazing Android app project boilerplate to get us started with Android app development. However, some dependencies are creating problems in the running phase so do upgrade them out. And for the inspiration on the UI and functionalities, you can check out some amazing Android app templates that offer state of the art UI screens and powerful features.

1

u/cortinico Spotify Oct 20 '20

Thanks for your feedback

However, some dependencies are creating problems in the running phase so do upgrade them out.

Can you be more specific? Which dependencies are creating problems?

5

u/groovy261 Apr 25 '20

Nice I’ve been looking for this...

5

u/theapache64 Apr 25 '20

Cool. I've created another version here -> https://github.com/theapache64/jaba