Ionic android issue with Xiaomi3


#1

Greetings

Been stuck on this for awhile now and hoping someone could assist me in some way. Here’s what I have so far.

Ionic Version: 1.3.20
Cordova Version: 5.0.0
Xiaomi Version: 4.4.4

<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="21" />

As for my codes, here is a snippet of what’s going on. I’m doing a simple http request to a PHP server(Laravel) to retrieve the version.

    Info.getVersion().then(
      function(data){
        var result = angular.fromJson(data);
        if( result.status )
        {
          if( version != result.version )
            $rootScope.updateApp();
        }
      },
      function(error){
        $rootScope.handleError( error );
      }
    );

Note: $rootScope.handleError shows an $ionicPopup

Currently, I’m getting a Failed to load resource: the server responded with a status of 404 (Not Found) when looking at Device Debugger on Google Chrome.

I also understand that the AndroidManifest.xml should have the following:

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

As I run ionic build android there were no issues reported by Ionic CLI

When I open the app, it just keeps giving me the 404 error and I’m suspecting it could be that I do not have connection within my app

P.S. I do have connection on the browser and other apps.


#2

Sounds like an issue with the new release for cordova-android.
Try adding the white list plugin

http://cordova.apache.org/announcements/2015/04/15/cordova-android-4.0.0.html


#3

Hey @mrhartington

Was just about to link this thread to this github issue:

Thanks again! Cheers


#4

Sorry to bother you again @mrhartington but I’m still unable to fix my issue.

Here’s what I’ve done so far

ionic plugin add https://github.com/apache/cordova-plugin-whitelist.git

This is then followed up by modifying my config.xml where including allow-origin, I’ve also included the following.

<allow-navigation href="http://omapp.my/*" />
<allow-intent href="*" />

As for my index.html, I’ve included the meta tag for Content-Security-Policy

<meta http-equiv="Content-Security-Policy" content="default-src 'self' omapp.my">

Lastly, I have run the following commands but to no avail.

ionic platform remove android
ionic platform add android
ionic build android

Your help is much appreciated!

Cheers


#5

I made some changes to my meta tag in index.html and came up with this instead and it’s working now!

<meta http-equiv="Content-Security-Policy" content="script-src 'self' https://maps.googleapis.com/ https://maps.gstatic.com/ 'unsafe-inline' 'unsafe-eval'">

I’m not sure if this is the right way to apply Content Security Policy but do let me know if I’m doing it wrong or there is a better way of doing it.

Thanks!