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
Related
I'm trying to run react native on windows 10. when I run npm run android i get this following error
Starting JS server...
Building and installing the app on the device (cd android && gradlew.bat installDebug)...
FAILURE: Build failed with an exception.
What went wrong:
Could not determine java version from '11.0.1'.
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
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/getting-started.html
Make sure you have set the necessary paths for Android and Java in your shell.
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home
ANDROID_HOME=/Users/username/Library/Android/sdk
ANDROID_NDK_HOME=/Users/username/Library/Android/sdk/ndk-bundle
Also, sometimes react-native versions may get messed up with the Java versions so it's not so recommended to use Java SDK 11 just yet, so better Java 8 which it's a more stable version.
Try to uninstall the Java SDK 11 and install Java 8, then update your paths in your shell config to match the correct locations, then try again and your app should work like expected.
If you installed Java through homebrew try:
brew cask uninstall java
brew tap caskroom/versions
brew cask install java8
And you're done.
If you installed it directly try rm -rf /Library/Java/JavaVirtualMachines/jdk<version>.jdk to remove it and then download Java 8 either directly or through homebrew (recommended).
TL; DR Downgrade your Java version to Java 8.
Sometime between Java 9 and Java 11, the format of java -version has changed, resulting in breakage in Gradle.
Gradle like the 1.x versions:
As I tested:
λ ~/m-demo/ master jenv versions
system
11.0
11.0.1
1.8
* 1.8.0.191 (set by ~/.jenv/version)
openjdk64-11.0.1
openjdk64-1.8.0.191
Android does not support the latest JAVA version.
I will recommend that use JAVA 8 which is the stablest version for Android.
-
Follow the link to install the JDK and update JAVA_HOME again
https://docs.oracle.com/cd/E19182-01/820-7851/inst_cli_jdk_javahome_t/
(Ignore the title inside the link, just follow the steps on the bottom)
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
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.
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.
I'm trying to build an Android app using inonic build android but I have the following error:
running cordova build android
Running command: "c:\Program Files\nodejs\node.exe" c:\xampp\htdocs\discipulado\
discipulado\hooks\after_prepare\010_add_platform_class.js c:/xampp/htdocs/discip
ulado/discipulado
add to body class: platform-android
Running command: c:\xampp\htdocs\discipulado\discipulado\platforms\android\cordo
va\build.bat
[Error: Please install Android target: "android-21".
Hint: Open the SDK manager by running: C:\Users\Thiago\AppData\Local\Android\sdk
\tools\android.BAT
You will require:
1. "SDK Platform" for android-21
2. "Android SDK Platform-tools (latest)
3. "Android SDK Build-tools" (latest)]
ERROR building one of the platforms: Error: c:\xampp\htdocs\discipulado\discipul
ado\platforms\android\cordova\build.bat: Command failed with exit code 2
You may not have the required environment or OS to build this project
Error: c:\xampp\htdocs\discipulado\discipulado\platforms\android\cordova\build.b
at: Command failed with exit code 2
at ChildProcess.whenDone (c:\Users\Thiago\AppData\Roaming\npm\node_modules\c
ordova\node_modules\cordova-lib\src\cordova\superspawn.js:131: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 already installed Apache Ant, but the error remains. I removed the Android platform with ionic platform remove android and added with ionic platform add android with no success.
Any idea?
UPDATE
I already installed Android Studio and Android SDK Tools.
As the error suggests, your system needs to install "android-21", which is Android 5.0 Lollipop