Skip to content

Instantly share code, notes, and snippets.

@jmfayard
jmfayard / Mercari-Jmfayard.adoc
Last active November 21, 2018 11:37
Mercari-Jmfayard
# Open a new android project in Android Studio
# From Android Studio, run the gradle task ":properties"
# From the command-line, run
$ ./gradlew :properties
# Check if you see this message
Starting a Gradle Daemon, 1 incompatible could not be reused
# To debug the problem run this
$ ps auxw | grep GradleDaemon
@jmfayard
jmfayard / Config.kt
Last active September 22, 2020 13:15
Gists Gradle-Kotlin-DSL
// buildSrc/src/main/kotlin/Config.kt
object Config {
const val ACTIVITY = "com.mautinoa.cardapp.MainActivity"
const val PACKAGE = "com.mautinoa.cardapp"
const val kotlinVersion = "1.2.71"
object SdkVersions {
val versionCode = 1
val compile = 28
val target = 26
@jmfayard
jmfayard / GooglePlay.kt
Created September 5, 2018 10:48
Custom task with gradle kotlin buildSrc
// buildSrc/src/main/java/GooglePlay.kt
import java.io.File
object GooglePlay {
@JvmStatic
fun updateWhatsNew(projectDir: File, version: String) {
val files: List<File> = listOf(
"src/production/play/en-US/listing/whatsnew-alpha",
@jmfayard
jmfayard / app-component-1.kt
Last active February 15, 2018 16:25
How To Not Use Dagger2
fun app() = AppComponent.instance
interface AppComponent {
val context: Context
val retrofit: Retrofit
val okHttpClient: OkHttpClient
val catRepository: CatRepository
val catService: CatService
val mainThreadScheduler: Scheduler
data class Producer<out T : Beverage>(
val beverage: T
) {
fun produce() : T = beverage
}
class Consumer<in T: Beverage> {
fun consume(t: T) = println("Thanks for the drink $t!")
}
// https://medium.com/@garnop/safe-concise-text-parsing-with-regex-destructuring-in-kotlin-b8f77ef1e30c
fun parsePhoneNumber(input: String): PhoneNumber {
val invalids = input.filterNot { it in '0'..'9' || it == '-' }
require(invalids.isEmpty()) { "Input $input has invalid characters : $invalids" }
val (areaCode, prefix, lineNumber) = input.split("-").map(String::toInt)
return PhoneNumber(areaCode, prefix, lineNumber)
}
fun main(args: Array<String>) {
lolcat() {
FILE="$HOME/.config/androidpackage.txt"
echo "Reading ${FILE}"
export PACKAGE=$( cat ${FILE} )
adb devices
echo pidcat $1 $2 $PACKAGE
sleep 2
pidcat $1 $2 $PACKAGE
}
@jmfayard
jmfayard / README.md
Last active May 14, 2025 11:20
Gradle Incompatible Daemons HOWTO

Add the printProperties task to your build.gradle

Run from both the command-line and intellij the gradle task printProperties

> Task :printProperties
Detecting what could cause incompatible gradle daemons
Run './gradlew printProperties' from the command-line and the same task Android studio
See https://docs.gradle.org/4.5/userguide/build_environment.html
See https://docs.gradle.org/4.5/userguide/gradle_daemon.html#daemon_faq