Cannot access the internet while i debug android on device - android

I'm trying to develop an android application that uses network connection. The server is up and running, but when i am trying to access it from the device that runs the android app (in debug mode-using eclipse) it outputs a message that 'cannot find the server' after a UnknownHostException occurs!
I have tested the server with a java application and it works fine! What is the problem then with the device?

check your Mainfest.xml file for this line...
<uses-permission android:name="android.permission.INTERNET" />

Related

App on Android emulator cannot connect to local API

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.

Xamarin App SQL Server Connection not working in release mode

I have a C# Android app that connect to a SQL Server database. I noticed that if I build in Release mode, the connection to the database is not working. But if I build in Debug mode, it works fine. What could be causing this?
I already set the user permission
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET" />
And this is my settings
And this is my Sql Server connection
I solve the issue by setting up the
Linkers properties to
SDK ASSSEMBLIES ONLY
and
Additional support encodings to MIDEAST,WEST

Android APK file does not connect to server through network : PhoneGap Build

I'm currently developing an application using PhoneGap in Eclipse. One of the features of the app is that it connects to a remote server through the network. In eclipse, when I run the project as an 'Android Application' directly on the device, everything works perfectly and the device successfully connects to the remote server. This I guess is the 'Debug' build that eclipse offers.
I then go on to create an APK file for the project through PhoneGap's site... I install the APK on the device and when I try to connect, it does not work. The app just hangs when I click on the connect button and does nothing.
I check the debug build and everything works again like a charm. Can someone please tell me what I'm missing ? Do I need to sign the APK file that I'm creating on the PhoneGap site ? Any help would be much appreciated.
Thanks in advance
Maybe you can put
AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.package">
<uses-permission android:name="android.permission.INTERNET"/>
<application>
...
</application>
</manifest>

Android application using phone gap

I successfully completed my application in android and is running in real device and simulator .My app requires internet access hence given access in manifest.xml file.
The code is like this:
uses-permission android:name="android.permission.INTERNET" />
uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
Now the problem is my app is running only when the wifi is ON but not running through the internet connection in mobile. I have to run the application with out wifi in my device.
I am using Apache 2.2.0 version. okay, no problem my issue is solved I added code lane super.setIntegerProperty("loadUrlTimeoutValue", 100000); and now it's running.

AIR Android application remote debugging

I have my AIR application created in Flash Builder 4.6, and trying to debug it on the device via USB. Application gets deployed properly, but doesn't connect to the internet. I have permissions set properly to
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
When I export release build and deploy it on the same device, it gets connected to internet without any issues.
Any ideas how to fix it?

Categories

Resources