Compilar ionic

Primero debo asegurarme de tener instalado el java 1.8 que es la mas estable y la que usa ionic

despues debo ejecutar esto para configurar mi java por defecto

sudo update-alternatives --config java
sudo update-alternatives --config javac

En ubuntu configurar las variables de entorno

export ANDROID_SDK_ROOT=/home/lmayta/Android/Sdk
export ANDROID_HOME=/home/lmayta/Android/Sdk
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre

Instalar gradle

Por defecto ubuntu me instala el gradle 4.4, tuve que instalar sdkman para poder instalar la ultima version

https://sdkman.io/install

https://docs.gradle.org/current/userguide/installation.html

Hay que fijarse en la documentacion oficial de ionic paa firmar en Ubuntu, porque se hace por consola ya que por android studio genera error

Generando un Apk

ionic cordova platform add android   
ionic cordova resources android --force
ionic cordova build android --release

https://ionicframework.com/docs/deployment/play-store

Con estos comandos pude generar un apk firmado

ionic cordova build android --release 
ionic cordova platform rm android 
ionic cordova platform add android 

keytool -genkey -v -keystore willymartinez.keystore -alias willymartinez -keyalg RSA -keysize 2048 -validity 10000  


jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore willymartinez.keystore /var/www/html/ionic/WillyMartinez/platforms/android/app/build/outputs/apk/release/app-release-unsigned.apk willymartinez

zipalign -v 4 /var/www/html/ionic/WillyMartinez/platforms/android/app/build/outputs/apk/release/app-release-unsigned.apk /var/www/html/ionic/WillyMartinez/platforms/android/app/build/outputs/apk/release/app-release-signed.apk

En la carpeta resource tengo que colocar los dominios de los servicios que estoy consumiendo

network_security_config.xml

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <domain-config cleartextTrafficPermitted="true">
        <domain includeSubdomains="true">localhost</domain>
        <domain includeSubdomains="true">willymartinezsanchez.com</domain>
        <domain includeSubdomains="true">69.73.182.198</domain>
    </domain-config>
</network-security-config>