I'm trying to build a project but when I type: cordova build android the following error occurred:
Generating config.xml from defaults
for platform "android"
Preparing android project
Compiling app on platform "android"
via command "../platforms/android/cordova/build"
Error: An error occurred
while building the android project.Error executing "ant debug -f "../platforms/android/build.xml"":BUILD FAILED /usr/local/Cellar/android-sdk/22.3/tools/ant/build.xml:932:The following error occurred
while executing this line: /usr/local/Cellar/android-sdk/22.3/tools/ant/build.xml:950:null returned: 1
Total time: 18 seconds
at ChildProcess. < anonymous > (/usr/local/lib/node_modules/cordova/src/compile.js:65:22)
at ChildProcess.EventEmitter.emit(events.js: 98: 17)
at maybeClose(child_process.js: 735: 16)
at Socket. < anonymous > (child_process.js: 948: 11)
at Socket.EventEmitter.emit(events.js: 95: 17)
at Pipe.close(net.js: 466: 12)
Is there a fix for this problem?
EDIT
I used brew to install Android-SDK and installed all possible build-tools:
And my android manifest looks like:
EDIT2
As requested here is the responce for cordova build android --verbose: http://pastebin.com/rqdkVKYG
I found the bug.
While testing, reinstalling android-sdk and ant. I tried to create a new project. Than typed in the terminal cordova build and it build flawlessly. After this I copied my existing WWW folder in to the new project. Typed cordova build again, it gave an error. Now I knew that the bug was in my WWW folder and not in the project itself. Scanning my folders I noticed a file with no extension(hidden files). I deleted the file and tried again. Success!
SUMMARY:
Scan your folders for files without extensions and delete or move them. Cordova doesn't like those.
EDIT
If this doesn't work try:
cordova platform rm android
then reinstall android using :
cordova platform add android
Now try to build.
try to run the command $home/.cordova/lib/android/cordova/3.3.0/bin/check_reqs to check if you have all the required components installed for android.
¿Did you add to windows path the sdk?
You can also try:
cordova platform add android
cordova build
try ant -v in your terminal and make sure it's above 1.8. Cordova requires that.
Also check path is given correct for Ant, Android-SDK/tools, and Android-SDK/platformtools
To debug exact issue try $Cordova build android --verbose
Let me know.
Related
I tried to update android in an existing phonegap project, told me fetching 7.0.0 ... completed. when I list platforms, it told me 6.3.0 was installed. So I did
phonegap platform remove android
phonegap platform add android
and copied my jks into platforms/android again.
phonegap build android (--release) is both telling me:
[phonegap] executing 'cordova build android' ...
[phonegap] completed 'cordova build android --no-telemetry'
But I cant find my outputs folder. Neither in platforms/android/build (I only have folder "android-profile" with a json and a rowproto file for every build) nor in platforms/android/app/build (there are folders "intermediate" and "generated"). I already searched for android-release-unsigned.apk and app-release-unigned.apk - nothing found.
Anybody an idea where to search or find out why it isn't created although there are no errors?
Thanks in advance
The answer can be found by adding "-d" to the build command. Then phonegap gives detailed information on build problems. In my case it could not find google-services.json
I faced the same issue and found that the output directory has been changed from ..platforms\android\build to ..\platforms\android\app\build\outputs\apk\debug
You could check the above directory.
While trying to do a release using the following command:
code-push release-cordova myApp android
I'm getting the following error in the terminal:
Running "cordova prepare" command:
[Error] Unable to prepare project. Please ensure that this is a Cordova project and that platform "android" was added with "cordova platform add android"
Any one knows what might be wrong? The project is a cordova project created using the command:
cordova create myApp
And also has android platform added.
UPDATE :
Running cordova prepare android --verbose returns the following output :
Executing "before_prepare" hook for all plugins.
Searching PlatformJson files for differences between project vs. platform installed plugins
No differences found between project and android platform. Continuing...
Generating config.xml from defaults for platform "android"
Wrote out Android application name to "HelloCordova"
Wrote out Android package name to "io.cordova.hellocordova"
This app does not have launcher icons defined
updated project successfully
Executing "after_prepare" hook for all plugins.
Make sure your Nodejs is the last version.
code-push-cli required "child_process"
That error indicates that the current working directory didn't represent the root of a Cordova project at the time that you ran the release-cordova command. Can you make sure that you CD into the directory that contains the www, platforms, plugins, etc. directories, and then run the release-cordova command? That should do the trick for you
After upgrading the cordova and the npm of my machine (Ubuntu 15.10) I can not build a new project with the cordova. The build accuses an error in graddle.
I did some research and found some possible solutions. Solutions like changing the version and url graddle repo. Anyway, it did not work.
I am using the cordova 6.0.0 and npm 1.4.21.
Below commands of fresh cordova app installation:
soufraz#atlantis:~/Projects/apps$ cordova create test com.somename.test Test
Creating a new cordova project.
soufraz#atlantis:~/Projects/apps$ cd test/
soufraz#atlantis:~/Projects/apps/test$ cordova platform add android
Adding android project...
Creating Cordova project for the Android platform:
Path: platforms/android
Package: com.somename.test
Name: Test
Activity: MainActivity
Android target: android-23
Android project created with cordova-android#5.1.0
Discovered plugin "cordova-plugin-whitelist" in config.xml. Installing to the project
Fetching plugin "cordova-plugin-whitelist#1" via npm
Installing "cordova-plugin-whitelist" for android
This plugin is only applicable for versions of cordova-android greater than 4.0. If you have a previous platform version, you do *not* need this plugin since the whitelist will be built in.
soufraz#atlantis:~/Projects/apps/test$ cordova build
ANDROID_HOME=/home/soufraz/Install/android-sdk-linux
JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:1.5.0.
Required by:
:android:unspecified
> Failure initializing default system SSL context
* 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: 0.769 secs
ERROR building one of the platforms: Error code 1 for command: /home/soufraz/Projects/apps/test/platforms/android/gradlew with args: cdvBuildDebug,-b,/home/soufraz/Projects/apps/test/platforms/android/build.gradle,-Dorg.gradle.daemon=true,-Pandroid.useDeprecatedNdk=true
You may not have the required environment or OS to build this project
Error: Error code 1 for command: /home/soufraz/Projects/apps/test/platforms/android/gradlew with args: cdvBuildDebug,-b,/home/soufraz/Projects/apps/test/platforms/android/build.gradle,-Dorg.gradle.daemon=true,-Pandroid.useDeprecatedNdk=true
Extra informations:
- I have all android apis 19 - 24 installed.
- cordova build android -- --ant doesn't works too
- I've tested it with the java jdk 1.7 and 1.8
- All tries with --stacktrace/--debug/--info: pastebin.com/nD6GNkbR
check_reqs (it was asked via comments):
soufraz#atlantis:~/Projects/apps/test/platforms/android/cordova$ ./check_reqs
ANDROID_HOME=/home/soufraz/Install/android-sdk-linux
JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
Looks like your environment fully supports cordova-android development!
java -version:
openjdk version "1.8.0_66-internal"
OpenJDK Runtime Environment (build 1.8.0_66-internal-b17)
OpenJDK 64-Bit Server VM (build 25.66-b17, mixed mode)
After nearly two weeks looking for a solution, I found a glorious question WITH A REAL ANSWER that solved the problem!!
Source: Peer not authenticated while importing Gradle project in eclipse
REPLICATING THE ORIGINAL ANSWER
If you get any other error like this:
Could not GET 'https://some_server.com/some/path/some.pom'.
> peer not authenticated
Then you need to import a certificate:
open the 'https://some_server.com/some/path/some.pom' in your favorite browser
export the cert using the Steps to export cert from a web site
copy the cer into JDK_HOME/jre/lib/security folder
open a shell and go to JDK_HOME/jre/lib/security folder
then import the cer into java using the
keytool -import -alias <the short name of the server> -file <cert_file_name_you_exported.cer> -keystore cacerts -storepass changeit
It will prompt you to import the certificate, type yes and press enter.
Then restart your eclipse and try building the project.
Thats happens when you try to update your SKD or cordova without the other, then, the versions could be not compatibles (not in all the cases, but happens).
Then, try to update manually your Android SDK version and your cordova to the lastest version.
If you are using the terminal, you can use the command: android update sdk --no-ui --filter extra
But my recomendation is update your Android SDK
I'm new on cordova, so if my question is not relevant, forgive me.
i have a cordova project in my Windows 7 x64 machine.
Yesterday i was build my cordova app via cordova build android --release.
But i need to add new plugin cordova-plugin-zip to update my cordova project.
What i did to add this plugin to my cordova app;
I installed a git application to my win7 x64 env.
npm install -g git i wrote this command on cmd.
I Opened Windows Environment Variables/Path Window and added ;C:\Program Files (x86)\Git\bin;C:\Program Files (x86)\Git\cmd
add plugin via this command cordova plugin add https://github.com/apache/cordova-plugin-file.git
then added other plugin cordova plugin add https://github.com/MobileChromeApps/zip.git
(Everything fine till this step)
Then i run on cmd cordova build android --release
Unfourtunately it throws following error;
BUILD FAILED C:\android\sdk\tools\ant\build.xml:720: The following
error occurred while execu ting this line:
C:\android\sdk\tools\ant\build.xml:734: Compile failed; see the
compiler error o utput for details.
Total time: 7 seconds
C:\hascevher\platforms\android\cordova\node_modules\q\q.js:126
throw e;
^ Error code 1 for command: cmd with args: /s,/c,ant,release,-f,C:\hascevher\platf
orms\android\build.xml,-Dout.dir=ant-build,-Dgen.absolute.dir=ant-gen
ERROR building one of the platforms: Error: cmd: Command failed with
exit code 1
You may not have the required environment or OS to build this project
Error: cmd: Command failed with exit code 1
at ChildProcess.whenDone (C:\Users\Hddn\AppData\Roaming\npm\node_modules\cor
dova\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)
When i try to create a new helloworld cordova project and adding android platform then from cmd cordova build android it creates sample app?
So what is wrong with my other application?
Any help greatly appricated.
OS: Windows 7 x64
Cordova v 5.1.1
Ant version 1.9.4
Plugins On Cordova Project:
cordova-plugin-file
cordova-plugin-zip
org.apache.cordova.console
org.apache.cordova.device
org.apache.cordova.inappbrowser
Full Windows Environment Variables/Path:
C:\ProgramData\Oracle\Java\javapath;C:\Program Files\Common
Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common
Files\Microsoft Shared\Windows
Live;%C_EM64T_REDIST11%bin\Intel64;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program
Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files
(x86)\Windows Live\Shared;C:\Program Files
(x86)\QuickTime\QTSystem\;C:\Program Files
(x86)\Java\jdk1.7.0_75\bin;C:\cordova\apache-ant-1.9.4\bin;C:\android\sdk\tools;C:\android\sdk\platform-tools;C:\Program
Files\nodejs\;C:\Program Files (x86)\Git\bin;C:\Program Files
(x86)\Git\cmd
I removed android platforms and installed again then worked. I wrote these lines in command window:
cordova platform remove android
then
cordova platform add android
Delete platforms/android folder and try to rebuild. That helped me a lot.
(Visual Studio Tools for Apache Cordova)
Delete all the apk files from platfroms >> android >> build >> generated >> outputs >> apk
and run command cordova run android
I found answer myself; and if someone will face same issue, i hope my solution will work for them as well.
Downgrade NodeJs to 0.10.36
Upgrade Android SDK 22
I have had this problem several times and it can be usually resolved with a clean and rebuild as answered by many before me. But this time this would not fix it.
I use my cordova app to build 2 seperate apps that share majority of the same codebase and it drives off the config.xml. I could not build in end up because i had a space in my id.
com.company AppName
instead of:
com.company.AppName
If anyone is in there config as regular as me. This could be your problem, I also have 3 versions of each app. Live / Demo / Test - These all have different ids.
com.company.AppName.Test
Easy mistake to make, but even easier to overlook. Spent loads of time rebuilding, checking plugins, versioning etc. Where I should have checked my config. First Stop Next Time!
I had the same error code but different issue
Error: /Users/danieloram/desktop/CordovaProject/platforms/android/gradlew: Command failed with exit code 1 Error output:
Exception in thread "main" java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version 52.0
To resolve this issue I opened the Android SDK Manager, uninstalled the latest Android SDK build-tools that I had (24.0.3) and installed version 23.0.3 of the build-tools.
My cordova app then proceeded to build successfully for android.
In my case it was the file size restriction which was put on proxy server. Zip file of gradle was not able to download due this restriction. I was getting 401 error while downloading gradle zip file. If you are getting 401 or 403 error in log, make sure you are able to download those files manually.
Faced same problem. Problem lies in required version not installed.
Hack is simple Goto Platforms>platforms.json
Edit platforms.json in front of android modify the version to the one which is installed on system.
I'm using Visual Studio 2015, and I've found that the first thing to do is look in the build output.
I found this error reported there:
Reading build config file: \build.json... SyntaxError: Unexpected
token
The solution for that was to remove the bom from the build.json file
Then I hit a second problem - with this message in the build output:
FAILURE: Build failed with an exception. * What went wrong: A
problem was found with the configuration of task ':packageRelease'.
File 'C:\Users\Colin\etc' specified for property
'signingConfig.storeFile' is not a file.
Easily solved by putting the correct filename into the keystore property
I installed PhoneGap 3.0 with Node.js and configured all the environment variables so that javac, java, and ant all work but when I do a basic app create and try to build it for Android, I get the following error:
An error occurred during creation of android sub-project. Creating Cordova project for the Android platform: Command failed to execute : ant jar
Any ideas?
Make sure you have the Android Build Tools installed for your Android SDK version. In the Android SDK manager under Tools>Android SDK Build-tools you should see that the Build tools for your SDK version are not installed.
Detail on how I uncovered this:
To identify this as the root cause I ran the Cordova command with -d for verbosity:
cordova -d platform add android
The output of this command shows the error:
Running bin/create for platform "android" with command: ""C:\Users\---\.cordova\lib\android\cordova\3.1.0\bin\create" "C:\Users\---\workspace_android\FleetView\platforms\android" "com.---.fleetview" "Fleet View"" (output to follow)
Running the offending command directly:
"C:\Users\---\.cordova\lib\android\cordova\3.1.0\bin\create" "C:\Users\---\workspace_android\FleetView\platforms\android" "com.---.fleetview" "Fleet View"
produces this output:
BUILD FAILED
C:\tools\adt-bundle-windows-x86_64-20130219\sdk\tools\ant\build.xml:479: SDK does not have any Build Tools installed.
Total time: 1 second
Command failed to execute : ant jar
I am on Windows 7.
This is due to ANT tools could not find tools.jar in JRE lib directory. When I copied tools.jar from JDK lib directory to JRE lib directory, the problem was absolutely solved and the build was successful when I ran the command "cordova -d platform add android". Hope this helps you.
Posted the answer to similar question: Android Platform Guide trouble with adding a platform through the command line
A combination of 2 things worked for me:
include the JDK in your path (path\to\jdk\bin of course)
exclude the JRE from your path (or at least have it come after the JDK)
I faced the same issue,
I was having jdk-6 and I updated to jdk-7,
that fixed the issue,
Also I didn't installed ant in the first place,
in your case ant PATH might be missing.
See if that helps.