$http, IOS good, Browser good, Android bad

Good day everyone,
I’m currently facing an issue with $http, I don’t know why but it doesn’t work on Android (emulator and device same). I also tried doing it with jQuery ($.getJSON) but still the same result, I get empty or error 404. I’ve made a small app with just a button to test. This is the super simple controller I’m using:

starter.controller('StarterController', function($scope, $http) {
  $http.defaults.headers.common.Accept = 'application/json'

  $scope.httpReq = function() {
    $http.get('http://date.jsontest.com')
    .success(function(data) {
      alert(JSON.stringify(data));
    })
    .error(function(data) {
      alert(JSON.stringify(data));
    });
  };
});

I’ve checked on config.xml. I’ve also checked AndroidManifest and it has permissions to use INTERNET, ACCESS_NETWORK_STATE, ACCESS_WIFI_STATE.

I’ve been struggling with this for couple days now, can anyone tell me how to solve this?

P.S. I’m using Ionic version 1.3.20 and Android Sdk like this : <uses-sdk android:minSdkVersion="10" android:targetSdkVersion="22" />

Regards.

same error for me. I try to compile the same project with a old ionic version and it works fine :frowning:

Check my answer I do run my app in android and all services run fine.

se if this does not run on your device http://plnkr.co/edit/m74z5IbvBqBviH0IbLqe?p=preview

Repeat Issue Link

Have you checked if it’s because of the new whitelist plugin in Cordova 5.0?

1 Like

Hey Dany, which Ionic version worked for you?

Mirko, thanks man!!! I used the advice you gave on the other post, add the plugin:

ionic plugin add cordova-plugin-whitelist

It worked like a charm!!! Again thanks a lot :smiley:

I guess this is because in the latest Cordova version whitelist code was moved out of core Cordova and into a new Cordova whitelist plugin.
check this article:
Apache Cordova Newsflash!