Hi, I've just started to play around with the kamp...
# touchlab-tools
u
Hi, I've just started to play around with the kampkit sample app on my Mac. Android works like a charm. However, on iOS I can't seem to build the app. I always get the dreaded "To use the “java” command-line tool you need to install a JDK." dialog. However, I have java and the JDK installed on my system, although not in the default location. I'm using
sdkman
to manage java versions, current version resides at
/Users/ubuntudroid/.sdkman/candidates/java/current
. I guess I somehow need to tell xcode to use that. JAVA_HOME environment variable is set to the abovementioned value, but xcode seems not to make use of it (I guess it only looks in the default . Any ideas?
m
What’s your Java version?
java -version
KaMP Kit docs say ‘JVM 8’
if you get openjdk 1.8.0 you should be fine
u
Copy code
openjdk version "11.0.6" 2020-01-14
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.6+10)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.6+10, mixed mode)
but I don't think it's being picked up at all by xcode
m
yep, definitely try a 1.8.0 openjdk
u
kk, will try
Now I have
Copy code
openjdk version "1.8.0_242"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_242-b08)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.242-b08, mixed mode)
Unfortunately I still get the popup. 😞
I guess Xcode is trying to execute the gradle task
:shared:syncFramework
and then gradle (running in the xcode environment) does not find my java environment. 🤔
m
hmm, maybe it chooses the wrong java version
when you set JAVA_HOME: did you logout & login your user on your Mac?
that might do the trick (because then freshly started apps get the updated env variables)
If you can, try to find out which java command Xcode runs
which ‘java’ binary exactly
it seems on your machine it finds a JRE java binary instead of the JDK one
maybe there is the old java binary from Apple installed
u
thanks for your outstanding support on this matter 🙏 - I'll restart my Mac (to be on the safe side) and see whether this resolves things. Then I'll try out the other things you've suggested.
m
I usually fix these things by uninstalling all JREs and JDKs on my machine and just installing openjdk 1.8.0 with homebrew 😉
glad to help - hope it works 🙂
u
haha, I feared that would be the answer 😅
Hm, okay, restarting didn't work - trying your other recommendations now
Ha, I've managed to get things up and running by hardcoding JAVACMD in gradlew - it seems that xcode indeed launches the process without properly setting proper environment variables.
Trying to find a better solution for this while keeping on using sdkman. Will post my findings here if I am successful.
m
I would suggest you run the ‘env’ command somewhere in your Xcode build process
maybe as a ‘run script’
that way you can find out if JAVA_HOME is set correctly in Xcode - or at all 😉
u
Will try that next, right now I am messing with the shared.podspec.json - I'm not an iOS dev so it is taking a bit longer than it probably should. 😉
m
good luck
🙏 1
🙂
k
Tracking issue. We’ll take a look at it soon and see if we have alternative solutions
u
Awesome, thanks a lot! 🙇
Okay, what works for me is adding
export JAVA_HOME=/Users/ubuntudroid/.sdkman/candidates/java/current
to
shared.podspec
right before the
gradlew
call. However, obviously this doesn't work well when being built on different machines...
A bit better - but still flawed: you can also set JAVA_HOME in the xcode build settings as a user-defined Setting. But as the project.pbxproj is checked into VCS as well, that's still not good when working on different machines.
@kevcar I still haven't succeeded in finding a good solution for this. Did you? And could you post the link to the tracking issue here? 🙏