PhoneGap installation issues - android

I am trying to setup PhoneGap on a new Windows 7 machine. Downloads and installs all go fine. In a command prompt I type java, adb, android and they respond correctly, but when I run the ant command it gives me
1. ant is not recognized as an internal command, operable program or batch.file
also
when I follow the PhoneGap documnentation path syntax for Windows:-
C:\path\to\cordova-android\bin\create.bat C:\path\to\my_new_cordova_project com.example.cordova_project_name CordovaProjectName
I receive the following following prompt:-
The filename, directory name or volume label name syntax is incorrect.
I am not to sure where to go from here as I have also appended JAVA_HOME and ANT_HOME to my environment variables when I run create.bat with the variables.
I am using PhoneGap 2.9.0 (have previously used PhoneGap 2.9.1), eclipse/ADT and Win 7.

Related

flutter is not recognised even after setting environment variables

When I do "flutter doctor" on cmd this is the error I receive:
where' is not recognized as an internal or external command operable program or batch file unable to locate git
Note that git --version gives me git version 2.28.0.windows.1
These are the things I tried
1.Reinstalling git
2.Updating Powershell to 5.0 as I run windows 7 SP1 and flutter requires Powershell 5.0 and greater
3.Tries resetting path variables
Here are my path variables.
USER ENV VAR:
C:\Program Files\MySQL\MySQL Shell 8.0\bin\;C:\Users\DELL\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\DELL\AppData\Roaming\npm;C:\src\flutter\bin
SYSTEM ENV VAR:
C:\Program Files\Java\jdk-14\bin;%PYTHON_HOME% ; C:\Users\DELL\AppData\Local\Programs\Python\Python37;C:\Program Files\MySQL\MySQL Server 8.0\bin;C:\Program Files\nodejs\;C:\Program Files\Git\cmd;C:\Program Files\Git\bin\git.exe;C:\Windows\System32 ;%systemroot%\System32\WindowsPowerShell\v1.0\
I am not able to find where exactly I am going wrong.
I am new to this.Any help would be appreciated.I have been trying this from 3 days nothing helps.
UPDATE
ADDING FLUTTER PATH TO SYSTEM VARIABLE WORKED FOR ME . Though now I have another set of issues as you can see in the image.I have android studio installed ; Have installed the dart and flutter plugin.Still I am getting the error
Make sure this path of flutter %/flutter/bin exists in the environment variable and you have restarted the terminal (maybe the system also).
Update :
Can You run flutter doctor -v using flutter_console and show us the error message:
Comparing with my enviroment variables it seems like you don't have java jdk installed, otherwise i see no problem . However i will share my variables . Another way of finding what is wrong is opening cmd in the flutter folder and lanuching flutter_console.bat inside the cmd, that way it will not close and it will show the error if there is any
USER ENV:
C:\Users\USER\AppData\Local\Microsoft\WindowsApps;C:\Windows\Microsoft.NET\Framework\v4.0.30319;C:\Users\USER\AppData\Local\Programs\Microsoft VS Code\bin;D:\flutter\bin;C:\Users\USER\.gradle\wrapper\dists\gradle-6.1.1-all\cfmwm155h49vnt3hynmlrsdst\gradle-6.1.1\bin;C:\Program Files\Java\jdk1.8.0_261\bin;C:\Users\USER\AppData\Local\Android\Sdk\tools\bin;
SYSTEM ENV:
C:\Program Files (x86)\Common Files\Oracle\Java\javapath;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;%SYSTEMROOT%\System32\OpenSSH\;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files\Git\cmd

'node' is not recognized as an internal or external command error with jenkins

I am trying to set up continuous code integration with the help of jenkins v1.592
I have an android hybrid code, which I'm, trying to build with jenkins.
I have set up environment variables for ANT_HOME, JAVA_HOME, ANDROID_HOME, and added then to the PATH respectively. I also have added nodejs and npm to the PATH.
ant version 1.9.2
java version 1.8.0_25
npm version 1.4.28
cordova android version 3.5.1
C:\Users\userName>path
gives
C:\Users\userName\AppData\Roaming\npm;C:\Program Files\nodejs;C:\whateverElse...
jenkins $WORKSPACE = C:\Program Files (x86)\Jenkins\jobs\myProject\workspace\
now I set my cmd prompt to jenkins workspace and execute the following commands
cd myProject
cordova build android
I get BUILD_SUCCESSFUL after 24 seconds
Similarly, when I go to my local jenkins server
The jenkins dashboard is shown and I have set up myProject there and
in the project configuration I have added the lines
"cd myProject
cordova build android"
in the build step and saved the configuration.
When I try to build I get the following error
Started from command line by anonymous
Building in workspace C:\Program Files (x86)\Jenkins\jobs\myProject\workspace
Updating repository at revision '2014-12-02T15:20:23.437 +0530'
At revision 263
no change for repository since the previous build
[workspace] $ cmd /c call C:\Windows\TEMP\hudson3297478415472069526.bat
C:\Program Files (x86)\Jenkins\jobs\myProject\workspace>cd myProject
C:\Program Files (x86)\Jenkins\jobs\myProject\workspace\myProject>cordova build android
'node' is not recognized as an internal or external command,
operable program or batch file.
Build step 'Execute Windows batch command' marked build as failure
Archiving artifacts
Finished: FAILURE
Any help would be appreciated
The same issue exists on mac OSX
Best Regards
Several things can be at play here
Did you add node to %PATH% through command line, or through the Windows UI? If done through UI, it can take affect immediatelly. If done through command line, it doesn't take affect until the next process spawns from shell, therefore Jenkins server restart is required.
Jenkins runs as "Local System" by default on Windows. You are listing C:\Users\userName as part of your paths, i.e. a user specific path. Did you set the %PATH% for all users, or just for your user userName? If it's not set for all users (or a specific user that Jenkins runs with), then Jenkins won't see it. You can change what user the service runs as.
2a. If Jenkins is running as "Local System" user, does that account have access to C:\Users\userName?
And lastly, if you set the %PATH% from command line, did you set it as a permanent entry using setx command?
In either case, from your job configuration, add a build step "Execute Windows Batch Command" and type just set (to display all environment variables) or #echo %PATH% (to see just the %PATH%) and verify that the environment is set correctly

Phonegap - Setting up Phonegap

I have installed the Phonegap using
$ npm install -g PhoneGap
And I have created the Project too.
After that I did
$ PhoneGap build android
It gives
[phonegap] detecting Android SDK environment...
[phonegap] using the local environment
[phonegap] adding the Android platform...
I am stuck with this screen for a lot of time.. I closed cmd and opened again and tried.. But again it stands on the same screen for lot of time..
I have installed Node.js and I have android SDk too. Please help
Thanks in advance..
EDIT:
I closed again and opened.. It gives
Error : C:\Users\Kutty.cordova\lib\npm_cache\cordova-android\3.6.3\package\bin\create.bat: command failed with exit code 8
Please help..
My Path : C:\Users\Kutty\AppData\Roaming\npm\;%ANT_HOME%\bin
A) Software required:
1) MAC : [For both iOS, Android]
a) Android Studios [For Android]
b) ANT 1.8.1
c) NODE.JS
d) Xcode 5.1 and above [for iOS]
2) Windows :
a) Eclipse ADT Latest [For Android]
b) ANT 1.8.1
c) NODE.JS
B) Steps to install Phonegap/Cordova:
1) MAC:
Open Terminal
a. Install Android Studios
Setup
your PATH environment variable on Mac OS
a. Open the Terminal program (this is in your Applications/Utilities folder by default).
i. Run the following command
$ touch ~/.bash_profile; open ~/.bash_profile
This will open the file in your default text editor.
You need to add the path to your Android SDK platform-tools and tools directory. In my example I will use "/Development/android-sdk-macosx" as the directory the SDK is installed in (For Android Studios, it can be found in /Users/<user>/Library/Android/sdk/ by default). Add the following line:
$ export PATH=${PATH}:/Development/android-sdk-macosx/platform- tools:/Development/android-sdk-macosx/tools
Save the file and quit the text editor.
Execute your .bash profile to update your PATH.
$ source ~/.bash_profile
Now every time you open the Terminal program your PATH will include the Android SDK
sudo npm install -g cordova
Create a new app
$ cordova create <directory name> <bundle identifier> <name of project>
$ cd <directory name>
$ cordova platform add android OR iOS
$ cordova run android OR iOS
If you come across problem of Please install Android target "android-19" then run android from Terminal. It will open up Android SDK manager and from there install Android 4.4.2 (API 19)
2) Windows:
Open Command prompt
a. Put ANT [Downloaded folder] folder into “android ADT folder”/sdk
Setup your PATH environment variable on Windows
From the Desktop, right-click My Computer and click Properties.
Click Advanced System Settings link in the left column.
In the System Properties window click the Environment Variables button.
Select the PATH variable from the System variables section.
Select the Edit button.
i. You need to add the path to your Android SDK platform-tools and tools directory. In my example I will use C:\Development\android-sdk- windows as the directory the SDK is installed in. Append the following text into the text box:
ii. ;C:\Development\android-sdk-windows\platform- tools;C:\Development\android-sdk-windows\tools
iii. Save your edit. Close the Environment Variables dialog.
Additionally, you may need to include %JAVA_HOME%\bin to your PATH as well. To check to see if this is required, run a command prompt and type java. If the program cannot be found add %JAVA_HOME%\bin to the PATH. You may need to specify the full path instead of using the %JAVA_HOME% environment variable.
Finally, you may need to include %ANT_HOME%\bin to your PATH as well. To check to see if this is required, run a command prompt and type ant. If the program cannot be found add %ANT_HOME%\bin to the PATH.
You may need to specify the full path instead of using the %ANT_HOME% environment variable.
sudo npm install -g cordova
Create a new app
$ cordova create <directory name> <bundle identifier> <name of project>
$ cd <directory name>
$ cordova platform add android
$ cordova run android
I also tried ,there is a problem in phonegap updated version .
run the following commands in command prompt
npm uninstall -g phonegap -> to unsinstall
npm install -gphonegap#4.2.0-0.24.2 -> to install specific version.
Now use whatever sdk you have,it will work.
PHONEGAP Manual Method
Another method is placing the things manually, and how it can be implemented is shown
below:
• set up the normal Android Application Project
• Create www folder inside assets
• download the phonegap zip file
• copy the phonegap jar file from downloaded phonegap place into libs folder
• copy the phonegap .js file from downloaded phonegap place into www folder that we
have created inside the assets.
• copy the xml complete folder and out into res folder of android
• create index.html file inside the www folder which is the gateway of the phonegap
application.
• Now we can transfer the control from MainActivity.java to our index.html which will
look like this:
"public class MainActivity extends DroidGap {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/index.html");
}
}
• open the AndroidManifest.xml file and paste the code that is shown in the picture.
Figure 4.1: Android Manifest File which allows permissions for device usage.
41
After writing this code, now whatever we code in the index.html file will be shown on the
android emulator or the phone.
PHONEGAP CLI Method
Phonegap Command Line Interface(CLI) Method can be called as automated method because
commands will do all the work for you to initialize the PhoneGap project that we have to set up
by yourself in the manual method. Following are the steps that need to be followed in order to
set up the PhoneGap project:
Download Nod.js and install it.
• Now run this command "npm install -g cordova" on Node.js, this command will install
the cordova module with the help of Node Package Manager(npm) for windows, where
-g states that installation of cordova globally.
• Another command "cordova create first com.example.First FirstProgram", this command
will take little processing tim, the argument first will determine the directory of the
project, second argument com.example.First gets a package and the last argument
FirstProgram is define the application title.
• This command "cd first" will give the control inside the cordova project.
• Now this command "cordova platform add android" , it will set up the target platform
on which platform you want to install this application, other commands for several
platform are described below:
• Cordova platform add wp8cordova platform add windows
• cordova platform add amazon-fireos
• cordova platform add blackberry10
• cordova platform add Firefox's
• "cordova platforms ls" command will check the current platforms and we can also
delete the platform by "cordova platform rm amazon-fireos"
• Now the process come on the building block of application by running the command on
console " cordova emulate android".
42
• Finally this command will run the basic application "cordova run android" and the
settings of the folders like www in assets and all other things in AndroidManifest.html is
setup according to the phonegap project.
add android sdks 'tools' and 'platform-tools' to path variable.
Keep in mind if you have installed 'phonegap' always use 'phonegap' instead of 'cordova' anywhere.
I personally prefer using cordova.

An error occured during creation of android sub-project

I installed cordova e phonegap via npm install -g cordova and npm install -g phonegap respectively. Then i created a HelloWorld application via cordova create HelloWorld mynamespace.helloworld HelloWorld. It worked fine! Then i changed my working directory to HelloWorld and i tried to build the app for android via cordova platform add android -d but it didn't work. here is the output:
Installing cordova library for android...
Requesting {"uri":"https://git-wip-us.apache.org/repos/asf?p=cordova-android.git;a=snapshot;h=3.3.0;sf=tgz"}...
Downloading cordova library for android...
Downloaded, unzipped and extracted 541065 byte response.
Download complete
Installing cordova library for android...
Checking if platform "android" passes minimum requirements...
Creating android project...
Running bin/create for platform "android" with command: ""C:\Users\marcos.pacheco\.cordova\lib\android\cordova\3.3.0\bin\create" "C:\Dev\HelloWorld\platforms\android" "mynamespace.helloworld" "HelloWorld"" (output to follow)
C:\Users\marcos.pacheco\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:126
throw e;
^
Error: An error occured during creation of android sub-project.
at C:\Users\marcos.pacheco\AppData\Roaming\npm\node_modules\cordova\src\platform.js:244:30
at exithandler (child_process.js:633:7)
at ChildProcess.errorhandler (child_process.js:649:5)
at ChildProcess.EventEmitter.emit (events.js:95:17)
at Process.ChildProcess._handle.onexit (child_process.js:787:12)
I've googled and have found some issues with whitespaces but my project is in the C:\Dev\HelloWorld path and my android sdk is in the PATH so that when i type adb at the windows prompt i get the help information of the command as well Java and Ant. Furthermore, i have ANT_HOME, JAVA_HOME and ANDROID_HOME set. I also deleted the ** .cordova ** folder inside my %HOMEPATH% directory and entered the command again but the error is still there.
What might be wrong?
XCOPY needs to be defined and found on your path as it is used by the internal node.js scripts to move things around.
You probably already have xcopy.exe somewhere on your machine. You should be able to add %SystemRoot%\System32 to your PATH and it will work. Or you can open up a terminal and type where xcopy to see the actual path to your xcopy.exe.
I guess having XCOPY on the path is a requirement for setting up and installing Android, but it'd be nice if Cordova checked to make sure you have XCOPY somewhere...

Cordova and setting Android using command line

I am trying to migrate my existing project from cordova 2.1 to the latest, 3.1 which can be installev vía command line,
I already have the Android SDK installed,
So:
sudo npm install -g cordova // All good
cordova create hello com.example.hello HelloWorld // All good
cordova platform add android // Then it fires:
Checking Android requirements...
[Error: The command `android` failed. Make sure you have the latest Android SDK installed, and the `android` command (inside the tools/ folder) added to your path. Output: ]
So I installed Macports and tried:
sudo port install android
Which logs:
Warning: All compilers are either blacklisted or unavailable; defaulting to first fallback option
Warning: Xcode does not appear to be installed; most ports will likely fail to build.
---> Cleaning android
---> Scanning binaries for linking errors: 100.0%
---> No broken files found.
Any idea what am I missing here?
It's work cordova Android for MAC 1000000000%. I fought solution and now i'm working try this #Toni Michel Caubet. I will happy to share my Answer.
STEPS:
Open Your Terminal and followed by,
touch ~/.bash_profile
open ~/.bash_profile
PATH="/Users/System-Name/Documents/android-sdk-macosx/sdk/tools:/Development/android-sdk-macosx/sdk/platform-tools:$PATH" (This is Android SDK Location to stored in My system )
4.Save the file and quit the text editor.
5.Execute your .bash_profile to update your PATH:
source ~/.bash_profile
if you want to see your environment path:
7.In your terminal type: set
After you can see like
8.As far as your made it very correct. After your enter command like cordova platform add android. you get following error. because Java SDK doesn't too set environment PATH.
9.open ~/.bash_profile. Add JAVA_HOME value
10.You can see your environment like STEP 7 set. You should be able see:
11.Successfully created environment now you can create Android project with Cordova or PhoneGap
When you installed the Android SDK, it will come with a bunch of folders, like build-tools, platform-tools, tools, and some others. You need to add platform-tools and tools to your main $PATH environment variable.
See the docs here about how to add things to your PATH for whichever system you are on (Windows or Mac): http://cordova.apache.org/docs/en/3.1.0/guide_platforms_android_index.md.html#Android%20Platform%20Guide
Here is how you would edit the $PATH on Windows:
Click on the Start menu in the lower-left corner of the desktop,
right-click on Computer, then click Properties.
Click Advanced System Settings in the column on the left.
In the resulting dialog box, press Environment Variables.
Select the PATH variable and press Edit.
Append the following to the PATH based on where you installed the
SDK, for example: ;C:\Development\adt-bundle\sdk\platform-tools;C:\Development\adt-bundle\sdk\tools
Save and close both dialogs.
To install the cordova command-line tool, follow these steps:
First of all go through the Cordova Document
For Cordova command-line tools to work, you need to include the SDK's tools and platform-tools directories in your PATH environment. On Mac, you can use a text editor to create or modify the ~/.bash_profile file, adding a line such as the following, depending on where the SDK installs:
export PATH=${PATH}:/Development/adt-bundle/sdk/platform-tools:/Development/adt-bundle/sdk/tools
Next Steps:
Download and install Node.js from Here. Following installation, you should be able to invoke node or npm on your command line.
Install the cordova utility. In Unix(Mac), prefixing the additional sudo command may be necessary to install development utilities in otherwise restricted directories:
For Mac $ sudo npm install -g cordova
once successful installation of cordova is done ,now you can create your application
across all the platforms.
Create the Cordova Application
Go to the directory where you maintain your source code, and run a command such as the following:
$cordova create hello com.example.hello CordovaDemo
hello is the directory where you want to create your application
com.example.hello is the package name
CordovaDemo is the name of the Application
Once Successful creation of your project, some file will be created inside the directory i.e hello
Add Platforms
All subsequent commands need to be run within the project's directory, or any subdirectories within its scope:
$ cd hello
Now you need to specify a set of target platforms, Supported OS for Mac
$ cordova platform add android
plz tell me if you are still having problem.
[Error: The command `android` failed. Make sure you have the latest Android SDK installed, and the `android` command (inside the tools/ folder) added to your path. Output: ]
You just need to install the Latest version of Android i.e 4.3
Go to SDK Manager and install the latest SDK Platform.
And try run the command again.
Hope this will help you.
Here it solved my issue:
into the terminal.
touch ~/.bash_profile (create a bash profile)
open ~/.bash_profile (opening a bash profile)
in your opened file, please type the following, Make sure that you have given the correct path, in case you find it difficult to find your directory in which your Android SDK is installed , search into your terminal with ls -l.
PATH="/Users/System-Name/Documents/android-sdk-macosx/sdk/tools:/Development/android-sdk-macosx/sdk/platform-tools:$PATH"
[Let me clarify first that, this is windows specific suggestion, answer]
For particular cordova version there corresponds particular android API
So,
First check out version of cordova with following command:
$ npm cordova -v
In my case cordova version was 1.4.28 , which corresponds to Android API 19
So the bottom line is don't waste time in downloading all "SDK Platforms"
instead just download corresponding Android API for concerned cordova version...
Hope this help....!!!

Categories

Resources