react-native-community/docker-android

Build failing: Fix for Buck and JAVA_HOME and emulator

jpotts18 opened this issue ยท 2 comments

This issue is being left as a travelogue for future people who may pass this way.

Here is the commit I needed to make to get it working again. Right now I don't have any intention to create a PR, but I'd be happy to or someone else can contribute them.

Bumped NodeJS to version 18

  • Update version to 18 โœ…
  • I am a bit curious why node@18 is not set as the default yet in this repo since it is the current LTS ๐Ÿค”

JAVA_HOME variable not correctly set, so I symlinked it using this command โœ…

# Reset JAVA_HOME var
RUN ln -s $(dirname -- $(dirname -- $(readlink -f /usr/bin/java))) /usr/lib/jvm/default-java
ENV JAVA_HOME=/usr/lib/jvm/default-java

Emulator not found as by sdkmanager Warning: Failed to find package 'emulator'.

Fix: Made an image that completed just after the android install and interactively ran sdkmanager --list on a container. This is where I saw that and emulator was no longer available to sdkmanager.

Note: I personally don't need the emulator in my CI/CD pipeline yet so this might be future oversight but seems like since the emulator has been dropped from sdkmanager it should probably be installed differently now. Anyways that was now fixed for my use case โœ…

Ran into issue with sdkmanager "ndk;21.4.7075529" not being found

This was the same problem but it looks like buck was introduced as a build tool. I think this should have probably been left as an optional configuration like some kind of ARG USE_BUCK=TRUE but maybe the maintainers disagree and I don't really know everything about react-native. I didn't need buck in my system so removed its installation and moved back to using the normal version of the NDK.

  • Don't install buck
  • Didn't need to do any symlinking to point clang to a different version
  • Cleaned up a lot of NDK_VERSION_BUCK and NDK_VERSION_GRADLE to just be back to NDK_VERSION

Thanks for the clarification @jpotts18. I'm closing as this is for future reference, but thansk for sharing.

I am a bit curious why node@18 is not set as the default yet in this repo since it is the current LTS ๐Ÿค”

This was discussed in depth here: #187 (comment)

JAVA_HOME variable not correctly set, so I symlinked it using this command โœ…

What do you mean with "not correctly set". The current image is used to build RN on github.com/facebook/react-native so I'm unsure what's your root issue.
Specifically JAVA_HOME is already set to:

ENV JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64

which is the correct one.

Don't install buck

Again this is not an option as this docker image is used to build github.com/facebook/react-native where we need to run Buck tests, therefore we need buck installed.

@cortinico thanks for helping me out with this. I appreciate your thoughtful response and links so that I can learn more. ๐Ÿ‘