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
- Download the latest version of AndroidStudio and install SDK
- Export variables ANDROID_HOME and ANDROID_SDK pointing to the Android SDK directory
- Add tools and platform-tools folders to PATH
- Download Android system image to run your application or just use your Android phone to test
Install Gradle
- Download the latest Gradle release
- Unzip somewhere in your system
mkdir /opt/gradle
unzip -d /opt/gradle gradle-4.6-bin.zip
- Export GRADLE_HOME to the folder you extracted
- Add GRADLE_HOME/bin to PATH
- note: electrode will probably download its own Gradle version anyway
Install nodejs and npm
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
- Install electrode-native from npm
npm install -g electrode-native
- Install yarn
npm install -g yarn
- Run ern for the first time to complete installation
- 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?
- 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.
- 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 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)
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
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.
Hi Akiel, Above raised issue has been resolved and steps are as follows to resolve:
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
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