3 MIN READ
   //   Aug 1, 2019

Resolving Network Error in Android app development

abhay.kumar

While accessing an API within the Android application you might be haunted with the ‘Network Error`:

Network Error in Android Application Development

 

| What do these errors indicate? 

These errors state that the request you tried to make did not reach your remote server. Be it a hosted API or your local machine. These errors may occur under the following scenarios: 

Scenario 1

If we want to serve the mobile app with your local machine’s REST endpoint which has the local server up and running. We must choose “public IP” of the local machine to be the endpoint.

Scenario 2

You can access APIs over HTTP pointing to a domain name or an IP.  However, these approaches are not suggested as you wouldn’t want your APIs to be unsecured or the server’s IP to be used as an endpoint.

Scenario 3

If you access the API over HTTPS with a domain name and receive a “Network Error”. Try checking the access logs and error logs of the servers to check if the API messed up with the “request” or did the request never reach the server. If the request did not reach the server, this indicates the REST endpoint is rejected to be served by the Android itself.

| Solution

To resolve this issue check if your SSL certificates on the servers are correctly installed. Go to: https://www.ssllabs.com/ssltest/ to find more about your SSL certificate.

Network Error in Android Application Development

 

If you get the warning “certificate chain is incomplete” and the overall rating is below “A+”. Try resolving the issue by installing the complete certificate chain on the respective server and check for the ratings again.

Copy the certificate :
cp mydomain-2019.crt mydomain-2019.pem

Add the Intermediate Certificate to your SSL Certificate
cat intermediate.crt >> mydomain-2019.pem

Make sure your mydomain-19.pem is a valid file by checking there should be only 10 ‘-’ in the respective lines and no extra new line in the bottom of the file.

Use the mydomain-2019.pem as a certificate in your server configurations

If things are done right the ratings should be increased to A+

Network Error in Android Application Development

 

Now your mobile application should be able to access the API over HTTPS with a domain main.

Facing any other issues related to Android applications? We would like to hear about them. Drop us a word at [email protected]

Start your Digital

Transformation journey

Consultancy | Design | Drupal