romainguy / kotlin-explorer

Desktop tool to quickly explore disassembled Kotlin code.
Apache License 2.0
745 stars 21 forks source link

Hard to find ANDROID_HOME and KOTLIN_HOME; README.md could make this easier #13

Closed mhansen closed 4 months ago

mhansen commented 4 months ago

Hi, love the tool. Want my team to use it! I had a bit of trouble figuring out the environment variables to set when running it; was a bit of trial-and error, so I thought I'd log an experience report about how it was to get started, and we could discuss how to make it easier.

My guess is most developers will have android sdk and kotlinc from Android Studio, so we could make setup easier by saying where Android Studio stores these?

README says:

For $ANDROID_HOME, use the path to the root of the Android SDK (directory containing build-tools/, platform-tools/, etc.).

OK, this wasn't too hard to find, I think I knew already this was in ~/Library on my mac, but I still first tried ~/Library/Android before ~/Library/Androi/sdk worked. After a little trial and error, I got it.

For $KOTLIN_HOME, use the path to the root of your Kotlin installation. This directory should contain bin/kotlinc and lib/kotlin-stdlib-*.jar for instance.

OK this one stumped me! First I thought, I might not have a Kotlin installation? So I went to the Kotlin website looking for a release, but I couldn't easily find one: they just say to use IntelliJ or Android Studio: https://kotlinlang.org/docs/getting-started.html#install-kotlin (edit: later on, I was able to find CLI releases: https://kotlinlang.org/docs/command-line.html).

Ultimately I got it working by setting /Applications/Android\ Studio.app/Contents/plugins/Kotlin/kotlinc/ as my KOTLIN_HOME, but that gave me an error that kotlinc was not executable, so I had to chmod +x kotlinc /Applications/Android Studio.app/Contents/plugins/Kotlin/kotlinc/bin/kotlinc, then compiling in Kotlin Explorer worked.

Now, the presence of the hacky chmod makes me think I'm not doing this right. Probably I should have installed kotlin following the instructions at https://kotlinlang.org/docs/command-line.html instead. So maybe let's link there from the README?

Thanks, and I'm keen to help. I'll send a PR with some ideas.

romainguy commented 4 months ago

Installing Kotlin and the Android SDK separately from Studio is the preferred way.

mhansen commented 4 months ago

Just checking how to parse the 'separately'; do you mean install Kotlin from GitHub releases and Android SDK from Studio, or install both without using Studio? I'm guessing the first as you approved my PR.