MediumHow to Start Ionic Dev Env In Ubuntu | by Wu Jiaojiao & Li Yuansan | Medium
Sitemap

How to Start Ionic Dev Env In Ubuntu

2 min readJun 27, 2021

--

Those are handy steps if you want to start Ionic development environment in Ubantu:

sudo apt install -y nodejs
sudo apt install -y npm
sudo apt-get install -y openjdk-8-jdk
sudo apt install -y android-sdk
sudo apt-get install -y android-sdk-platform-tools
sudo apt-get install -y android-sdk-build-tools
sudo npm install -g @ionic/cli
sudo npm install -g cordova-res
#to use cordova
sudo npm i -g cordova
#ionic
ionic start <app name>
#add cordova support
ionic integrations enable cordova
#to use ios
ionic cordova platform add ios
#to use android
ionic cordova platform add android
#add path
export ANDROID_HOME=/usr/lib/android-sdk
export ANDROID_SDK_ROOT=/usr/lib/android-sdk/Sdk
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/
export PATH="${PATH}:${ANDROID_HOME}tools/:${ANDROID_HOME}platform-tools/"
#make sure the right jdk is selected if you installed multiple
sudo update-alternatives --config javac
sudo update-alternatives --config java
#install gradle
wget https://services.gradle.org/distributions/gradle-6.4.1-bin.zip -P /tmp
sudo unzip -d /opt/gradle /tmp/gradle-*.zip
export GRADLE_HOME=/opt/gradle/gradle-6.4.1
export PATH=${GRADLE_HOME}/bin:${PATH}
wget https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip -P /tmp
sudo unzip -d ${ANDROID_HOME}/Sdk/ /tmp/sdk-tools-linux-*.zip
export PATH=${ANDROID_HOME}/Sdk/tools:${ANDROID_HOME}/Sdk/tools/bin:$PATH
chmod 777 $ANDROID_HOME -R

Get Wu Jiaojiao & Li Yuansan’s stories in your inbox

Join Medium for free to get updates from this writer.

To add android emulator:

android list target
android create avd --name testAVD -t android-29

To integrate with google firebase:

npm install firebase angularfire2 --save
ionic generate component google-login
npm install --save @ionic-native/google-plus
ionic cordova plugin add cordova-plugin-googleplus --variable REVISED_CLIENT_ID=<GoogleService-Info.plist>
npm i firebase@7.24.0 angularfire2 --save

To start a quick testing environment:

ionic serve --address 0.0.0.0
(the 0.0.0.0 allows any address to access, which is useful if you run ubantu in oracle virtual server, and you want to access outside of ubantu)

To see the result, open below in the browser, and you will see it is up and running:

http://127.0.0.1:8100/home

If you want to run on your own device or emulate

$ionic cordova run android --device
$ionic cordova emulate android

How to create product release aab file and sign the package?

$ionic cordova build --release android//navigate to folder /platforms/android
$echo "sdk.dir=/usr/lib/android-sdk/Sdk" >> local.properties
$./gradlew bundle
//navigate to folder /platforms/android/app/build/outputs/bundle/release
$keytool -genkey -v -keystore sr-release-key.jks -alias sr-release -keyalg RSA -keysize 2048 -validity 10000
$jarsigner -keystore sr-release-key.jks ./app-release.aab sr-release

--

--