My problem
I have been using the Tools for Apache Cordova template in visual studio to build an app it has been working for me for like two months no problem at all but then suddenly yesterday after I built it like 6 times it just stopped working.
In VS you get some really bad build errors that don't tell you much about the problem like:
Severity Code Description Project File Line Source
Error C:\Konstruktion\MyFirstApp\MyFirstApp\MyFirstApp\platforms\android\cordova\build.bat: Command failed with exit code 1 MyFirstApp C:\Konstruktion\MyFirstApp\MyFirstApp\MyFirstApp\ERROR building one of the platforms 1 Build
and
Severity Code Description Project File Line Source
Error C:\Konstruktion\MyFirstApp\MyFirstApp\MyFirstApp\platforms\android\cordova\build.bat: Command failed with exit code 1 MyFirstApp C:\Konstruktion\MyFirstApp\MyFirstApp\MyFirstApp\MDAVSCLI 1 Build
So I did try to build it without the help of visual studio with just the CMD commands this was the error I then got:
[Error: Please install Android target: "android-21"]
Hint: Open the SDK manager by running C:\Users\username\AppData\Local\Anndroid\sdk\tools\android.BAT
You will require:
1. "SDK Platfrom" for android-21
2. "Android SDK Platform-tools (latest)
3. "Android SDK Build-tools (latest)]
Error: cmd: Command failed with exit code 2
at ChildProsses.whenDone (C:\Users\myUsername\AppData\Roming\npm\node_modules\cordova\node_modules\cordova-lib\src\cordova\superspawn.js:134:23)
at ChildProcess.emit (events.js:110:17)
at mybyClose (child_process.js:1015:16)
at Process.ChildProcess._handle.onexit (child_process.js:1087:5)
(This is handwritten sens I don't know how copy to the entire output from cmd if you know I can update the question).
Things I have tried so far
re-install the asked tools and sdk platforms via SDK manager
re-install the entire sdk
this Stack Overflow question
What will I try today?
The awesome solutions readers can come up with!
Install everything on a different computer and try there
Try it on windows-10 (like that will help)
Images
I found why the problem appears. This is a problem that only affects user how uses Cordova tools for Visual Studio! (I think).
If you start a build and then cancel it if you have device or emulator selected it will corrupt some files in the debug folder:
C:\Konstruktion\myApp\myApp\myApp\bin\Android\Debug
or where you have put it.
If you don't know where it is just right click the project name in the solution explorer and then click "Open path in File Explorer"
Navigate to the debug folder and delete it's contents, build again and it should work again.
bin\Android\Debug
Related
I'm using Ubuntu Gnome 14.04 64 Bit (for the moment) with kernel 3.19.0-33-generic.
I created a new app (a clean one, no plugin, no www folder with content) to try to build it.
After type in the bash "cordova build android"
I get this error:
Running command: /home/aby/Desktop/testApp/platforms/android/cordova/build
[Error: Android SDK not found. Make sure that it is installed. If it is not at the default location, set the ANDROID_HOME environment variable.]
ERROR building one of the platforms: Error:/home/aby/Desktop/testApp/platforms/android/cordova/build: Command failed with exit code 2
You may not have the required environment or OS to build this project
Error: /home/aby/Desktop/testApp/platforms/android/cordova/build: Command failed with exit code 2
Now if you printenv | grep android
You will get
ANDROID_HOME=/opt/android-sdk-linux
ANDROID_PLATFORM_TOOLS=/opt/android-sdk-linux/platform-tools
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/opt/android-sdk-linux/tools:/opt/android-sdk-linux/platform-tools:/opt/android-sdk-linux/tools:/opt/android-sdk-linux/platform-tools:/home/aby/bin:/home/aby/opt/jdk8/jdk1.8.0_45/bin:/opt/android-sdk-linux/tools:/opt/android-sdk-linux/platform-tools:/opt/android-sdk-linux/tools:/opt/android-sdk-linux/platform-tools
ANDROID_SDK=/opt/android-sdk-linux
You can see that the variables exist, in fact before I run cordova build android I had to use cordova platform add android and its works with no problem.
So I found this Bug, and tried some solution like update android(project) or remove and install it again with no success.
I reinstall the Andoroid SDK, and updated the "/.bashrc", "/.profile" and "~/.pam_enviroment" with the environment values and also this not help.
So how can I fix this? How can I build my app with no error? What I missing?(If you consider that you need another information please tell me).
Thanks, in advance.
At the end I could fix my problem when I change the "Owner" / "Group" to the android sdk folder and Permission to "/tools/android".
Here a link to my previous question, and the solution (at least for me) to fix this error.
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've had this problem when build a android app with cordova command:
cordova build android
D:\Desenvolvimento\ionicapps\AppBelle>cordova build android Running command: "C:\Program Files\nodejs\node.exe"
D:\Desenvolvimento\ionicapps \AppBelle\hooks\after_prepare\010_add_platform_class.js D:\Desenvolvimento\ionic apps\AppBelle add to body class: platform-android
Running command: "C:\Program Files\nodejs\node.exe" D:\Desenvolvimento\ionicapps \AppBelle\hooks\after_prepare\020_remove_sass_from_platforms.js D:\Desenvolvimen to\ionicapps\AppBelle
Running command: D:\Desenvolvimento\ionicapps\AppBelle\platforms\android\cordova \build.bat [Error: Android SDK not found. Make sure that it is installed. If it is not at t he default location, set the ANDROID_HOME environment variable.]
ERROR building one of the platforms:
Error: D:\Desenvolvimento\ionicapps\AppBell e\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: D:\Desenvolvimento\ionicapps\AppBelle\platforms\android\cordova\build.bat : Command failed with exit code 2 at ChildProcess.whenDone (C:\Users\Victor\AppData\Roaming\npm\node_modules\c ordova\node_modules\cordova-lib\src\cordova\superspawn.js:131:23) at ChildProcess.emit (events.js:98:17) at maybeClose (child_process.js:756:16) at Process.ChildProcess._handle.onexit (child_process.js:823:5)
D:\Desenvolvimento\ionicapps\AppBelle>echo %ANDROID_HOME% C:\Users\Victor\AppData\Local\Android\sdk\
Above I show location of env var ANDROID_HOME . I don't know what to do.
Help me, please.
Thanks
I'm learning Ionic (based on Cordova) these days, and I came to this similar problems in Mac os too when execute ionic build android, with similar error msg below:
Running command:/Users/ngloom/code/workspace/myWork/platforms/android/cordova/build
[Error: Android SDK not found. Make sure that it is installed. If it is not at the default location, set the ANDROID_HOME environment variable.]
and the msg still exist after i setting the ANDROID_HOME environment, upgrade the sdk tools, finally i have to look into the check_reqs.js which throw the error and i found that the js is based on the cmd output by android list targets, and finally I found the android is owned by root (very likely that the android is installed by sudo brew before) and only error returned when executing by my user.
So I change the owner of android and everything works !
I post my solution here as a solution backup, hoping to help the guys in case like me :)
Unfortunately this can be a bug caused by upgrading android SDK versions. In general look for for different reasons:
First if you have to set the ANDROID_HOME environment variable. (according to your OS - In windows , right click your PC icon "MY PC", --> properties -> Advanced system settings -> Environment Variables" and set ANDROID_HOME variable and edit PATH variable to your path to your android SDK, tools & platform tools.
Secound try the "android" command in command tool, if android sdk couldn't open it cause a problem to build your app. I got this error:
The "android" command is no longer available.
For manual SDK and AVD management, please use Android Studio.
For command-line tools, use
tools\bin\sdkmanager.bat and tools\bin\avdmanager.bat
to solve it, you should downgrade your sdk using this links:
(Mac) https://dl.google.com/android/repository/tools_r25.2.3-macosx.zip
(Windows) https://dl.google.com/android/repository/tools_r25.2.3-windows.zip
and replace the zip file with your "tools" folder in your android SDK, It will work fine after trying "android" command and building app command in cordova and ionic frameworks.
Digging the reason: (In my case)
Why failing android command is causing this problem?
part of the cordova or ionic configuration in js files are using android command to "VERIFY" your "ANDROID_HOME" and "PATH" environment variables to operate building your app, and in case of any failure accessing to Android sdk via command access, system tells you "Android SDK" is not found. Recently, in new version android command is no longer accessible and is causing issues for any operation whom used this command. :/
Hope it works for you, It took a time for me to figure out solving this issue and don't forget to (+1) if it helped you!
Setting environmental variables use this to set up the path to tools and platform tools and update SDK for the android version that you are trying to build and make sure weather its Ionic or cordova application and then try once
I have met this trouble in both VS2013Up4 and VS2015Pre. My OS is Win8.1 Pro x64. The detail message about the error:
Cannot find module 'q' MDAVSCLI 1 1 WinJSToDo.
And I can get nothing from double click it. Please help me. ORZ...
Currently I'm using Visual Studio 2013 update 4 with Visual Studio Tools for Apache Cordova extension on Windows 8.1. I create a new Cordova JavaScript Blank project and then trigger a build, it turns out to be below building error:
Error 2 Cannot find module 'q' C:\Users\penlv\documents\visual studio
2013\Projects\BlankCordovaApp1\BlankCordovaApp1\MDAVSCLI 1 1
BlankCordovaApp1
Seems many other users run into the same issue. Any help on this?
You can try this link if works.
And also this.
I tried but still have the same error.
Finally i have 'Cannot find module' error fixed:
copy 'lib' and 'resource' folder from 'C:\Program Files\nodejs\node_modules\vs-mda' to 'C:\Users\[user-name]\AppData\Roaming\npm\node_modules\vs-mda'
in 'C:\Users\[user-name]\AppData\Roaming\npm\node_modules\vs-mda' folder, run npm install command
I had this issue when my "User Account Control" was switched on (Windows 8.1).
The solution was to run Visual Studio as Administrator, and then clear your cordova cache, and rebuild.
I'm trying to learn something about multy hybrid app developing under visual studio 2013 using Apache Cordova. I've just created a new project and i'm trying to build it but when I try to build it for android I get 1 warning and 1 error.
warning:
Warning 1 The TypeScript Compiler was given no files for compilation, so it will skip compiling. C:\Program Files\MSBuild\Microsoft\VisualStudio\v12.0\TypeScript\Microsoft.TypeScript.targets 95 5 helloWorld
error:
Error 2 The command ""C:\Users\user01\AppData\Roaming\npm\node_modules\vs-mda\vs-cli" build --platform "Android" --configuration "Debug" --projectDir . --projectName "helloWorld" --language "en-US" --buildServerUrl "" --buildTarget "AndroidEmulator"" exited with code 1. C:\Users\user01\AppData\Roaming\npm\node_modules\vs-mda-targets\Microsoft.MDA.targets 99 5 helloWorld
I've googled those errors but I haven't sorted anything out. Do you know what is the problem?
The issue is because of Android target (latest version) is not available with Android SDK. Make sure the following in your system,
Go to Android installed folder (for me, C:\Users\username\AppData\Local\Android\android-sdk)
Go to tools folder and select "android.bat" Run as Administrator
Check whether the latest version of Android (ex: API 19) is installed or not
If it is not installed, select that API, click install by accepting License
If it is installed, close it and then Go to to root folder(ex: C:\Users\username\AppData\Local\Android\android-sdk)
Double click on the AVD Manager and create new AVD
Now I hope, you can able to build and run the application.