1. ReactJS vs React-Native

  • ReactJS: JavaScript library to include and use in browser or NodeJS
  • React-Native: Framework to create application based on IO.js for multiple platforms (Android, iOS, Windows, Linux)

2. Download and install Android SDK in command-line

#download android sdk tar ball
cd /opt
sudo wget \
http://dl.google.com/android/android-sdk_r22.0.5-linux.tgz

#unpack it
sudo tar zxvf android-sdk_r22.0.5-linux.tgz

#make it available to everybody
sudo chmod -R 777 android-sdk-linux

3. Add environment to everywhere (.bashrc, /etc/profile, /etc/profile.d/…)

export ANDROID_HOME="/opt/android-sdk-linux"
export PATH="$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$PATH"

#load variables
source ~/.bashrc

4. Update Android SDK

sudo android update sdk --no-ui
#answer 'y' too all licence questions

#list all available updates
sudo android list sdk --all

#install specific updates (eg. Android Build Tools 23.0.1=14)
sudo android update sdk -u -a -t 14
#answer 'y' too all licence (or errors on build later)

5. Create Android directory, iOS directory

#go to project directory, and run:
react-native upgrade

6. Install libraries

sudo yum install gcc
sudo yum install gcc-c++
sudo yum install zlib.i686
sudo yum install libstdc++.i686

Install Oracle JDK, and set JAVA_HOME, JRE_HOME during building process (not necessary to remove Open JDK):
https://www.mkyong.com/java/how-to-install-oracle-jdk-8-on-centos/

7. Build Android .apk for the React-Native application

Rename the main .js file at project root to index.android.js if necessary. Follow the steps in the link below to self-sign and build release .apk file:
https://facebook.github.io/react-native/docs/signed-apk-android.html

Jenkins can’t find ~/.gradle/gradle.properties as Jenkins user home directory is different, so just remove:

if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
#and the closing curly bracket.

Put the path to keystore file, alias, password directly under android.signingConfigs.release as strings in doublequotes. Remember to put value for android.buildTypes.release.signingConfig to signingConfigs.release. These values are in some-project/android/app/build.gradle.

8. Publish .apk file to Google Play

Sign up to Google Play Developers:
https://play.google.com/apps/publish/signup/

Install gradle-play-publish Gradle plugin:
https://github.com/Triple-T/gradle-play-publisher

Publish to Google Play:

cd some-project/android
./gradlew tasks
./gradlew assembleRelease
./gradlew publishApkRelease
Advertisements