Skip to content
This repository has been archived by the owner on Dec 7, 2019. It is now read-only.

Fallback to ANDROID_SDK_ROOT if ANDROID_HOME is not defined #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
10 changes: 9 additions & 1 deletion android/src/main/kotlin/com/gojuno/commander/android/Adb.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,15 @@ import java.util.concurrent.TimeUnit
import java.util.concurrent.TimeUnit.MINUTES
import java.util.concurrent.TimeUnit.SECONDS

val androidHome: String by lazy { requireNotNull(System.getenv("ANDROID_HOME")) { "Please specify ANDROID_HOME env variable" } }
val androidHome: String by lazy {
// Resolution order is from https://developer.android.com/studio/command-line/variables#envar
val androidHome = System.getenv("ANDROID_HOME")
if (androidHome != null) {
return@lazy androidHome
}
val androidSdkRoot = System.getenv("ANDROID_SDK_ROOT")
requireNotNull(androidSdkRoot) { "Please specify ANDROID_SDK_ROOT env variable" }
}
val adb: String by lazy { "$androidHome${File.pathSeparator}platform-tools${File.pathSeparator}adb" }
private val buildTools: String? by lazy {
File(androidHome, "build-tools")
Expand Down