I followed their "how-to":
Phonegap Start
Phonegap wiki
I have succesfully installed the android sdk, but I can not install phonegap 1.3.0. I'm stuck at this step: Step 4. Build the Example PhoneGap App
4A. Open a command window and change directory ('cd') to the 'phonegap-android' folder. In Windows, use git bash as the command window. In Mac OS, use Terminal.
4B. Run the following command. This will create a PhoneGap.jar file and create a basic Android Eclipse project in the output path that can then be opened in Eclipse.
NOTE: The droidgap script has been updated and now there are two methods to create the necessary files. The new script is significantly simpler to use than the old method. For those who prefer the old method, it is still available.
NEW METHOD:
4C. From the 'phonegap-android' folder, run 'ruby bin/droidgap create [path_of_application]'. For the example app, the command would be 'ruby bin/droidgap create example'. If the example folder does not exist inside 'phonegap-android', run 'ruby bin/droidgap gen' first.
These are the steps that I have took:
I have downloaded the callback package from git (see wiki)
I run git bash --> cd to the phonegap-android folder
I run this command: 'ruby bin/droidgap gen'
Then I get: No such file or directory -- bin/droidgap(loadError) and idd the file isnt there.
I can't find droidgrap, who has the anser for me....... The old method don't work either, because I need droidgap for that one 2.
In the end I want to develop a Sencha web app for my android device. What did I forget.... :'(
The AppLaud Eclipse plugin documented on the PhoneGap wiki here eliminates the need for droidgap or any other configuration. Its wizard creates a fully configured PhoneGap for Android project.
(Note: I developed the AppLaud plugin)
Related
How easy is PhoneGap to build and deploy Android applications? The application I'm thinking of is not a beginner level app. How is the level of debugging and error handling and the support it gives?
Thanks in advance.
Deploying an app with Phonegap is quite easy. You can install Phonegap by using,
npm install -g phonegap#latest
and then create an app by,
phonegap create myApp
Refer the docs, PhoneGap Getting Started
When you create the app you will notice there is a directory called "WWW". All you have to do is copy a build of your existing web app to this directory.
All your assets and code in this directory will be used to build apps for the platforms you specify.
You can use Cordova to add the Android platform, which will be used to get an Android build out of your project.
Use,
cordova platform add android
Notice the directory "platforms". Inside it you will find another directory called "android" and this will be your Android project.
To build an Android app simply use,
phonegap build android
When you run the above command Phonegap will build an Android project using your code in WWW directory and place it in the platforms/android directory.
You can then use Android Studio to open the android directory which is an Android project now.
It's as simple as that and quite easy once you get the hang of it.
Then you can do all the regular debugging inside Android Studio using Logcat.
Helo,
I am currently trying to build the base phonegapp android app that's automatically created, so I navigated to the directory... but when I use the command
phonegap build android
I just get this random error, as shown in the attatched picture.
Extra info
I am currently on Windows 8, and am completely new to making apps, and am new to the command line as well. Not very familiar with this stuff...
What I'm trying to do would be called 'compiling', right?
Yeah, I had the same problem yesterday - but with a little help of a colleague I got it!
Step by step tutorial (for Windows)
Install node js
Install phonegap using command line: npm install -g phonegap
Install Android SDK
Launch Android SDK Manager and install Android 4.4.2 (API19)
Because latest phonegap/cordova version requires this
Documentation for Android SDK and SDK Platform should be enough
Also update already existing packages
Create an environment variable called ANDROID_HOME which points to destination of Android SDK. e.g. C:\Users\You\AppData\Local\Android\android-sdk
Download Apache Ant and extract the archive somewhere
Create an environment variable called ANT_HOME which points to destination where you have extracted Ant
Install JDK (Java Development Kit) for your System. Before you are able to download, you have to accept the licence
Create an environment variable called JAVA_HOME which points to destination of JDK
If you want to add plugins via phonegap automatically you should also install GIT.
Last but not least you need to add the following directories to PATH environment variable:
%ANT_HOME%\bin;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools;%JAVA_HOME%\bin
Each folder is separated by a semicolon
Setting environment variables will take effect just for new command line windows. So you should reopen it, after the whole process.
Easy, isn't it? ;-)
Now you can use phonegap build android after you've created a new phonegap project. If you have your smartphone plugged via USB and installed the USB drivers, and activated the USB Debugging on smartphone, you may use
phonegap run android
And the ready build APK will be transfered and executed on your smartphone. Perfect for testing.
If you want to create a final release APK, go to
YOURPROJECT\platforms\android\ant-build
and enter ant release.
You'll find the final APKs in YOURPROJECT\platforms\android\bin.
They are unsigned, here is a Noob guide to signing an APK.
I have tested a Barcode Scanner example, and it works seamlessly.
Have fun!
also check android in cmd, if it says: 'xcopy' was not recognized.
then add to your path:
%SystemRoot%\system32; %SystemRoot%; %SystemRoot%\System32\Wbem;
Armin's guide is perfect. But if you still fail you can do this.
Phonegap platform files stay in C:\Users[username].cordova\lib folder. Go there and remove android/ios/bb... driectory.
For best result run this command:
npm cache clear
After that try again, clean platfrom files will be download and build your project.
I can't find something about this, I am create a cordova project with NodeJS/npm, see this link, But after create the project I will try to modify him, its like a normal thing to do.
I tryed to edit the file in:
C:\Program Files\nodejs\helloworld\platforms\android\assets\www\index.html
and run this code in console:
cordova emulate android
my files are reloading and my modifications are deleted, the application are deployed into emulator and I can't do nothing. How I can edit my project without this "reloader"? What I am doing wrong?
modify here
C:\Program Files\nodejs\helloworld\www\index.html
This modification will be automatically applied to the platform's asset folder after you build the project. And build project first before emulate
cordova build android
Im new with phonegap, cordova and android. Im on mac, recently i install all the needs:
Phonegap 3.3.0-0.19.6
Cordova 3.3.1-0.4.1
Got Android SDK and running on eclipse with no problem. Then create a new Android application on eclipse for phonegap successfully, and running on a phone with android.
Then i create another app with cordoba(terminal), put 2 platforms android and ios, i run prepare etc.. and then import the project(android) into eclipse. At this point the app runs ok, so i proceed to install some plugins for testing (Notifications and Device)
https://cordova.apache.org/docs/en/3.0.0/cordova_device_device.md.html#Device
When i run the app with eclipse the examples always return
Uncaught TypeError: Cannot call method 'alert' of undefined
And its the same with device. So looking over the internet i found that if i run $cordova prepare will work, then i run the command, then run the app on eclipse and it work but always when i install a new plugin for testing i have to run cordova prepare, and the problem is that index.html rewrite with example hello world and i loose my code.
Any help over here, im doing ok?, how to install those plugins and make the test and dont have to run prepare all the time. (Please think on eclipse, i dont what to use terminal all the time)
I had the same exact problem and other posts suggestions didn't work for me.
I solved it by switching the steps a bit, despite the official docs and other posts.
If I add ALL the files AND the core plugins BEFORE I add the platforms, then adding the platforms takes these things with it into the new folder structures AND only build once from the command line before I open the project.
If I need to add anything I do it again. Although I can edit the www files without going through the process again, I do not expect the root www to perpetuate the platform www's. I just copy it myself into all the www folders. It shouldn't be this way but I think this is a well documented bug with multiple command line builds, for now and thats my working fix.
The recommended way is to edit html/js/css... in the root www folder of the project, not in the platfotms/xxx folders.
The reason is that if you have multiple platforms, you just need to modify in one place and cordova prepare or cordova build or phonegap build will propagate your code to all the platforms and update plugins.
If you have only android platform and want to be able to change code directly in eclipse for the platforms/android/assets/www folder, I suggest you create a shell script to
copy all the content of projectroot/platforms/android/assets/www to projectroot/www
run cordova prepare android
Then, instead of running cordova prepare android, you'll just have to run your script after you add new plugins.
Edit
I think there may be a better way for your problem.
You should be able to use plugman to install your plugins instead of cordova.
First you need to install plugman cli : npm install -g plugman
then install a plugin using
plugman -d --platform android --project projectname --plugin nameorurlofplugin
http://cordova.apache.org/docs/en/edge/plugin_ref_plugman.md.html
I had these issues too.
One approach I use now is:
Edit the index.html in the platform folders which is platform/iOS/appname/www and so. Then add plugins using the normal terminal way using cordova plugin add but always run the project using Xcode for iOS and eclipse and not from the terminal because then you will lose your code.
From my experience when you run using .xcodeproj or say android project the www on the inside is used and if you use cordova run ios from terminal the www on the outside will overwrite the www in the platform folders.
If you get xcode errors saying can't find so and so plugin files just move them to the path the error says xcode expects them to be in.
So I've tried posting some of these issues on the Phonegap forum but have not heard from anyone regarding my issues...
I recently upgraded from PG 2.9 to 3.3 and am having trouble adjusting my project to the change... it should be as easy as installing phonegap 3.3 and creating a new project and dragging my /www to the root of the project and calling the cordova CLI commands to build and update my project-- both of which say that they complete successfully.
But it's not that easy! Instead, building and updating my project deletes the cordova2.9.jar and does not create a 3.3.0 jar... so I build it myself which goes fine. I stick it in my /libs folder and my app loads on my phone finally... The problem now is that running in PG 3 requires a change in how API calls are handled-- they are all plugins which you have to install before using them... so I installed all of the needed plugins...
The problem now is this message in logcat within Eclipse:
Unable to open asset URL: file:///android_asset/www/cordova/lib/cordova_plugins.js
so I find this cordova_plugins.js file in the root of my assets/www/ directory (Why is it here?! Shouldn't this be automated by cordova build & update to the correct location?!) So I try to copy the file to /www/cordova/lib/ where the error reports it is trying to find it.
When I do this, I get all of these errors:
Unable to open asset URL:file:///android_asset/www/cordova/lib/plugins/org.apache.cordova.file/www/DirectoryEntry.js
Unable to open asset URL:file:///android_asset/www/cordova/lib/plugins/org.apache.cordova.file/www/DirectoryReader.js
Unable to open asset URL:file:///android_asset/www/cordova/lib/plugins/org.apache.cordova.file/www/File.js
Unable to open asset URL:file:///android_asset/www/cordova/lib/plugins/org.apache.cordova.file/www/Entry.js
...etc (basically every plug-in that I had installed in the project.)
I am clearly missing something here... relocating these javascript files to the correct directory manually should not be what I need to do...
I should mention that this original error occurred when I was running the application in PG2.9 but the only plugins that I needed to use were included by default so I could still use the needed API functionalities.
Any ideas here?
You must need to create and deploy any phonegap project/application using Phonegap Command Line Interface
To Create any project write following command on command line:
$ phonegap create <path> <package_name> <project_name>
i.e.
$ phonegap create hello com.example.hello HelloWorld
To add any platform to your project:
cd <path_to_project>
$ phonegap build <platform>
i.e.
cd hello
$ phonegap build ios
$ phonegap build android
To add any plugin feature to your project:
cd <path_to_project>
$ phonegap local plugin add <path_to_plugin>
i.e.
cd hello
$ phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git