-2

We are developing an android application in eclipse. We have a web service on one of our computer that the app gets its data from.

During the debug in a sony Xperia Z1 mobile the debugger behaves weird. it skips lines and in a try/catch statement after entering the first command it goes directly to finally.

The code is below

    1 // Make the request.
>    2  CloseableHttpResponse httpResponse = null;
     3   try {
>    4       httpResponse = httpClient.execute(httpPost, context);
     5       // Set status.
>    6       response.setStatus(httpResponse.getStatusLine().getStatusCode());
     7       // Read the body.
>    8      response.setBody(EntityUtils.toString(httpResponse.getEntity(), "UTF-8"));
     9      // Get the cookies.
    10      response.setCookieList(context.getCookieStore().getCookies());
    11      } catch (IOException ex) {
    12        // logger.error("", ex);
    13      } finally {
>   14      if (httpResponse != null) {
    15         try {
    16                httpResponse.close();
    17                httpClient.close();
    18            } catch (IOException ex) {
    19            }
    20        }
    21    }

From line 2 that is the first breakpoint it gors to line 4 and then goes to line 14. We tried both "Step Into" and "Step Over" and hitting the resume button but stll we get the same result.

We cleaned the project and built it again. Created a new project and wrote the code again. Uninstall/Install the app from the mobile.

How can we fix that problem?

athskar
  • 226
  • 1
  • 3
  • 12

1 Answers1

0

The problem was that in android manifest file there wasn't any declaration that the app uses internet, so the mobile turned down the http request.

We added in AndroidManifest.xml the line below:

 <uses-permission android:name="android.permission.INTERNET" />

Be sure not to forget that for android apps it is vital to declare which services you will need in android manifest.

found the code above here: What permission do I need to access Internet from an android application?

Community
  • 1
  • 1
athskar
  • 226
  • 1
  • 3
  • 12