Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cordova net::ERR_CACHE_MISS

Tags:

cordova

i have an cordova pp i am calling a post method in controller it works in browser , but in build and debug apk i get the error

ionic.bundle.js:23826 POST http://somedomain.com/api/account/validation net::ERR_CACHE_MISS

my angular controller

.controller('splashCtrl', function ($scope, $state,$http, userManager, serverConfig) {
    //check if the user exist else it will redirect to login 
    $scope.authenticate = function () {

        $http.post(serverConfig.serverUrl + '/api/account/validation').success(function (res,status) {

            if (status == '200') {

                //check if the user need to change password
                if (window.localStorage.getItem('shouldChangePassword') && window.localStorage.getItem('shouldChangePassword')=='true') {
                    $state.go('setPassword');
                    return;
                }

                $state.go('tab.category');
            }

        }).error(function (data, status) {
            console.log(status)
        })


    }

    $scope.authenticate();


})

any suggestion ?

like image 702
user6599525 Avatar asked Oct 15 '16 15:10

user6599525


Video Answer


2 Answers

This Error means you don't have access to internet.There are two ways you can provide this access by changing these files

1.AndroidManifest.xml

add these following permission

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

2. config.xml

For this you are going to need this plugin

cordova plugin add cordova-custom-config

after adding this plugin , add these lines in you config.xml

<platform name="android">
   <config-file target="AndroidManifest.xml" parent="/*">
      <uses-permission android:name="android.permission.INTERNET" />
      <uses-permission android:name="android.permissions.NETWORK_ACCESS" />
      <uses-permission android:name="android.permissions.ACCESS_NETWORK_STATE" />
   </config-file>
</platform>

You can try it . Hope it helps you .Thanks

like image 195
Ujjwal kaushik Avatar answered Nov 09 '22 13:11

Ujjwal kaushik


If you encounter this problem after removing a plugin or installing a plugin then this solution might work for you.

cordova platform remove android
cordova platform add android

There is no harm in trying it even if you've not installed or removed any plugin.

like image 30
David Addoteye Avatar answered Nov 09 '22 13:11

David Addoteye