Is Cordova for Android broken on the Mac? - android

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.

Related

ionic cordova build android - build failed with an exception

I'm a beginner and in trouble with Ionic. I want to make an android app using Cordova for my homework. I tried to switch to Android Studio, uninstall-reinstall the Gradle, run the command with the --verbose flag and nothing works. When I type "ionic cordova build android" I got this error:
**FAILURE: Build failed with an exception.**
* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Failed to install the following Android SDK packages as some licences have not been accepted.
platforms;android-29 Android SDK Platform 29
To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html
Using Android SDK: C:\Users\Hp\AppData\Local\Android\sdk
* 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.
* Get more help at https://help.gradle.org
**BU¦LD FAILED in 1s**
Command failed with exit code 1: C:\Users\Hp\hava\platforms\android\gradlew cdvBuildDebug -b C:\Users\Hp\hava\platforms\android\build.gradle
[ERROR] An error occurred while running subprocess cordova.
cordova.cmd build android exited with exit code 1.
Have you installed SDKs and AVDs?
This link has an excellent walk thru
Could be u are using wrong java version.....maybe you didn't set up ENV path.....possibly (most likely based on error) you have not download API levels and accepted the licensing agreement which then also means you haven't install an AVD.
That guide should set you straight.

Android accept the license agreements of SDK [Google Repository, Android Support Repository]

when I tried to build the project
ionic build android
or adding this plugin in particular
$ ionic plugin add cordova-plugin-screen-orientation
ir return this problem with licence
$ ionic plugin add cordova-plugin-screen-orientation
WARN: ionic.project has been renamed to ionic.config.json, please rename it.
Fetching plugin "cordova-plugin-screen-orientation" via npm
Installing "cordova-plugin-screen-orientation" for android
ANDROID_HOME=/xxx/Android SDK/adt-bundle-mac-x86_64-20140702/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home
Subproject Path: CordovaLib
Incremental java compilation is an incubating feature.
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:
[Google Repository, Android Support Repository].
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: 7.315 secs
Failed to install 'cordova-plugin-screen-orientation':Error: /XXX/platforms/android/gradlew: Command failed with exit code 1
at ChildProcess.whenDone (/XXX/platforms/android/cordova/node_modules/cordova-common/src/superspawn.js:169:23)
at emitTwo (events.js:100:13)
at ChildProcess.emit (events.js:185:7)
at maybeClose (internal/child_process.js:850:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:215:5)
Error: /XXX/platforms/android/gradlew: Command fail
Help please
Found a solution, the licences I'm looking for are
[Google Repository, Android Support Repository]
to install those I need it to do
$ android update sdk --no-ui --filter extra-android-m2repository,extra-google-m2repository
And that worked for me

Unable to build Android using ionic

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

Build error when using Cordova google-analytics-plugin

I am trying to add https://github.com/nickdrewe/google-analytics-plugin to my cordova project. But the build failed. Here are what I tried:
Install google playservices 21 instead of 19. Edit plugin.xml to point to 21 but still don't work.
Remove google playservices completely and use framework instead https://github.com/nickdrewe/google-analytics-plugin/commit/cb8e78f17472ae2c8b4db613273764a7260b4e34 but still build error
I also tried android update sdk --no-ui --all --filter "extra-google-m2repository" from https://groups.google.com/forum/#!topic/adt-dev/UXW0Hl0UVXk
The error I got:
FAILURE: Build failed with an exception.
* What went wrong:
Failed to notify build listener.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
/vagrant/MyProject/platforms/android/cordova/node_modules/q/q.js:126
throw e;
^
Error code 1 for command: /vagrant/MyProject/platforms/android/gradlew with args: cdvBuildDebug,-b,/vagrant/MyProject/platforms/android/build.gradle,-Dorg.gradle.daemon=true
ERROR building one of the platforms: Error: /vagrant/MyProject/platforms/android/cordova/build: Command failed with exit code 1
You may not have the required environment or OS to build this project
Error: /vagrant/MyProject/platforms/android/cordova/build: Command failed with exit code 1
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:134: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 am using Ionic 1.5.5 and Cordova Android 4.0.2
Any help?
I am open to alternative Google Analytics plugin but I found https://github.com/phonegap-build/GAPlugin causing Android app crashing upon start.
I just tried to reproduce your error - and there is none. I build a new project with the plugin you linked and also the console plugin. The build was totaly fine and successfull.
As far as i see you edited your gradle build settings for speeding up the gradle build. -Dorg.gradle.daemon=true... as far as i read through the documents this must be -org.gradle.daemon=true or is the D sth like an operator or a variable which has to be there?
What you can also try is to run the cmd as an administrator.
Cordova downgrade from 5.1.1 to 4.3.2 fixed the problem for many users.

error in building android app using apache cordova

i have installed cordova on linux mint 17.1 xfce, jdk and android and npm is ok and i can create new cordova application and add android platform to it :
cordova create ...
cordova platform add android ..
but when i want to build android i get a error :
cordova build ...
Running command: /home/nasser/Desktop/app/app01/platforms/android/cordova/build
ANDROID_HOME=/home/nasser/android/sdk
JAVA_HOME=/usr/lib/jvm/java-7-openjdk-i386
Running: /home/nasser/Desktop/app/app01/platforms/android/gradlew cdvBuildDebug -b /home/nasser/Desktop/app/app01/platforms/android/build.gradle -Dorg.gradle.daemon=true
FAILURE: Build failed with an exception.
* Where:
Script '/home/nasser/Desktop/app/app01/platforms/android/CordovaLib/cordova.gradle' line: 64
* What went wrong:
A problem occurred evaluating root project 'android'.
> No installed build tools found. Please 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.
BUILD FAILED
Total time: 20.222 secs
/home/nasser/Desktop/app/app01/platforms/android/cordova/node_modules/q/q.js:126
throw e;
^
Error code 1 for command: /home/nasser/Desktop/app/app01/platforms/android/gradlew with args: cdvBuildDebug,-b,/home/nasser/Desktop/app/app01/platforms/android/build.gradle,-Dorg.gradle.daemon=true
ERROR building one of the platforms: Error: /home/nasser/Desktop/app/app01/platforms/android/cordova/build: Command failed with exit code 8
You may not have the required environment or OS to build this project
Error: /home/nasser/Desktop/app/app01/platforms/android/cordova/build: Command failed with exit code 8
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131:23)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:743:16)
at Process.ChildProcess._handle.onexit (child_process.js:810:5)
what i can do ?
Once you installed the android sdk, configured ANDROID_HOME and updated the path, you have to run the androidcommand to actually download the sdk tools and android platform.
You don't need to download everything. You can uncheck the system images (keep one if you want to use the emulator), the samples, the sources of android, the docs and android apis older than API 22 (latest android cordova version 4 requires api 22).
Not sure if you still need to install ant with android cordova 4, as it seems they switched to graddle wich is installed automatically.
I had the same problem, and this is the solution for the problem referent to:
No installed build tools found. Please install the Android build tools
version 19.1.0 or higher.
1) You have to go to the android sdk tools folder, for example (in my case) I just wrote the command in my console: $ cd android-sdk-linux/tools
2) Inside this folder you have to write the command
$ ./android list sdk --all and after
$ ./android update sdk -u -a -t 20
And that's all! :)
This will install all the tools you need as well as the system images which are quite large, limit them using the --filter flag
android update sdk --no-ui --all

Categories

Resources