I am developing a cross-platform app with Phone Gap, Jquery Mobile in Android using eclipse. I am not at all using any PhoneGap functions in my app. My purpose with PhoneGap is to build native apps for ios, Android, windows etc from Adobe PhoneGap build service. Under android assest/www/ folder I created multiple sub folders like css,js,html etc, where I put my jquery mobile html,css,js files and my custom js,html,css. Note under www directory I have cordova.js and index.html, cordova jar also included in build path. My app is working fine, when I run it in eclipse + Android emulator. It is generating valid apk and opening my app root page welcome.html, which is under www/html/welcome.html. The problem is when I generated android build by uploading my code to Adobe PhoneGap Build service, it is giving valid apk, which after installing opening index.html, which is under www/index.html. I my DroidGap actvity, i am loading welcome.html only.
super.loadUrl("file:///android_asset/www/html/welcome.html");
any suggestions plz. I need to have multiple html pages and folders under www directory because some design restrictions.
I am not sure if I uderstood what you mean.
Perhaps you could try:
$.mobile.changePage('./html/welcome.html');
Add this to your javascript event's listener, it should work.
For Phonegap Build to work, all your generic src files need to be in www of the base directory. Any Android specific files go in /www/res/android or /merge. See phonegap and/or codrova documentation.
One of the problems with using Eclipse and Phonegap together is that if you imported your project as an existing Android project, then all work you do is in the Android platform directories, not www.
Main reason why I now use Netbeans with Phonegap 3.0 CLI:
In terminal:
phonegap create [project dir name]
cd [project dir name]
phonegap local build android
add plugins
replace generic phonegap /www files with your project specific files & dirs
In netbeans IDE:
new project -> html5 -> use current src code
tweak /www/context.xml app name, ......
.......
In terminal:
adb connect 192.168.1.??? [Android-X86 in VB guest]
adb devices [are devices showing?]
phonegap local run android [build and installs to VB Android-X86 guest]
debug ....
phonegap remote build android [use Adobe Phonegap Build]
.......
Note: new Netbeans 7.4 RC2/Development includes Cordova development. Tried, but while has some interesting features, seemed to include the kitchen sink when doing initial build. Very slow to compile. Disabled feature. Also background scanning chokes. Turned off with plugin, but remember to manually rescan project files, especially if did work outside IDE. Couldn't set up Android-X86 in VB as my emulator. Why I use the above workflow.
Peter
By default the index.html, or in this case, welcome.html, should be located in the root of the www directory. Since it is not the case, you could try to add the following tag in your phonegap/cordova config.xml file
<content src="html/welcome.html" />
my suggestion is that you copy all the contents of welcome.html to www/index.html and let the default super.loadUrl("file:///android_asset/www/index.html"); as it is. you can later switch views using window.location.href='html/anypage.html';
i have the same kind of problem. i am converting my html website files in android studio. so, under the assets i paste my website folder.. how can i run all the html files i imported? i used the code webView.loadUrl("file:///android_asset/anamayyy/main.html");
and it only shows the main html. the links that i used as button doesnt work..
the links as buttn for next page doesnt show(webpage not available
Related
I want to convert my app into a hybrid app using phonegap build.
How do I do that?
I see different setups in basically every tutorial.
In this one, there is not a single platform folder, just the usual img/css folders, plus the config.xml
In many other tutorials I see a folder structure like www, platforms, etc. with the andorid and ios platform code.
How do I setup my phonegap project??? Do I need the platform, do I not need the platform, do I need the cordova.js, do I not need it??
It seems information about this is somewhat contradictory and often outdated.
E. g. I created my app using these steps.
Which does create all those folders like www and platform, however, the app doesnt install correctly after I built it with phonegap build. So something must be configured wrongly... I mean, it's there OWN site and it fails!
What is the correct folder structure that I need to convert my app into a hybrid app that will run on iOS, android and windows phone, using phonegap build?
It depends on whether you plan to use PhoneGap to develop or only to compile (Phonegap Build).
I will show how I used until a little time ago.
I used to develop an Ionic project and made all the development with it. When I needed to test something on the phone, I was using the Phonegap Build.
Both projects have the folder "www". To use Phonegap Build site, I was replacing the folder "www" of Phonegap project with the "www" folder of Ionic project. Then just send the Phonegap project ZIP to Phonegap Build site. This always worked for me.
After creating the project (phonegap create my-app), basically you do the project at "www" folder and configures preferences in config.xml (fullscreen, plashScreen, android-minSdkVersion, etc).
If you use Phonegap Build site you donĀ“t need to add platforms (platform phonegap add) and not need to run "phonegap run android"
PhoneGap Build's only requirement for your application structure is that the config.xml and index.html is in the top level of your application.
Make test:
- phonegap create my-app
- configure config.xml (If necessary, not required)
- config.xml and index.html in the same folder (preferably in www)
- ZIP
- Upload ZIP on Phonegap Build
I run my phonegap app (phonegap run), but what I saw was a simple Hello World app.
In my project's directory I have files:
hooks/
platrofms/
plugins/
www/
config.xml
In www directory I have all files that are related to my app.
And when I phonegap serve I can see what I want under given address on a web browser.
I don't know wy on my smartphone I have only HelloWorld app with a blank screen, when launched. Could someone will be able to give me some tips, please?
Add platform Like this :
phonegap platform add android
in your project directory path using terminal.
I am working on a cros platform phonegap app. Basically it is working on Android,iOS, Windows phone. Usually i am doing edits on root WWW folder and run terminal command
phonegap run android
phonegap run iOS
It creates projects for each platform. But if i do a platform specific change in native code , "run" command will replace changes. Is there any standard way to sync changes.
While developing an app based on sencha touch 2.1 and cordova/phonegap 2.2.0, I have noticed a strange behavior by netbeans.
When my App become bigger, I started to use sencha cmd (3.0.0.250) to minify (production build) my js-css-html code. So I created a batch file and added it to the build.xml (pre-compile). I also edited the activity class to point to the sencha cmd build output. So in the Assets/www path there is my "readable" js, html, ... code and also the minified code.
Now When I build the app, the apk file is up to 8mb.
But when I delete the "readable" js-html-css code before build (also don't use a batch script) then the size of my apk is only 600kb.
In both cases the performance is the same.
Is this a normal behavior of Netbeans? How to avoid that?
Now i understand this behavior. all files within assets/www are put into apk.
my project included all (sencha stuff, phonegap stuff). i think splitting them is better. Now i have a project, that containing the js/html/css stuff - e.g. fast debugging with chrome. for every target platform i have a own project (using for build). e.g. android-10, android-15, ios ... i make us of some ant pre-compile commands to first build sencha, than copy output and finally build the apps.
I have been investigating Phonegap as a method of deploying an app to both Android and iOS. However, it seems like depending on what device you are programming for, there is a different set of instructions.
How do I set up something where the 'project' for both Xcode and ant are in separate directories but they both point to the same set of common assets? And how do I version control this...what should I .hgignore and what is necessary to keep around?
We generally have a www folder with the html, js, css etc for your app and a folder next to it that contains the xcode project and android project then write a simple script to copy the www code into the platform specific projects ... some of this is made more simple with tools like github.com/brianleroux/cordova
You could also check out build.phonegap.com