Hey there! I think this is stupidity and waste of resources to install whole Android Studio. So here I will explain how to in minutes generate installable apk without Android Studio.
I use GaliumOS that based on Ubuntu 16.04
Installing Java JDK
Go to oracle official website and install 8th version of Java Development Kit for you OS.
If you are using Fedora/Ubuntu you can easily type sudo apt-get install default-jdk
in a Terminal.
To ensure you have properly installed jdk use
java -version
.
If you still got nothing then you should set enviroment variables to do it https://docs.oracle.com/javase/tutorial/essential/environment/paths.html
Installing Android SDK tools
For this go to in the end of official page (Command line tools only) and download right version of sdk for your OS. Then just unzip it whenever you want and set environment variables to use android tools from any part of your system. To do it follow this steps (ubuntu/fedora):
- Type `nano ~/.bashrc’
- Add following lines to the end of the file:
export ANDROID_HOME="/usr/lib/android-sdk/"
export PATH="${PATH}:${ANDROID_HOME}tools/:${ANDROID_HOME}platform-tools/"
Don’t forget to edit your paths! - Reopen terminal window
- Go to Android HOME. Type
cd /usr/lib/android-sdk/
and got to toolscd toos
- Type
./sdkmanager "build-tools;19.1.0"
, to install build tools - Type
./sdkmanager --licenses
, to automatically accept all SDK liscenses
Test it - type
android
Generating android build
Follow steps and be carefull to use your path not mine =)
- Go to you ionic project
cd ~/Documents/myApp
Probably you will need to connect as super user ->sudo -i
- Type
ionic cordova build android --prod --release
, this will generate unsigned apk
wait untill it’s successfully completing (it should generate unsigned .apk)
relative path to itplatforms/android/app/build/outputs/apk/release/app-release-unsigned.apk
- Type
keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000
, this will generate keystore file - Type
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.jks platforms/android/app/build/outputs/apk/release/app-release-unsigned.apk my-alias
, this will sign unsigned apk. - Type
cd ~/Android/build-tools/19.1.0
- Type
./zipalign -v 4 /home/chrx/Documents/myApp/platforms/android/app/build/outputs/apk/release/app-release-unsigned.apk ~/HelloWorld.apk
Conclusion
That’s it! You have HelloWorld.apk in your hove directory.