Phonegap open android files - android

I can't seem to figure out how to open up my android phonegap project in eclipse. I need todo this because I need to customize some android settings and files specifally to install facebook connect on phonegap 3.0.0. The app runs fine on my emulator, but the problem is that I can't find the local android files to open in eclipse. With ios its easy, you go into platforms/ios/projectname.xcodeproj and it opens your ios build in xcode. With android, it's nothing like this. I'm using this tutorial btw: https://github.com/phonegap/phonegap-facebook-plugin/tree/3.0

The Android Platform Guide has instructions on how you can use an IDE (eclipse) with Cordova 3.0.0 and the command line:
Use the command line to set up the new project:
$ cordova create hello com.example.hello "HelloWorld"
$ cd hello
$ cordova platform add android
$ cordova build
After that, open up Eclipse, select "New Project", hit "Android Project from Existing Code", and navigate to the hello/platforms/android folder that was created. This should load the project into your Eclipse workspace and you should be able to edit the Android files just like in the pre-3.0.0 days.

Related

What is correct way of setting up phonegap project?

I have setup phonegap for android on my machine.I have searched over net and come with two different solutions for starting android project in phonegap
(1) Using Command Line Tool for creating project
phonegap create myFirstApp
cd myFirstApp
and then importing project in eclipse
(2) Directly from eclipse IDE
Choose New > Android Project and then filling necessary information
Now question is which should I use, and which one is better for starting phonegap project for android?
There is obviously, no single answer. You can use any, whatever you are interested in. Also, you can write your entire code in the www folder and may not open Eclipse at all.
Personally, I connect my android phone with USB debugging on, and whenever I feel like testing my app, I type in the command in the terminal
$ cordova run android
If you have configured a Virtual Machine, it will start the virtual machine or the app is installed directly on my device.
The correct way is
3) Using Command Line Tool for creating project
phonegap create myFirstApp
cd myFirstApp
Use any editor to edit the www folder (brackets, sublime)
Use the CLI to run, build, etc.
Forget about eclipse.
According to the Documentation the best way is as follows:
$ cordova create hello com.example.hello HelloWorld
$ cd hello
Then to add platforms:
$ cordova platform add ios
$ cordova platform add amazon-fireos
$ cordova platform add android
$ cordova platform add blackberry10
$ cordova platform add firefoxos
And run the app
$ cordova emulate ios
And build the app
$ cordova build ios

Error on creating an android project using Cordova and Sencha Touch 2

I am unable to create an android project using cordova in command line. I have followed the following steps and while executing this command "cordova platform add android", I get the following error.
Also, I have downloaded the android SDK files and kept it in a separate folder, and mentioned its path (platform-tools and tools) in the system variables. The Project folder is being created, but could not specify the platform as android. PLEASE HELP !! It would be very helpful if someone explains building an android app using cordova (apart from CORDOVA DOCUMENTATION) easily under few steps. Thanks in advance.
Steps followed:
npm install -g cordova
cordova create hello com.example.hello "HelloWorld"
cd hello
cordova platform add android
Error received:
" Please install Android target "android-19"
Hint-Run "android" from your command line to open the SDK manager "
If you're building an app with Sencha Touch, then you need to use Sencha Cmd to add cordova to your project. First, download from the Sencha website. Then, assuming you've already created your Sencha Touch project, switch to your Sencha Touch project directory and do the following from the command line:
Add a cordova project to your Sencha Touch project
sencha cordova init
Add a platform to your cordova project
cd cordova
cordova platform add android
Change back to the Sencha Touch directory and build and run
cd ..
sencha app build -r native
Follow these steps to create a Sencha Touch 2 app with cordova support for packaging.
Once you have installed Sencha CMD and downloaded the Sencha Touch 2 SDK, run the following:
sencha -sdk [path to sencha sdk] generate app [name of app] [root folder for your app]
sencha cmd will create a folder for you if you have not created one yourself)
From inside the newly created folder, run the following to initiate cordova (you can replace cordova with phonegap and it should work fine):
sencha cordova init
A folder named 'cordova' will be created. From inside this folder, run the following to add android platform:
cordova platform add android
(keep in mind that the latest Android SDK must be downloaded and that you have the 'tools' and 'platform-tools' folders in your path. You can check this by running the command 'android' from the same terminal tab in which you're running sencha commands)
Go back to the root folder of your app, edit the 'cordova.local.properties' file and set the platform to 'android'.
From inside the root folder of your app, run the following to build an aPK:
sencha app build native
For me, the apk file is found under /cordova/platform/android/ant-build/
This APK should install and work fine.

Trouble getting first PhoneGap Android app to run

I'm a new user of PhoneGap. My platform is Windows 7 64 bit. I've followed the instructions on the Cordova site and have Node & PhoneGap installed. I already have Eclipse and the ADT installed from my previous work with developing Android apps with Java.
Following the steps at http://cordova.apache.org/docs/en/2.5.0/guide_getting-started_android_index.md.html I'm half way through step 4. I've successfully created the my skeletal hello world PhoneGap app. How exactly do I make an Eclipse project out of it however? The generated files do not seen to include the standard Eclipse .project file. It is not clear from the instructions which exact "new project" menu option to choose.
Thanks if anyone can help.
After creating cordova project through command line, I'm assuming you have added platform using cordova platform add android
Then to load project into eclipse, do this
Eclipse> file > import >Android >Existing acdroid code ..... > Root
directory (Browse button...... Browse to this folder
[yourcordovaproject-platforms-android] select this android folder)>
Check both your project name & cordovaLib > Finish
I figured it out. I had jumped ahead to the "create Android app." step without having run the "cordova platform add android" step first. I ran the add android step, and that did generate the Eclipse project files I needed.

Upgraded to Phonegap3, project does not load needed plugins correctly

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

How to Build and run the cordova project with eclipse and run project for android

I have created the project with cordova CLI but i do not know where i need to change and how to run the cordova android project with eclipse for each platform. Thanks for helping
Before run the android project inside your Cordova Project you should know these things.
If you are making any changes in the Cordova Project then first you need to prepare the cordova. use the command cordova prepare
Then it changed in your config.xml (for android) automatic as you added or any changes you made. Do not make any change in your android project which exist inside your Cordova project. You can only make change inside the www folder of your Cordova project. And after made changed you need to make cordova prepare every time.
After prepare the cordova you can run the android project on device or emulator. For this you make sure you have made the path of android sdk for platforms-tools and tools in your environment system. If you not configure this path and add this two path in system environment .
Now run the android project on device use command cordova run android and run on emulator use this command cordova emulate android.
And if want to run on eclipse then you should import this android project of your workspace in eclipse. But if you again made changes in your cordova project then need to delete and again import the android project this switching happened every time so better to run through CLI.
I hope you got all things
Sunil's answer is good. I would like to add logging using Android Debug Bridge(adb).You may want to run:
adb logcat on a seperate shell window for logs after running cordova run android you need when you run into errors.This will produce huge logs, so I would recommend using:
adb logcat|grep Cordova

Categories

Resources