/AppDevCon-KMM

sharing everything but UI

Primary LanguageKotlin

Getting Ready

Install latest Android Studio version (I’m using Flamingo 2022.2.1).

Install XCode, command line tools tools and Simulator.

Make sure your Kotlin Plugin has 1.8.x version.

Screenshot 2023-05-06 at 12 18 46

Make sure you have Ruby gem installed. gem list

Make sure you have Java JDK installed. java --version

To use the Android KMM Wizard Template, first you need to install a KMM plugin and restart AS.

Screenshot 2022-09-03 at 11 53 31

Clone the repository. Try opening the starter project in Android Studio (you need to choose the whole project, not only androidApp).

Sync the dependencies:

Screenshot 2022-09-03 at 13 26 34

Build and run the app.

Screenshot 2022-09-03 at 13 27 11

If the emulator starts, then everything is fine 👌

Screenshot 2022-09-03 at 13 29 33

If you run into a problem, it may be one of these:

If you have a Apple M1 Chip and the next command in terminal returns empty:

echo $LANG

Then in terminal:

open -e ~/.zshrc

And add this line to the opened file:

export LANG=en_US.UTF-8

After saving your .zshrc file, you must run next command:

source ~/.zshrc

If you’re running into Java JDK problem, do the following:

  1. /usr/libexec/java_home -V

Your output should be something like:

18 (arm64) "Oracle Corporation" - "OpenJDK 18" …/Library/Java/JavaVirtualMachines/openjdk-18/Contents/Home 1.8.0_292 (x86_64) "AdoptOpenJDK" - "AdoptOpenJDK 8" /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home

  1. brew install openjdk@17

sudo ln -sfn /opt/homebrew/opt/openjdk@11/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-17.jdk

  1. /usr/libexec/java_home -V

Your output should be something like:

18 (arm64) "Oracle Corporation" - "OpenJDK 18" /Users/lenastepanova/Library/Java/JavaVirtualMachines/openjdk-18/Contents/Home 17.0.7 (arm64) "Homebrew" - "OpenJDK 17.0.7" /opt/homebrew/Cellar/openjdk@17/17.0.7/libexec/openjdk.jdk/Contents/Home 11.0.17 (arm64) "Amazon.com Inc." - "Amazon Corretto 11" /Users/lenastepanova/Library/Java/JavaVirtualMachines/corretto-11.0.17/Contents/Home

  1. open ~/.zshrc

In zshrc add and save: export JAVA_HOME=$(/usr/libexec/java_home -v 17.0.7)

  1. export JAVA_HOME='/usr/libexec/java_home -v 17.0.7\'

  2. Also make sure you're using the correct Gradle JDK version in Android Studio

Screenshot 2023-05-06 at 12 12 08

If nothing still works, you can try checking out ADC-0-starter branch and setting up your java environment to Java 11.