DEV Community

Cover image for How to install electrode-native on Ubuntu to develop for Android
Jorge Alberto Díaz Orozco (Akiel)
Jorge Alberto Díaz Orozco (Akiel)

Posted on • Updated on

How to install electrode-native on Ubuntu to develop for Android

note: These instructions are outdated and might not be the correct way anymore. I'm no longer working with this technology and I'm not planning to do so in the near future, therefore this post won't be updated.

Hi @all. A few days ago I started trying to get electrode-native up and running and since I failed to do so following their getting started guide, I decided to make my own and share it with the developers that want to go the same path. This post will be only a series of the steps I followed to make it work in my environment which is Kubuntu 17.10 OS. Here is all that I did.

Install gnome-terminal

For some reason, electrode-native depends on gnome-terminal so do apt-get install gnome-terminal if you are not running a Gnome based system.

Install git

apt-get install git

Install Java Development Kit

apt-get install openjdk-8-jdk

Get the Android SDK and install

  1. Download the latest version of AndroidStudio and install SDK
  2. Export variables ANDROID_HOME and ANDROID_SDK pointing to the Android SDK directory
  3. Add tools and platform-tools folders to PATH
  4. Download Android system image to run your application or just use your Android phone to test

Install Gradle

  1. Download the latest Gradle release
  2. Unzip somewhere in your system
mkdir /opt/gradle
unzip -d /opt/gradle
  1. Export GRADLE_HOME to the folder you extracted
  2. Add GRADLE_HOME/bin to PATH
  3. note: electrode will probably download its own Gradle version anyway

Install nodejs and npm

curl -sL | sudo -E bash -
sudo apt-get install -y nodejs
sudo apt-get install -y npm

Install electrode-native

  1. Install electrode-native from npm npm install -g electrode-native
  2. Install yarn npm install -g yarn
  3. Run ern for the first time to complete installation
  4. Installing react-native tools might be needed npm install -g create-react-native-app

Start a miniapp

To start building your first miniapp run ern create-miniapp MyGreatApp And after it finishes run ern run-android to start the application. You can run either on emulator or physical device.

Enable reload

Are you working with your device connected to your computer?

  1. Ensure adb access. When you run adb devices your device should show in the list like this :
~$ adb devices
List of devices attached
b91feec4        device

If you can't see your device in the list or it says anything but device try disconnecting and connecting again and checking if you have USB debugging active.

  1. Run a tunnel from localhost to the device like this: adb reverse tcp:8081 tcp:8081


Gradle fails

An error occurred: Command failed: ./gradlew lib:uploadArchives
Exception in thread "main" java.lang.RuntimeException: error in opening zip file
        at org.gradle.wrapper.ExclusiveFileAccessManager.access(
        at org.gradle.wrapper.Install.createDist(
        at org.gradle.wrapper.WrapperExecutor.execute(
        at org.gradle.wrapper.GradleWrapperMain.main(
Caused by: error in opening zip file
        at Method)
        at org.gradle.wrapper.Install.unzip(
        at org.gradle.wrapper.Install.access$400(
        at org.gradle.wrapper.Install$
        at org.gradle.wrapper.Install$
        at org.gradle.wrapper.ExclusiveFileAccessManager.access(
        ... 3 more

Solution: Probably Gradle did not download correctly. Delete /home/$USER/.gradle/wrapper/dists/gradle-4.1-all and try running the project again.

Any other Gradle-related problem?

Try deleting your Gradle cache (usually on /home/$USER/.gradle) and trying to run again

I want to thank Benoit Lemaire for helping me when I was stuck having issues with Gradle.
Thank you very much for reading. I hope you enjoyed this post and find helpful.

Top comments (3)

santosh2606 profile image
Santosh Kumar • Edited

When I am executing the ern run-android command at ubuntu 18.04, getting following error:

✖ An error occurred: Command failed: ./gradlew lib:uploadArchives

Early help will be much appreciated

jadolg profile image
Jorge Alberto Díaz Orozco (Akiel)

I have not used this technology for more than one year already. One year ago it was not ready and it was barely usable. I do not recommend this technology at all. I'm sorry I can't be of much help here.

santosh2606 profile image
Santosh Kumar

Hi Akiel, Above raised issue has been resolved and steps are as follows to resolve:

  1. open the terminal and type sudo su to become the root user
  2. Install the gradle
  3. Edit the ~/.bashrc and add the followings

export ANDROID_SDK_ROOT=/home/$USER/Android/Sdk # comment you can also change the $USER with your username or can set the path where you have installed Android
export PATH=$PATH:$ANDROID_SDK_ROOT/emulator
export PATH=$PATH:$ANDROID_SDK_ROOT/tools/bin
export PATH=$PATH:$ANDROID_SDK_ROOT/platform-tools
export PATH=$PATH:$ANDROID_SDK_ROOT/build-tools
also option in case still getting error add following line as well
GRADLE_HOME=/opt/gradle # comment enter the respective path as you have installed
export PATH=$PATH:$GRADLE_HOME/gradle5.5

  1. Save the file
  2. Reboot the system
  3. again login with root user into the terminal and execute following command once after connecting the mobile device $ adb devices
  4. now run the ern run-android command