How do I get the apk of my IONIC application

2

Following the documentation , there should be two simple commands:

  • To include the platform: ionic platform ios android
  • To compile: ionic build android
  • However, I'm getting a lot of red error in the terminal, as shown below:

      

    Editedsofar:Ihavesolvedsomeoftheproblem,however,Ihavenewerrors:

    Followingthetips,IunzippedtheAndroidJDKinthe/usr/localfolder.

    Andincludesattheendofthefile~/.profilethelinesbelow:

    exportANDROID_HOME=/usr/local/android-sdk-linuxexportPATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools

    Then,Iranthecommand:source~/.profile

    AndthenIexecutedthecommandsbelow:

    echo>>/.profileecho"export ANDROID_HOME=/usr/local/android-sdk-linux" >> /.profile
        echo "export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools" >> /.profile
        . /.profile
    

    I followed a few steps through of this reference :

    And now you're seeing the following error:

    ➜  TesteApp  ionic build android          
    Running command: /var/www/html/apps/TesteApp/hooks/after_prepare/010_add_platform_class.js /var/www/html/apps/TesteApp
    add to body class: platform-android
    Running command: /var/www/html/apps/TesteApp/platforms/android/cordova/build 
    [Error: Please install Android target: "android-22".
    
    Hint: Open the SDK manager by running: 
    You will require:
    1. "SDK Platform" for android-22
    2. "Android SDK Platform-tools (latest)
    3. "Android SDK Build-tools" (latest)]
    ERROR building one of the platforms: Error: /var/www/html/apps/TesteApp/platforms/android/cordova/build: Command failed with exit code 2
    You may not have the required environment or OS to build this project
    Error: /var/www/html/apps/TesteApp/platforms/android/cordova/build: Command failed with exit code 2
        at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:139:23)
        at ChildProcess.emit (events.js:110:17)
        at maybeClose (child_process.js:1015:16)
        at Process.ChildProcess._handle.onexit (child_process.js:1087:5)
    

    I also ran the commands to install android-22:

    cordova platforms remove android
    cordova platforms add [email protected]
    

    And I received the following message:

    Adding android project...
    Creating Cordova project for the Android platform:
        Path: platforms/android
        Package: com.ionicframework.ionicgooglemap340659
        Name: TesteApp
        Activity: MainActivity
        Android target: android-22
    Copying template files...
    Android project created with [email protected]
    Running command: /var/www/html/apps/TesteApp/hooks/after_prepare/010_add_platform_class.js /var/www/html/apps/TesteApp
    add to body class: platform-android
    

    But when I run the command ionic build android , it still has the same error.

    What do I need to do to work without error, I already have Java JDK installed, need to do some more JAVA configuration?

        
    asked by anonymous 05.11.2015 / 13:22

    1 answer

    1

    I was using zsh instead of batch.

    I was able to solve by doing the following, I typed in the console:

    cd ~/
    
    ls -lha
    
    vi .zshrc
    

    I've included the following lines:

    export ANDROID_HOME="/usr/local/android-sdk-linux"
    export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/android-sdk-linux/tools:/usr/local/android-sdk-linux/platform-tools"
    

    I installed the Android SDK, and all Java JDK dependencies.

    In the terminal I just typed "android" and opened the Android SDK Manager:

    There, I selected only the items of the Android version that I needed and had it installed. Then I ran the command line:

     ionic build android
    

    And it worked! he created the apk in:

    /var/www/html/apps/TesteApp/platforms/android/build/outputs/apk/test-app.apk
    
        
    09.11.2015 / 13:23