I am new to cordova and am trying to create an android HelloWold project.
When I use cordova platforms add android, it throws some exception:
D:\CordovaSpace\helloWorld>cordova platforms add android
Adding android project...
Creating Cordova project for the Android platform:
Path: platforms\android
Package: com.example.helloworld
Name: HelloWorld
Activity: MainActivity
Android target: android-24
Subproject Path: CordovaLib
Android project created with cordova-android#6.0.0
Installing "cordova-plugin-whitelist" for android
ANDROID_HOME=D:\Java_Android_SDK\android_sdk
JAVA_HOME=C:\Program Files (x86)\Java\jdk1.8.0_73
Subproject Path: CordovaLib
Starting a new Gradle Daemon for this build (subsequent builds will be faster).
FAILURE: Build failed with an exception.
* What went wrong:
Unable to start the daemon process.
This problem might be caused by incorrect configuration of the daemon.
For example, an unrecognized jvm option is used.
Please refer to the user guide chapter on the daemon at https://docs.gradle.org/2.14.1/userguide/gradle_daemon.html
Please read the following process output to find out more:
-----------------------
Error occurred during initialization of VM
Could not reserve enough space for 2097152KB object heap
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Failed to install 'cordova-plugin-whitelist':Error: cmd: Command failed with exit code 1
at ChildProcess.whenDone (D:\CordovaSpace\helloWorld\platforms\android\cordova\node_modules\cordova-common\src\superspawn.js:169:23)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:850:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:215:5)
Error: cmd: Command failed with exit code 1
Try again after increasing your Java VM(?) memory size.
Here is how to fix it on a Windows platform:
Go to Start -> Control Panel -> System -> Advanced(tab) -> Environment Variables -> System Variables -> New:
Variable name: _JAVA_OPTIONS
Variable value: -Xmx512M
Don't ignore the score and underscore characters.
I had the exact same problem. I switched to use 64-bit JDK as suggested in here and it worked fine. I was using Ionic 3.5.0 on Windows 10.
this worked for my ionic app.
Change line on
// to allow dex in process
'org.gradle.jvmargs': '-Xmx1024m',
from
// to allow dex in process
'org.gradle.jvmargs': '-Xmx2048m',
in your
<app path>\platforms\android\cordova\lib\config
thanks
args.push('-Dorg.gradle.jvmargs=-Xmx2048m')
into
args.push('-Dorg.gradle.jvmargs=-Xmx1024m');
on the following location files.
project-folder\platforms\android\cordova\lib\builders\GradleBuilder.js
project-folder\platforms\android\cordova\lib\builders\StudioBuilder.js
Go to : \platforms\android\cordova\lib\config\GradlePropertiesParser.js
constructor (platformDir) {
this._defaults = {
// 10 seconds -> 6 seconds
'org.gradle.daemon': 'true',
// to allow dex in process
'org.gradle.jvmargs': '-Xmx2048m',
// allow NDK to be used - required by Gradle 1.5 plugin
'android.useDeprecatedNdk': 'true'
// Shaves another 100ms, but produces a "try at own risk" warning. Not worth it (yet):
// 'org.gradle.parallel': 'true'
};
And change the 'org.gradle.jvmargs': '-Xmx2048m', to 'org.gradle.jvmargs': '-Xmx1024m',
args.push('-Dorg.gradle.jvmargs=-Xmx2048m')
to
args.push('-Dorg.gradle.jvmargs=-Xmx1024m');
on the following location files.
project-folder\platforms\android\cordova\lib\builders\builders.js
project-folder\platforms\android\cordova\lib\builders\GradleBuilder.js
project-folder\platforms\android\cordova\lib\builders\StudioBuilder.js
Go to Start -> Control Panel -> System -> Advanced(tab) -> Environment Variables -> System Variables
Add/change JAVA_HOME value
from C:\Program Files (x86)\Java\jdk1.8.0_192
to C:\Program Files\Java\jdk1.8.0_192
That is, change from Program Files (x86) path to Program Files path.
I had a same problem.
Anyway, here is how to fix it:
Go to Start->Control Panel->System->Advanced(tab)->Environment Variables->System Variables->New:
Variable name: _JAVA_OPTIONS
Variable value: -Xmx512M
if 512 not work then change it to.
Variable value: -Xmx1024M
And also change the path.
Variable name: Path
Variable value: ;C:\Program Files\Java\jre6\bin;F:\JDK\bin;
Change this to your appropriate path.
Setting the environment variable at system level as in the #kemal's solution will set the memory size for all the JVM applications in the system, which is not a what most would want to do.
Instead, set the heap size in your cordova gradlebuilder property file.
args.push('-Dorg.gradle.jvmargs=-Xmx2048m');
Related
Soo... everything worked fine then after taking a break from work apps wont run.
New or empty project it does not matter.
Flutter doctor says everything is fine.
Here is Debug console.
Launching lib/main.dart on iPhone 14 Pro Max in debug mode...
lib/main.dart:1
Xcode build done. 3.8s
Failed to build iOS app
Error output from Xcode build:
↳
** BUILD FAILED **
Xcode's output:
↳
Writing result bundle at path:
/var/folders/bm/_wgnp7b94l78gc2g88cq3kbc0000gn/T/flutter_tools.MW6UxN/flutter_ios_build_temp_dirktvpW1/temporary_xcresult_bundle
/Applications/flutter/packages/flutter/lib/src/widgets/ticker_provider.dart:186:7: Error: 'ethrow' isn't a type.
ethrow FlutterError.fromParts(<DiagnosticsNode>[
^^^^^^
/Applications/flutter/packages/flutter/lib/src/widgets/ticker_provider.dart:186:14: Error: Expected ';' after this.
ethrow FlutterError.fromParts(<DiagnosticsNode>[
^^^^^^^^^^^^
/Applications/flutter/packages/flutter/lib/src/widgets/ticker_provider.dart:186:26: Error: Expected an identifier, but got '.'.
Try inserting an identifier before '.'.
ethrow FlutterError.fromParts(<DiagnosticsNode>[
^
/Applications/flutter/packages/flutter/lib/src/widgets/ticker_provider.dart:195:6: Error: A value of type 'bool?' can't be assigned to a variable of type 'bool' because 'bool?' is nullable and 'bool' isn't.
}());
^
Failed to package /Users/stankoo003/minimal_design.
Command PhaseScriptExecution failed with a nonzero exit code
note: Building targets in dependency order
warning: Run script build phase 'Thin Binary' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'Runner' from project 'Runner')
warning: Run script build phase 'Run Script' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'Runner' from project 'Runner')
Result bundle written to path:
/var/folders/bm/_wgnp7b94l78gc2g88cq3kbc0000gn/T/flutter_tools.MW6UxN/flutter_ios_build_temp_dirktvpW1/temporary_xcresult_bundle
Could not build the application for the simulator.
Error launching application on iPhone 14 Pro Max.
Exited
flutter doctor, empty projects..
This shows a problem in Flutter's TickerProvider class.
It might be a version problem. Try flutter upgrade.
Clean your project flutter clean then flutter pub get and try building again.
hello
I am trying to build hybrid app with ionic and cordova
at first i run below commands and they run successfully
but after running the last command i get this error
ionic start firtApp
cd firtApp
ionic platform add android
note: it return me android-21 error, and i changed the android-21 to android-18, and it runs successfully
ionic build android
after running the above command i got this error
BUILD FAILED
D:\New folder\android-sdk-final\android-sdk-fully\sdk\tools\ant\build.xml:601: T
he following error occurred while executing this line:
D:\New folder\android-sdk-final\android-sdk-fully\sdk\tools\ant\build.xml:542: U
nable to resolve project target 'android-21'
Total time: 1 second
C:\Users\Mohammad\firstapp\platforms\android\cordova\node_modules\q\q.js:126
throw e;
^
Error code 1 for command: cmd with args: /s /c "ant debug -f C:\Users\Mohammad\f
irstapp\platforms\android\build.xml -Dout.dir=ant-build -Dgen.absolute.dir=ant-g
en"
ERROR building one of the platforms: Error: C:\Users\Mohammad\firstapp\platforms
\android\cordova\build.bat: Command failed with exit code 8
You may not have the required environment or OS to build this project
Error: C:\Users\Mohammad\firstapp\platforms\android\cordova\build.bat: Command f
ailed with exit code 8
at ChildProcess.whenDone (C:\Users\Mohammad\AppData\Roaming\npm\node_modules
\cordova\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)
please help me with this error
i really like to bulid hybrid apps with my web knowledge
thanks.
You can try this
Go to this directory
C:\Users\Mohammad\.cordova\lib\npm_cache\cordova-android\3.6.4\package\framework
Edit project.properties file. Change target to 19.
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "ant.properties", and override values to adapt the script to your
# project structure.
# Indicates whether an apk should be generated for each density.
split.density=false
# Project target.
target=android-19
apk-configurations=
renderscript.opt.level=O0
android.library=true
Restart your terminal.
You don't have SDK correctly installed on you computer. (Path or SDK update)
It's write on your error log : You may not have the required environment or OS to build this project
you just need to install ant
sudo apt-get install ant
then do the same as before,its work correctly
I am attempting to use the emulator via Phonegap, upon following these instructions in order to build the app. It fist tells me that I dont have Android installed as a platform, but I do have the Android sdk, of which I then made sure that the path was correct following these instructions, .
I then attempt to check platforms, and receive error that no platforms installed.
I then skipped to building the app, just to see what would happen, and receive this:
C:\Users\Jessica.PORTER\hello>cordova platform add android
Creating android project...
C:\Users\Jessica.PORTER\.cordova\lib\npm_cache\cordova-android\3.6.4
\node_modules\q\q.js:126
throw e;
^
Error: ANDROID_HOME is not set and "android" command not in your PAT
fulfill at least one of these conditions.
at C:\Users\Jessica.PORTER\.cordova\lib\npm_cache\cordova-androi
age\bin\lib\check_reqs.js:159:19
at _fulfilled (C:\Users\Jessica.PORTER\.cordova\lib\npm_cache\co
d\3.6.4\package\bin\node_modules\q\q.js:798:54)
at self.promiseDispatch.done (C:\Users\Jessica.PORTER\.cordova\l
\cordova-android\3.6.4\package\bin\node_modules\q\q.js:827:30)
at Promise.promise.promiseDispatch (C:\Users\Jessica.PORTER\.cor
_cache\cordova-android\3.6.4\package\bin\node_modules\q\q.js:760:13)
at C:\Users\Jessica.PORTER\.cordova\lib\npm_cache\cordova-androi
age\bin\node_modules\q\q.js:821:14
at flush (C:\Users\Jessica.PORTER\.cordova\lib\npm_cache\cordova
.4\package\bin\node_modules\q\q.js:108:17)
at process._tickCallback (node.js:442:13)
at Function.Module.runMain (module.js:499:11)
at startup (node.js:119:16)
at node.js:929:3
Error: C:\Users\Jessica.PORTER\.cordova\lib\npm_cache\cordova-androi
age\bin\create.bat: Command failed with exit code 8
at ChildProcess.whenDone (C:\Users\Jessica.PORTER\AppData\Roamin
odules\cordova\node_modules\cordova-lib\src\cordova\superspawn.js:13
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:766:16)
at Process.ChildProcess._handle.onexit (child_process.js:833:5)
As you can still see from
Error: ANDROID_HOME is not set and "android" command not in your PATH
It clearly tells you that you haven't set the ANDROID_HOME and that the android command isn't found from your PATH. To fix it, locate the Android SDK installation location and at it to the PATH. Also, open new command line instance after adding them since they are only loaded at the boot-time of command line.
You can also check if the android command is correctly added to PATH by opening the command line and simply typing android. If it tells you something like no such program, it means that it isn't still available.
Changing ANdroid Home -
I fixed the problem by adding a new Environment Variable named ANDROID_SDK_HOME and then linked it to Android folder C:\Program Files (x86)\Android
Thank you for all your help!!!!
I was having an error that is Camera not successful invoked on first try (click) so I tried this solution on stackoverflow Phonegap(3.0.0) Camera not successful on first try.
I followed the steps as mentioned in the answer removed android by cordova platform remove android then I run the second command cordova platform add android ;
Now when I use netbeans to run the cordova application on cordova android decvice this error occurs:
exec: ant debug -f "/var/www/mobile/platforms/android/build.xml"
[ 'ant debug -f "/var/www/mobile/platforms/android/build.xml"',
{ [Error: Command failed:
BUILD FAILED
/var/www/adt-bundle-linux-x86_64-20130917/sdk/tools/ant/build.xml:720: The following error occurred while executing this line:
/var/www/adt-bundle-linux-x86_64-20130917/sdk/tools/ant/build.xml:734: Compile failed; see the compiler error output for details.
Total time: 8 seconds
] killed: false, code: 1, signal: null },
'Buildfile: /var/www/mobile/platforms/android/build.xml\n\n-set-mode-check:\n\n-set-debug-files:\n\n-check-env:\n [checkenv] Android SDK Tools Revision 22.3.0\n [checkenv]
.
.
.**LONG TEXT which I removed from the post **
.
\nBUILD FAILED\n/var/www/adt-bundle-linux-x86_64-20130917/sdk/tools/ant/build.xml:720:
The following error occurred while executing this line:\n/var/www/adt-bundle-linux-x86_64- 20130917/sdk/tools/ant/build.xml:734:
Compile failed; see the compiler error output for details.\n\nTotal time: 8 seconds\n' ]
Error executing "ant debug -f "/var/www/mobile/platforms/android/build.xml"":
BUILD FAILED
/var/www/adt-bundle-linux-x86_64-20130917/sdk/tools/ant/build.xml:720: The following error occurred while executing this line:
/var/www/adt-bundle-linux-x86_64-20130917/sdk/tools/ant/build.xml:734: Compile failed; see the compiler error output for details.
Total time: 8 seconds
child_process.spawn(/var/www/mobile/platforms/android/cordova/build,[]) = 2
/usr/local/lib/node_modules/cordova/node_modules/q/q.js:126
throw e;
Error: An error occurred while building the android project.Error executing "ant debug -f "/var/www/mobile/platforms/android/build.xml"":
BUILD FAILED
/var/www/adt-bundle-linux-x86_64-20130917/sdk/tools/ant/build.xml:720: The following error occurred while executing this line:
/var/www/adt-bundle-linux-x86_64-20130917/sdk/tools/ant/build.xml:734: Compile failed; see the compiler error output for details.
Total time: 8 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)
/var/www/mobile/nbproject/build.xml:256: exec returned: 8
BUILD FAILED (total time: 4 minutes 36 seconds)
any idea about this problem?
I was having a similar issue. I ran ant debug -f "/path/to/project/build.xml" from a separate terminal. It displayed a more specific description of the error (which for me wast that there was a space in the project name). This answer also notes:
config.xml can't have a widget id with number as a first character
after a dot. For example: com.42myapp.test or com.myapp.42test won't
work as well as 42com.myapp.test. It will trigger an error from the
compiler.
I was facing similar issues when i started using the CLI to build apps using cordova and started checking the internet for solutions. While i was at it, i discovered the following things that may help you or anyone else facing the same problem can take some hints from this:
These are some very basic checks that you need to take
1. make sure you have all the required sdk's in place (ANT, Java, Android) and is available when you use these commands on the terminal/command $ ant $ java $ adt. if any of these commands are not found, then you need to get it installed or get the class paths fixed.
make sure your project path does not have spaces. i.e. do not have spaces or special characters in directory names. this issue seems to have been fixed on latest versions of cordova and phonegap, but either cases it is a good practice to follow as ant and java paths could be dependent on the folder names you make.
use -d or -v to get extra debug information on the build process to know where and what is causing the issue. $ cordova build android -d or $ cordova build android -v
Make sure you dont use "#" as the link attribute of author tag in the cordova config.xml on the root of the project. This expects the compiler to interpret a hexadecimal color and fails the build. (this was my problem)
Hope this helps.
er... Happy debugging??
Make sure your Ant is 1.8.0 or later version. Cordova 3.3 demands that.
In the past several days, I found that the conflicting files from Dropbox had a very long name. After renaming it, everything worked.
I'm having problems running the scala-android plugin when running sbt from inside IntelliJ. When I run sbt for the same project from Mac terminal I get no errors:
~/Documents/my-android-project $ sbt
[info] Loading global plugins from /Users/rgoodwin/.sbt/plugins
[info] Loading project definition from /Users/rgoodwin/Documents/my-android-project/project
[info] Set current project to (in build file:/Users/rgoodwin/Documents/my-android-project/)
But when I try to run sbt from IntelliJ I get:
[info] Loading global plugins from /Users/rgoodwin/.sbt/plugins
[info] Loading project definition from /Users/rgoodwin/Documents/my-android-project/project
[error] Android SDK not found. You might need to set ANDROID_SDK_HOME or ANDROID_SDK_ROOT or ANDROID_HOME
[error] Use 'last' for the full log.
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore?
Why doesn't sbt inside of IntelliJ pick up the Path names I have set?
I think that you have probably set ANDROID_SDK_HOME in your .bashrc file so this property is set when you run sbt.
When you run Intellij, you don't launch it from command line so the ANDROID_SDK_HOME is not defined when you run sbt from Intellij.
For MacOS, I think that you can set global environment variables (take a look at http://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPRuntimeConfig/Articles/EnvironmentVars.html).