Software Archive
Read-only legacy content
17061 Discussions

got 404 (Not Found) for ajax url/media src in android

Arthur_T_
New Contributor I
573 Views

I got 404 (Not Found) when run my app on android phone for those ajax url or media src. (ps: find it out when using debug tab and 404 show on console) Already added

<meta http-equiv="Content-Security-Policy" content="media-src 'self' https://xxx.mooee.com; connect-src 'self' https://xxx.mooee.com; ">

to index.html

but still fail and got 404 when run on android phone. It is ok when run on iPhone or desktop browser.

URL used in ajax like this: https://xxx.mooee.com/yyy/test/p02Launcher.php

URL used in video source src like this: https://xxx.mooee.com/yyy/test/a.mp4

Anything wrong?

P.S.

I'm using XDK ver 3240 and there is no different for using build tab. Also, the cert our server use is not a self signed cert. I just replace the real subdomain with xxx here.

0 Kudos
15 Replies
Swati_S_Intel1
Employee
573 Views

Have you added your URLs in Network whitelist? The CSP meta tag will only work on Android 4.4+. Please see this article for whitelisting URLs: https://software.intel.com/en-us/articles/cordova-whitelisting-with-intel-xdk-for-ajax-and-launching-external-apps

0 Kudos
PaulF_IntelCorp
Employee
573 Views

If you are using jQuery, please also read this FAQ > https://software.intel.com/en-us/xdk/faqs/app-designer#ajax-jquery-one-fail

0 Kudos
Arthur_T_
New Contributor I
573 Views

I think it is not related to whitelist issue as the console not saying 'blocked' for the url access. In fact, I got the 'blocked' in console before added the meta tag (<meta http-equiv="Content-Security-Policy" content="media-src 'self' https://xxx.mooee.com; connect-src 'self' https://xxx.mooee.com; ">) So it is another issue. Besides, the video tag in my app got 404 too.

<video controls="controls" id="p03-vdo-ChildPerf" preload="default">
     <source src="https://xxx.mooee.com/yyy/test/a.mp4" type="video/mp4">
</video>

So it is not just related to ajax.

p.s.

there is no different for adding "https://xxx.mooee.com/*" to <access> and <allow-intent> in android build setting of my project.

0 Kudos
PaulF_IntelCorp
Employee
573 Views

Are you adding it to your CSP tag in your index.html file? http://www.html5rocks.com/en/tutorials/security/content-security-policy/ explains CSP and https://software.intel.com/en-us/articles/cordova-whitelisting-with-intel-xdk-for-ajax-and-launching-external-apps contains some example CSP meta tags that you can experiment with.

0 Kudos
Arthur_T_
New Contributor I
573 Views

Already added CSP like this in index.html:

<meta http-equiv="Content-Security-Policy" content="media-src 'self' https://xxx.mooee.com; connect-src 'self' https://xxx.mooee.com; ">

and <access> and <allow-intent> in project android build settings set to https://xxx.mooee.com/*

as I said in this post

Anything wrong?

0 Kudos
PaulF_IntelCorp
Employee
573 Views

Did you check this faq?

If you are using jQuery, please also read this FAQ > https://software.intel.com/en-us/xdk/faqs/app-designer#ajax-jquery-one-fail

0 Kudos
Arthur_T_
New Contributor I
573 Views

I think even though I can solve the problem on ajax. Still has video src issue. As we need to do streaming, so it is not workable for us to use ajax to get the video src and save at client then play it. That's why I'm not start to follow all advice for ajax on this post yet.

0 Kudos
Swati_S_Intel1
Employee
573 Views

Arthur, are you building with Crosswalk or just Android? Which Cordova version are you using? What min and Target API are you specifying? Assuming you have done everything right for AJAX request, check few things :

1) Server certificate : Android is sensitive about the certificate order, so please make sure your server certificate chain is correct

2) Permissions on your Android device

3) Try with Unsigned app

4) try to run your ajax request and/or video request using mobile browser on your Android device and see if that works

5) In the video tag do not use type attribute. 

 

0 Kudos
Arthur_T_
New Contributor I
573 Views

Thanks for all of you. Now it works on android and iOS devices.  May be last time I used a wrong AppID in android project settings. (but don't know why it can build using the keystore)

0 Kudos
PaulF_IntelCorp
Employee
573 Views

Arthur -- Android certs do not require a match with the App ID like iOS certs do. Any App ID will work with any Android cert. On Android, the primary purpose of the cert is to confirm that any updates to an app are coming from the original owner of that app.

0 Kudos
Arthur_T_
New Contributor I
573 Views

Thanks for your information. When I build for android. I chose 'shared' for crosswalk runtime. And there are 2 apk, one for arm and one for x86 after download the build. I think I can install any one of them to my LG nexus 4 as both ok to install. I only need to choose the one for arm when I chose to embed crosswalk runtime in my project, right?

fyi: seems the problem happen on debug tab only as the app is ok when I chose to build my app with embed crosswalk runtime ver 16. If I chose ver 17, debug tab ok too.

0 Kudos
PaulF_IntelCorp
Employee
573 Views

Arthur -- yes, when you build for shared the system generates to APK files, labeled ARM and x86. In fact, those two "shared model" APK files are identical. It's a weird artifact of the new build system that does that. We haven't had time to fix it. You only need to submit one of those to the store, but if you submit both, it will still work fine.

0 Kudos
Arthur_T_
New Contributor I
573 Views

Thanks for your information. That's ok for the "shared model" still have 2 APK when build with XDK 3357 as long as I know they are the same.

P.S. Maybe that is cause:

I change an old project's name to a new one. The old project was created by XDK 3240 and it was built before. After changed the project name (I changed those in ~/Library/Application Support/XDK/global-settings.xdk and state.json too under XDK not running)

Then after I build the project by 3357 and download the build. The filename still suffix by the old project name.

0 Kudos
PaulF_IntelCorp
Employee
573 Views

Arthur -- I think that project name on the APK files that you download comes from the project folder name or the <project-name>.xdk file in the project folder. I'm not sure and have never experimented to figure that out.

0 Kudos
Arthur_T_
New Contributor I
573 Views

FYI: Seems that is not the reason as I changed xdk too. I tried delete uploaded project source files from build server before build. But the build filename still suffix by the old project name.

0 Kudos
Reply