I just started Learnig Ionic and after a successful deploy of myapp (generate apk and install in my phone), i still get a web page error on my android device 'Could not connect to server (http://localhost:8080/)'
I believe the app should be offline because i haven't used any web service. check out the error here
The url http://localhost:8080/ would only work on the emulator but not on an actual android device.
Find the method webview.loadUrl() most likely on the MainActivity.java and change to something like webview.loadurl("file:///android_asset/www/index.html") instead of webview.loadurl("http://localhost:8080/");
Your app is offline.
A plugin that all Ionic apps have been using for ages, cordova-plugin-ionic-webview, released a new version 2.x on July 23rd 2018. This added a webserver into the Android app that is used to deliver your app files to the webview displaying your app. It runs on localhost:8080.
Unfortunately version 2 of cordova-plugin-ionic-webview does not support Android 4.x any more which you seem to be using. This is the eason why you are getting that error message.
You can probably fix your problem by downgrading to the last version of the plugin that supported Android 4.x:
ionic cordova plugin add cordova-plugin-ionic-webview#1.2.1
More elaborate information and alternative solutions:
https://ionic.zone/debug/ionic-and-android-4
Related
I can't run Android APK of my ionic apps on my tablets (Android version 4.4), I get the connection unsuccessful error. I have no idea why, it happens even if I start a ionic project from scratch and run the apk without modifying anything in the project. Weird thing is..I can run it on my Xperia celphone and also if I emulate a Nexus 9 tablet with android studio the Apk also works. How can I fix this? maybe build the apk with older android api? is there a way of doing this, or isn't this related?
Already tried setting loadUrlTimeoutValue to a high number, makes no difference.
Aaaaaaaaaaaaaaaaaaaaaaaaah finally got it FFS, had to add cordova crosswalk plugin to make it work. Followed this > https://github.com/codyteng/ionic2-android-crosswalk
ionic plugin add cordova-plugin-crosswalk-webview
ionic platform add android
ionic run android
When I am trying to run app on android device using ionic run android, it is showing the build and launch as successful.
On device, it is showing
app_name stopped working
I searched a lot and tried installing plugins again, not working. I'm not using ionic-keyboard plugin. Any help would be appreciated.
UPDATE: When I'm using ionic serve --lab, it is showing perfectly on browser with some of the plugins not working because browser doesn't support all the cordova plugins. That's fine.
ionic platform add android shows at the end
saving platform to package.json file
believe something to do with ionic-keyboard. can you try installing keyboard plugin once and checking the app if it works or not. Thus we will have some RCA.
Can't run Ionic on Android: class not found exception IonicKeyboard
I just recently installed apache cordova and am trying to get it up and running properly. I'm using a macbook pro running 10.9.5. My android SDK is the latest (22, but android target build uses 21). The cordova version is the latest as well (4.3). This issue occurs with any example app that I've tried, including the basic app/page that gets installed when you create a new cordova project (i.e. cordova create...).
For the most part, everything seems to be working ok, with one exception. When I try to view the android version of the test app in a browser (any browser - tried chrome, firefox, safari), I get various prompts that show up on the init/load of the app. The first prompt window to popup up says "gap_init:2", which is generated from the androidExec function in the cordova.js file:
androidExec.init = function() {
bridgeSecret = +prompt('', 'gap_init:' + nativeToJsBridgeMode);
channel.onNativeReady.fire();
};
If I cancel thru these prompts (there are 3 prompt windows), then the app seems to load ok. If I 'ok' thru these prompts, then the app gets into an infinite cycle of processing empty messages, and I have to kill the browser processes to stop it.
The iOS version of the app loads fine in every browser. I've tried changing the android target to version 19, but the prompts still occur. There are no error messages during the build process.
Does anyone have any insight into what might be causing this? How is this prompt message supposed to be caught/handled?
Its simple, from visual studio, on running, it opens web pages for Android /iOS environment, you would have tried to cut-short the url to open for web version, this is when you will get dialog's as you mentioned.
To overcome this problem map the www folder to your local iis / iis express and open the url, page will open without any error.
This error you get when you use the following command directly as follows:
ionic serve
and then followed by
ionic cordova build android --prod --release
I SUGGEST TO FOLLOW THIS METHOD, IF YOU WANT TO RUN THE APP IN BROWSER
ionic serve
ionic build
ionic build --prod
This way you get www folder where you can upload to server and check the whole app in browser directly
I'm trying to make a Phonegap app for android and I have a problem that I can't figure out...
I used this tutorial for my first plugin http://devgirl.org/2013/07/17/tutorial-how-to-write-a-phonegap-plugin-for-android/ (I didn't copy past the code) and I created a plugin that works.
The problem came up when I moved the "web application" from the android device to my computer, ran in on apache and loaded the url on the device... The page comes up just fine and I get the "Device ready" message, but my plugin does not work...
Do I have to do anything differently if I want to run an external url?
I am building a Sencha Touch application that I then build using PhoneGap. When I installel the application on my android device for testing I got a strange prompt box asking me to provide a gap_bridge_mode?! What is this and how do I get rid of it (the prompt).
In my current situation I just click the Ok button without providing any value and all works fine. However I cannot release the application with this thing "welcoming" the user.
Please, help!
I think I found what the problem was. In my phonegap config file I indicated the use of phonegap 2.0.0 - the latest available version on the build server - while in the index.html I was loading the 2.1.0 - the latest version available for download.
After I changed index.html to point to version 2.0.0 I don't get this message anymore.
Thanks for the help.