Following the documentation , there should be two simple commands:
ionic platform ios android
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/local
folder.
Andincludesattheendofthefile~/.profile
thelinesbelow:
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?