Unable to build Android using ionic - android

I am trying to setup Ionic framework for developing android apps on my mac but I am having some problems in building android apps.
I have followed following procedure for installing ionic :
Run: "sudo npm install -g cordova"
Run: "sudo npm install -g ionic"
Run: “android” then install the following packages
Tools: Andoird SDK Tools, Android SDK Platform-tools, Android SDK Build-tools
Android 4.4.2 (API 19)
Extras: Android Support Library
My .bash file is like this :
export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=${JAVA_HOME}/bin:$PATH
export PATH=${PATH}:~/Library/Android/sdk/tools:~/Library/Android/sdk/platform-tools
This is the error I am getting while building android app :
You have been opted out of telemetry. To change this, run: cordova telemetry on.
Running command: /Users/coderahul/sampleIonicApp/hooks/after_prepare/010_add_platform_class.js /Users/coderahul/sampleIonicApp
add to body class: platform-android
ANDROID_HOME=/Users/coderahul/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> failed to find target with hash string 'android-23' in: /Users/coderahul/Library/Android/sdk
* Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 2.299 secs
Error: /Users/coderahul/sampleIonicApp/platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> failed to find target with hash string 'android-23' in: /Users/coderahul/Library/Android/sdk
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Please install Android target: "android-23".
Hint: Open the SDK manager by running: /Users/coderahul/Library/Android/sdk/tools/android
You will require:
1. "SDK Platform" for android-23
2. "Android SDK Platform-tools (latest)
3. "Android SDK Build-tools" (latest)

This happened to me just type this in your terminal "/Users/coderahul/Library/Android/sdk/tools/android" and proceed with the steps to download the sdk for android-23.
This happens because your device is using the higher version of OS than the sdk version

Related

No installed build tools found. Install the Android build tools version 19.1.0 or higher. Please add it to build.gradle

I'm Trying to generate android project from ionic in my Ubuntu 20.04.2 LTS in Webstorm with this command:
sudo ionic cordova build android
I have defined the following variables in the .bashrc file:
export ANDROID_HOME=/home/matteo/Android/Sdk
export ANDROID_SDK_ROOT=/home/matteo/Android/Sdk
export PATH=${PATH}:/home/matteo/Android/Sdk/tools
export PATH=${PATH}:/home/matteo/Android/Sdk/platform-tools
export ANDROID_AVD_HOME=~/.android/avd
and i ran the command
source ~/.bashrc
But I still have the following errors:
Preparing Firebase on Android
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=undefined (DEPRECATED)
Using Android SDK: /usr/lib/android-sdk
Subproject Path: CordovaLib
Subproject Path: app
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
-----------
* Where:
Script '..../platforms/android/CordovaLib/cordova.gradle' line: 64
* What went wrong:
A problem occurred evaluating project ':app'.
> No installed build tools found. Install the Android build tools version 19.1.0 or higher.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
==============================================================================
2: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':app'.
> compileSdkVersion is not specified. Please add it to build.gradle
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
==============================================================================
this is my SDK situation:
If i run this command:
cordova requirements android --verbose
this is the result:
Platform API successfully found in: .../platforms/android/cordova/Api.js
Requirements check results for android:
Java JDK: installed 1.8.0
Android SDK: installed true
Android target: installed android-30,android-29,android-27,android-22
Gradle: installed /usr/share/gradle/bin/gradle

react-native run-android Starting JS server... Building and installing the app on the device (cd android && ./gradlew installDebug

After
react-native init Project
i do :
cd Project and
react-native run-android
my version is : nodejs v6.9.5
emulateur genymotion api 23
I have this error :
Starting JS server...
Building and installing the app on the device (cd android && ./gradlew installDebug...
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> failed to find Build Tools revision 23.0.1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 4.309 secs
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html
Install Build Tools revision 23.0.1 on SDK

Ionic app build issue

I am new to ionic. I have developed sample application ionic.
When I try to execute below command it gives gradle error.
$ ionic build android
Below is the build error:
Error: /home/myapp/platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred starting process 'Gradle build daemon'
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Gradle version is 3.3
Android SDK and Android Studio located in /usr/local/ folder
You will either have to move it to your home directory (that involves reinstall).
Or run ionic build commands with sudo
sudo ionic build android
You could technically change permissions of the specific sdk and studio folders but it is not advisable especially in /usr directory.

Is Cordova for Android broken on the Mac?

I'm trying to get started with Cordova (on Mac Sierra): https://cordova.apache.org/#getstarted
I already have Android Studio (Version 2.2.2) installed and I'm using Android SDK 24.
So I follow the Getting Started instructions...
npm install -g cordova
cordova --version
I have Cordova 6.4.0.
cordova create hello
cd hello
cordova platform add android
This should just work, but I get the following error:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> You have not accepted the license agreements of the following SDK components:
[Android SDK Platform 24].
Before building your project, you need to accept the license agreements and complete the installation of the missing components using the Android Studio SDK Manager.
Alternatively, to learn how to transfer the license agreements from one workstation to another, go to http://d.android.com/r/studio-ui/export-licenses.html
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 28.559 secs
Failed to install 'cordova-plugin-whitelist':Error: /Users/richardeng/hello/platforms/android/gradlew: Command failed with exit code 1
at ChildProcess.whenDone (/Users/richardeng/hello/platforms/android/cordova/node_modules/cordova-common/src/superspawn.js:169:23)
at emitTwo (events.js:87:13)
at ChildProcess.emit (events.js:172:7)
at maybeClose (internal/child_process.js:829:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
Failed to restore plugin "cordova-plugin-whitelist" from config.xml. You might need to try adding it again. Error: Error: /Users/richardeng/hello/platforms/android/gradlew: Command failed with exit code 1
So what is it with the Mac???
Try to Setup your PATH environment variable on Mac OS like is explained here.
If it doesn't work try to update android studio or just your sdkmanager like i explain on my other answer here.
Anyway android studio make his own android-sdk directory, be sure your cordova project is pointing to the same directory.

Ionic: Failed to build android

Having huge issues trying to build to android with Ionic. I tried initially the normal ionic build android, it failed with
[Error: ANDROID_HOME is not set and "android" command not in your PATH. You must fulfill at least one of these conditions.]
I did some hunting around stack overflow and ionic forums, and installed Java and Android Studio as a 'solution', it began to install lots of .jar files, and this happened:
Download https://repo1.maven.org/maven2/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar
Download https://repo1.maven.org/maven2/commons-codec/commons-codec/1.4/commons-codec-1.4.jar
Download https://repo1.maven.org/maven2/com/android/tools/external/lombok/lombok-ast/0.2.3/lombok-ast-0.2.3.jar
Download https://repo1.maven.org/maven2/org/abego/treelayout/org.abego.treelayout.core/1.0.1/org.abego.treelayout.core-1.0.1.jar
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> failed to find target with hash string 'android-23' in: /Users/.../Library/Android/sdk
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 51.558 secs
Error: /users/nick/documents/.../.../platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> failed to find target with hash string 'android-23' in: /Users/.../Library/Android/sdk
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Please install Android target: "android-23".
Hint: Open the SDK manager by running: /Users/.../Library/Android/sdk/tools/android
You will require:
1. "SDK Platform" for android-23
2. "Android SDK Platform-tools (latest)
3. "Android SDK Build-tools" (latest)
Any advice? Maybe I need to un-install Android Studio or something? I'm very bad at this, as you likely can tell. But this is hugely holding back the project I'm working on, so will be amazing if someone could help!
Base from Installing the Android Development Environment
Configure the ANDROID_HOME environment variable based on the location of the Android SDK. Additionally, consider adding ANDROID_HOME/tools, and ANDROID_HOME/platform-tools to your PATH.
For Mac :
export ANDROID_HOME=/<installation location>/android-sdk-macosx
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
For windows :
set ANDROID_HOME=C:\<installation location>\android-sdk-windows
set PATH=%PATH%;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools
For linux :
export ANDROID_HOME=/<installation location>/android-sdk-linux
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools

Categories

Resources