How to install electrode-native on Ubuntu to develop for Android
Tags: electrode, electrodenative, react, ubuntu
Published: 2018-03-21 17:00:03

---
title: How to install electrode-native on Ubuntu to develop for Android
published: true
description: Installing electrode-native and running a sample electrode-native miniapp
tags: electrode, electrode-native, react, Ubuntu
cover_image: https://thepracticaldev.s3.amazonaws.com/i/klpluu81hw44q7d1g6wq.jpeg
---

**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](http://www.electrode.io/site/native.html) 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](https://developer.android.com/studio/index.html) 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](https://gradle.org/releases) release
2. Unzip somewhere in your system
```bash
mkdir /opt/gradle
unzip -d /opt/gradle gradle-4.6-bin.zip
```
3. Export **GRADLE_HOME** to the folder you extracted
4. Add **GRADLE_HOME/bin** to **PATH**
* **note:** electrode will probably download its own Gradle version anyway

## Install nodejs and npm
```bash
curl -sL https://deb.nodesource.com/setup_8.x | 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.

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

## Troubles?
### Gradle fails 
```
An error occurred: Command failed: ./gradlew lib:uploadArchives
Exception in thread "main" java.lang.RuntimeException: java.util.zip.ZipException: error in opening zip file
        at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:78)
        at org.gradle.wrapper.Install.createDist(Install.java:44)
        at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:126)
        at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:58)
Caused by: java.util.zip.ZipException: error in opening zip file
        at java.util.zip.ZipFile.open(Native Method)
        at java.util.zip.ZipFile.<init>(ZipFile.java:225)
        at java.util.zip.ZipFile.<init>(ZipFile.java:155)
        at java.util.zip.ZipFile.<init>(ZipFile.java:169)
        at org.gradle.wrapper.Install.unzip(Install.java:157)
        at org.gradle.wrapper.Install.access$400(Install.java:26)
        at org.gradle.wrapper.Install$1.call(Install.java:67)
        at org.gradle.wrapper.Install$1.call(Install.java:44)
        at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)
        ... 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](https://github.com/belemaire) 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.