I am currently developing a cordova 4.3 android app in Visual Studio 2015 RC. It's an AngularJS app and I use $resource to send requests to an ASP.NET Web Api application running on a different port on the same computer. Debugging the app in Ripple works fine if I disable the Cross Domain Proxy but when I try to debug in the Visual Studio Android Emulator or on my Android device I get a not very helpful "Failed to load resource" as soon as try to reach the web api. The url looks correct and I suspect the problem has to do with either CORS or my HTTPS certificate or both? What I have tried so far is:
Set <uses-permission android:name="android.permission.INTERNET" /> and android:debuggable="true" in the manifest file.
Tried chrome://inspect/#devices to get more info about the problem but got the error message "Cannot load DevTools frontend from an untrusted origin".
I am able to connect my android phone chrome web browser to the localhost web api using the very helpful tool sharpproxy [https://www.codefromjames.com/wordpress/?p=97] but this approach unfortunately does not work with the app's webview.
The ajax request does work when I point the app to my azure hosted live web api endpoint where I have a valid https certificate but that is not very convenient to use while developing the app.
Made sure the config.xml-file contains <access origin="*" />
My web api is configured with app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll)
I am completely new to cordova/hybrid app development and am surely missing some obvious thing? Any help or suggestion would be very appreciated!!
After having all sort of problems with Visual Studio 2015 I uninstalled it went back to Visual Studio 2013 Update 4 and now I can connect my android device to a local running web api using sharp proxy I mentioned and linked to above.
So to be clear:
Use Visual Studio 2013 Update 4 to run your web api on for example the url https://localhost:44358/.
Start sharp proxy with external port 5000 and internal 44358.
Make sure your android device is connected to the same wifi and instruct your app to use https://your-ip-address:5000 for all service calls.
Related
I'm building a mobile app in React with Ionic and Capacitor.
I'm running a local server with a local API built with Strapi (a headless CMS) that is running on localhost:9000.
I'm having a hell of a time trying to connect my local API to my Ionic app on an Android emulator. The connection works fine on a development server on a web browser. My emulator can also access my local API on a web browser. My app, however, cannot connect to the API when it is running on an emulator.
Here's how I have proceeded so far:
in the .env file of my ionic-react app, I have set the URI to my local API. I have replaced "localhost" with my IP address :
REACT_APP_API_URL = "http://192.168.1.31:9000"
in the gradle.properties file of my app, I have added proxy settings:
systemProp.http.proxyHost=192.168.1.31
systemProp.http.proxyPort=9000
systemProp.https.proxyHost=192.168.1.31
systemProp.https.proxyPort=9000
in the AndroidManifest.xml file of my app, I have added two permissions:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Observations:
(✔️) When I run ionic serve to launch a development server in a browser on my local machine, the HTTP requests execute fine. I can fetch my data.
(❌) When I run the app in Android Studio on an emulator, the HTTP requests fail ("Type Error : fetch failed").
(✔️) Yet, when I open a web browser on the aforementioned emulator and try to access my API on 192.168.1.31:9000/api/games, I get a valid response.
The emulator can access my local API, but my app running on the emulator, cannot. It baffles me. Does anyone have an idea what I'm doing wrong?
I have tried replacing my IP address with 10.0.2.2 in the config files, with no success.
From left to right:
my app in a web browser,
my app on an emulator (with an empty carousel because the HTTP request failed),
a web browser on the emulator trying to access the API and getting a valid response.
After enabled https on back end nodejs server, the http request URL was changed from http to https in React Native 0.66 app. Now in Android emulator (API 27), the app does not send out any http request to back end server at all. android:usesCleartextTraffic="true" was added to AndroidManifest.xml but it didn't help (removing it has no impact either). It must be the issue about late android API which requires https in production. But I don't quite understand why https didn't work in Android emulator.
The development platform is macOS Big Sur for both IOS and Android which open their own emulators respectively. The IOS version of the app works fine after https was enabled. But android version of the app does not.
I'm able to import the certificate into Android via settings/security/trusted credentials without a problem and have tried this on Android 4.1, 4.4, and 6.x without success. SSL cert is generated with v3_req and v3_ca via openssl. We use the web app offline and neither the app manifest nor service workers will work without a "green lock". With Chrome moving to require SSL for app manifest soon (and deprecating it in favor of service workers), this is pretty important. The server is IIS 8 (also tried on IIS 7). I swear this worked in the past! Any help would be appreciated.
Works fine in Chrome on Windows and Linux (able to import cert and get the green lock instead of red). Firefox works fine on Android.
This is for an internal web server on a .local domain.
I have a beginners question.
I deployed my meteor website on Galaxy. Now I want an android version of my website. I followed every step in mobile docs. Everything is working fine on windows and the app is working as expected in the emulator.
Now if I build my app for production, we need to give a host and port.
What port and host should I use so I can use the same code base as my website?
Here is My domain
I tried:
meteor build ../output --server http://heybuddy.meteorapp.com:80
But without success. Or do I see it totally wrong.
Thank you for any answers!
The host is where your server is accessible, typically the address you use to access the browser-based version of your application / website.
The port is not mandatory.
I trying to deploy an android application connected to GAE. I run the online tutorial on google, I used the right configuration (as they write on the tutorial) but I can't communicate the Android Virtual Device with the web application running locally. The Web application shows me a "Server Error 500" and the android application on AVD shows me a "Failure:Connect to /192.168.56.1:8888 timed out" error.
I m running Eclipse Indigo and the virtual android device is with Google API Level 10.
Thank you.
Appengine dev server by default only accepts connections on localhost address (localhost and 127.0.0.1).
To make it accept connections on all ports add -bindAddress 0.0.0.0 to dev server parameters in Eclipse.