ionic2 API Call issue - android

I am working on an Android application using Ionic framework version 2. The app makes an http request to an url, gets the json and displayes the data on the screen. Its a very simple and basic application. With CORS plugin on my chrome, things went smooth. But once i build the apk and run on the device, it doesn't seem to work. I have followed all the suggestions provided in various URL's for the cordova whitelist plugin. But nothing seem to resolve my issue and it is very annoying. Things i did on my end
Step1:
cordova plugin add cordova-plugin-whitelist
Step2:
cordova prepare
config.xml
index.html
While executing the step 1, i got an error unexpected token. But i could see the plugin files are added in the project. Could that be a proble?
In the App Debug log i see this -
SystemWebViewClient: URL blocked by whitelist: http://.com

Related

Ionic InAppBrowser issue

I have an Ionic App where I use AR.js and i have access to the camera. The web version works fine. I build an Android version with capacitor and I use InAppBrowser to access the site where i host the web app. But when i try to run the AR inside of the inappbrowser, I get an error of 'Permission denied' and it won't work. I've tried the plugin 'AndroidPermissions' as well as adding <use-permission> in the AndroidManifest.xml but still nothing. Any help would be appreciated!

Ionic Webpage error after Android apk

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

Ionic: Admob is not defined error and infinite loading on Android app, iOS is fine

I put admob into my ionic app. It works fine for ios, but I keep on getting "admob is not defined" error for android and see no ads when I run it on an android phone.
I added and removed the cordova plugin a few times: ionic plugin add cordova-plugin-admobpro
I also added and removed and readded the android platform from the app, didn't work.
I also added and removed: cordova plugin add com.google.playservices, didn't change
The other problem is once I take all the admob stuff out of my code and completely uninstall the plugin, it causes (I am using parse server) parse initialize issues in the same locations as the admob issues in the error below, and the android does infinite loading, the ios app works fine.
Any ideas please? I've been stuck on this for a bit.

Getting gap_init on new apache cordova install when viewing android app in browser

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

Cordova and google maps

Well im trying to make simple app which will display map and user location i did everything like in this tutorial http://kendrickcoleman.com/index.php/Tech-Blog/phonegap-cordova-geolocation-integration-with-google-maps-javascript-api-v3.html
I have downloaded cordova.js from github i have correct key and all i can see on my avd is grey-white screen without any map, coudl someone give me a clue what shoudl i change ?
shoudl i add anything to android manifest or to config file ?
Battled with the same issue for 3 days only to discover that http request are blocked in the latest Ionic except a the cordova whitelist plugin is added.
To add whitelist plugin, run the following command:
ionic plugin add cordova-plugin-whitelist

Categories

Resources