V
V
Vitaly2017-07-07 16:34:32
Angular
Vitaly, 2017-07-07 16:34:32

How to build an application on Ionic 3?

Greetings. I took up the development of Ionic 3, I can not build the application. Doesn't run on device - apk is created unreadable. On the emulator, it was possible to launch android in the release, but after the loading window, an empty white screen remains, and in the debug it did not start at all. iOS does not compile, shows an error.

ionic cordova run android
$ ionic cordova run android
Running app-scripts build: --address 0.0.0.0 --port 8100 --p 8100 --livereload-port 35729 --r 35729 --iscordovaserve --externalIpRequired --nobrowser

[14:07:26]  build dev started ... 
<blockquote>...</blockquote>
BUILD SUCCESSFUL

Total time: 2.114 secs
Built the following apk(s): 
  /Users/vitali/Desktop/projects/test/platforms/android/build/outputs/apk/android-debug.apk

ANDROID_HOME=/Users/vitali/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home
No target specified, deploying to device 'ACE215CFDE5A'.

Skipping build...
Built the following apk(s): 
  /Users/vitali/Desktop/projects/test/platforms/android/build/outputs/apk/android-debug.apk

Using apk: /Users/vitali/Desktop/projects/test/platforms/android/build/outputs/apk/android-debug.apk

Package name: io.ionic.starter
Error: Failed to install apk to device: [  1%] /data/local/tmp/android-debug.apk
<blockquote>...</blockquote>
[100%] /data/local/tmp/android-debug.apk
/Users/vitali/Desktop/projects/test/platforms/android/build/outputs/apk/android-debug.apk: 1 file pushed. 2.3 MB/s (4078111 bytes in 1.659s)
  pkg: /data/local/tmp/android-debug.apk
Failure [INSTALL_FAILED_INSUFFICIENT_STORAGE]
rm failed for -f, No such file or directory


[ERROR] Cordova encountered an error.
        You may get more insight by running the Cordova command above directly.
        
[ERROR] An error occurred while running cordova run android (exit code 1).

ionic cordova run android --prod --release
$ ionic cordova run android --prod --release
Running app-scripts build: --prod --address 0.0.0.0 --port 8100 --p 8100 --livereload-port 35729 --r 35729 --iscordovaserve --externalIpRequired --nobrowser

[14:09:05]  build prod started ... 
<blockquote>...</blockquote>
BUILD SUCCESSFUL

Total time: 2.893 secs
Built the following apk(s): 
  /Users/vitali/Desktop/projects/test/platforms/android/build/outputs/apk/android-release-unsigned.apk

ANDROID_HOME=/Users/vitali/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home
No target specified, deploying to device 'ACE215CFDE5A'.

Skipping build...

Built the following apk(s): 
  /Users/vitali/Desktop/projects/test/platforms/android/build/outputs/apk/android-release-unsigned.apk

Using apk: /Users/vitali/Desktop/projects/test/platforms/android/build/outputs/apk/android-release-unsigned.apk

Package name: io.ionic.starter
Error: Failed to install apk to device: [  2%] /data/local/tmp/android-release-unsigned.apk
<blockquote>...</blockquote>
[100%] /data/local/tmp/android-release-unsigned.apk
/Users/vitali/Desktop/projects/test/platforms/android/build/outputs/apk/android-release-unsigned.apk: 1 file pushed. 4.5 MB/s (2187312 bytes in 0.460s)
  pkg: /data/local/tmp/android-release-unsigned.apk
Failure [INSTALL_FAILED_OLDER_SDK]
rm failed for -f, No such file or directory


[ERROR] Cordova encountered an error.
        You may get more insight by running the Cordova command above directly.
        
[ERROR] An error occurred while running cordova run android --release (exit code
        1).

ionic cordova run ios
$ ionic cordova run ios
Running app-scripts build: --address 0.0.0.0 --port 8100 --p 8100 --livereload-port 35729 --r 35729 --iscordovaserve --externalIpRequired --nobrowser

[16:27:21]  build dev started ... 
<blockquote>...</blockquote>
** BUILD SUCCEEDED **

Error: Cannot read property 'replace' of undefined

[ERROR] Cordova encountered an error.
        You may get more insight by running the Cordova command above directly.
        
[ERROR] An error occurred while running cordova run ios (exit code 1).

Answer the question

In order to leave comments, you need to log in

3 answer(s)
O
ozknemoy, 2017-07-08
@ozknemoy

I will assume that the release flag is superfluous. I normally built ionic run android --prod
(for release, you need to create a release-signing.properties file in the platforms/android/ project folder)

F
Fayozzhon Berdiev, 2019-10-11
@CybernatiC

ionic cordova build android
ionic cordova build ios

D
Dmitry Baibukhtin, 2020-03-16
@PiloTeZ

My script for creating a release build. Run on Windows in the project folder release.sh.
Before using, substitute your data.
Do not store this file in the git, as it contains secret data. You can cut them out and enter each time manually.
If strange problems appear after the build, try executing the ionic repair.

#!/usr/bin/env bash

# Если не работает, проверь слэши и прочее. Зависит от консоли, в которой запускаешь. Например гитовая требует слэши /, а не \
# Билд приложения
ionic cordova build android --prod --release &&
# Переход к собранному приложению
cd platforms/android/app/build/outputs/apk/release &&
# Подпись приложения с помощью личного секретного ключа
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -storepass ТВОЙ_ПАРОЛЬ_ОТ_КЛЮЧА -keypass ТВОЙ_ВТОРОЙ_ПАРОЛЬ_ОТ_КЛЮЧА -keystore C:/ТВОЙ_ПУТЬ_К_КЛЮЧУ/НАЗВАНИЕ_КЛЮЧА.jks app-release-unsigned.apk key &&
# Удаление прошлой сборки для релиза
rm -f НАЗВАНИЕ_ПРИЛОЖЕНИЯ.apk &&
# Оптимизация APK, обязательно перед загрузкой в play market
zipalign -v 4 app-release-unsigned.apk НАЗВАНИЕ_ПРИЛОЖЕНИЯ.apk

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question