agamemnus / cordova-plugin-xapkreader

Easily access Google Play APK expansion file data.
32 stars 55 forks source link

net::ERR_UNKNOWN_URL_SCHEME #98

Closed roedoejet closed 7 years ago

roedoejet commented 7 years ago

Hi there,

Looking for some help debugging an issue with the plugin. I've added the plugin to my project as described for cordova 6.5 but the content:// URL scheme is still not recognized. My obb is a stored zip with one folder called "audio".

content://com.firstvoices.lilwat_fphlcc/audio/183Sounds20060713173801859seal_lil.mp3:1 GET content://com.firstvoices.lilwat_fphlcc/audio/183Sounds20060713173801859seal_lil.mp3 net::ERR_UNKNOWN_URL_SCHEME

Thank you!

roedoejet commented 7 years ago

I assumed this has something to do with the whitelist plugin, but I followed the instruction:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<widget id="com.firstvoices.lilwat_fphlcc" version="1.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
  <name>Lilwa_</name>
  <description>&#xD;
        An Ucwalmicwts/English Dictionary&#xD;
    </description>
  <author email="" href="">&#xD;
      Aidan Pine&#xD;
    </author>
  <content src="index.html"/>
    <allow-navigation href="*://*/*"/>
    <allow-intent href="*" />
    <access origin="*" />
    <access origin="content:///*" />
    <access origin="cdvfile:///*" />
  <preference name="webviewbounce" value="false"/>
  <preference name="UIWebViewBounce" value="false"/>
  <preference name="DisallowOverscroll" value="true"/>
  <preference name="android-minSdkVersion" value="16"/>
  <preference name="BackupWebStorage" value="none"/>
  <preference name="SplashScreen" value="screen"/>
  <preference name="SplashScreenDelay" value="3000"/>
  <preference name="xwalkVersion" value="22+"/>
  <preference name="xwalkCommandLine" value="--disable-pull-to-refresh-effect"/>
  <preference name="xwalkMode" value="embedded"/>
  <preference name="xwalkMultipleApk" value="true"/>
  <feature name="StatusBar">
    <param name="ios-package" onload="true" value="CDVStatusBar"/>
  </feature>
  <platform name="android">
    <icon src="resources\android\icon\drawable-ldpi-icon.png" density="ldpi"/>
    <icon src="resources\android\icon\drawable-mdpi-icon.png" density="mdpi"/>
    <icon src="resources\android\icon\drawable-hdpi-icon.png" density="hdpi"/>
    <icon src="resources\android\icon\drawable-xhdpi-icon.png" density="xhdpi"/>
    <icon src="resources\android\icon\drawable-xxhdpi-icon.png" density="xxhdpi"/>
    <icon src="resources\android\icon\drawable-xxxhdpi-icon.png" density="xxxhdpi"/>
    <splash src="resources\android\splash\drawable-land-ldpi-screen.png" density="land-ldpi"/>
    <splash src="resources\android\splash\drawable-land-mdpi-screen.png" density="land-mdpi"/>
    <splash src="resources\android\splash\drawable-land-hdpi-screen.png" density="land-hdpi"/>
    <splash src="resources\android\splash\drawable-land-xhdpi-screen.png" density="land-xhdpi"/>
    <splash src="resources\android\splash\drawable-land-xxhdpi-screen.png" density="land-xxhdpi"/>
    <splash src="resources\android\splash\drawable-land-xxxhdpi-screen.png" density="land-xxxhdpi"/>
    <splash src="resources\android\splash\drawable-port-ldpi-screen.png" density="port-ldpi"/>
    <splash src="resources\android\splash\drawable-port-mdpi-screen.png" density="port-mdpi"/>
    <splash src="resources\android\splash\drawable-port-hdpi-screen.png" density="port-hdpi"/>
    <splash src="resources\android\splash\drawable-port-xhdpi-screen.png" density="port-xhdpi"/>
    <splash src="resources\android\splash\drawable-port-xxhdpi-screen.png" density="port-xxhdpi"/>
    <splash src="resources\android\splash\drawable-port-xxxhdpi-screen.png" density="port-xxxhdpi"/>
  </platform>
  <platform name="ios">
    <icon src="resources\ios\icon\icon.png" width="57" height="57"/>
    <icon src="resources\ios\icon\icon@2x.png" width="114" height="114"/>
    <icon src="resources\ios\icon\icon-40.png" width="40" height="40"/>
    <icon src="resources\ios\icon\icon-40@2x.png" width="80" height="80"/>
    <icon src="resources\ios\icon\icon-40@3x.png" width="120" height="120"/>
    <icon src="resources\ios\icon\icon-50.png" width="50" height="50"/>
    <icon src="resources\ios\icon\icon-50@2x.png" width="100" height="100"/>
    <icon src="resources\ios\icon\icon-60.png" width="60" height="60"/>
    <icon src="resources\ios\icon\icon-60@2x.png" width="120" height="120"/>
    <icon src="resources\ios\icon\icon-60@3x.png" width="180" height="180"/>
    <icon src="resources\ios\icon\icon-72.png" width="72" height="72"/>
    <icon src="resources\ios\icon\icon-72@2x.png" width="144" height="144"/>
    <icon src="resources\ios\icon\icon-76.png" width="76" height="76"/>
    <icon src="resources\ios\icon\icon-76@2x.png" width="152" height="152"/>
    <icon src="resources\ios\icon\icon-83.5@2x.png" width="167" height="167"/>
    <icon src="resources\ios\icon\icon-small.png" width="29" height="29"/>
    <icon src="resources\ios\icon\icon-small@2x.png" width="58" height="58"/>
    <icon src="resources\ios\icon\icon-small@3x.png" width="87" height="87"/>
    <splash src="resources\ios\splash\Default-568h@2x~iphone.png" width="640" height="1136"/>
    <splash src="resources\ios\splash\Default-667h.png" width="750" height="1334"/>
    <splash src="resources\ios\splash\Default-736h.png" width="1242" height="2208"/>
    <splash src="resources\ios\splash\Default-Landscape-736h.png" width="2208" height="1242"/>
    <splash src="resources\ios\splash\Default-Landscape@2x~ipad.png" width="2048" height="1536"/>
    <splash src="resources\ios\splash\Default-Landscape@~ipadpro.png" width="2732" height="2048"/>
    <splash src="resources\ios\splash\Default-Landscape~ipad.png" width="1024" height="768"/>
    <splash src="resources\ios\splash\Default-Portrait@2x~ipad.png" width="1536" height="2048"/>
    <splash src="resources\ios\splash\Default-Portrait@~ipadpro.png" width="2048" height="2732"/>
    <splash src="resources\ios\splash\Default-Portrait~ipad.png" width="768" height="1024"/>
    <splash src="resources\ios\splash\Default@2x~iphone.png" width="640" height="960"/>
    <splash src="resources\ios\splash\Default~iphone.png" width="320" height="480"/>
  </platform>
  <icon src="resources\android\icon\drawable-xhdpi-icon.png"/>
</widget>
agamemnus commented 7 years ago

Do you have the Cordova Media plugin installed?

roedoejet commented 7 years ago

No I don't, am currently calling my audio with HTMLAudioElement:

srcURL = "content://com.firstvoices.lilwat_fphlcc/audio/" + src
var audio = new Audio(srcURL);
audio.play()
agamemnus commented 7 years ago

Try removing the whitelist plugin entirely and modifying the java file to ignore it.. let me find the code..

agamemnus commented 7 years ago

(Might be a few minutes, kind of getting pulled in all directions right now)

agamemnus commented 7 years ago

Also, try seeing if you can get any other format to work to rule out other issues... PNGs? Text files?

roedoejet commented 7 years ago

Tried with 'jpg' and same error:

content://com.firstvoices.lilwat_fphlcc/audio/test.jpg Failed to load resource: net::ERR_UNKNOWN_URL_SCHEME

agamemnus commented 7 years ago

Maybe the underscore is doing it? I really don't know. Try text files also.

roedoejet commented 7 years ago

Same error with .txt ...

agamemnus commented 7 years ago

Try removing the underscore...

roedoejet commented 7 years ago

Unfortunately the same thing: content://com.firstvoices.lilwatfphlcc/audio/test.jpg Failed to load resource: net::ERR_UNKNOWN_URL_SCHEME

agamemnus commented 7 years ago

Change out this file:

https://github.com/agamemnus/cordova-plugin-whitelist/blob/master/src/android/WhitelistPlugin.java

See what happens if you have shouldAllowNavigation, shouldAllowRequest, and shouldOpenExternalUrl to simply return true.

roedoejet commented 7 years ago

Same error.

agamemnus commented 7 years ago

And text files don't work either?

roedoejet commented 7 years ago

Nope.

content://com.firstvoices.lilwatfphlcc/audio/test.txt:1 GET content://com.firstvoices.lilwatfphlcc/audio/test.txt net::ERR_UNKNOWN_URL_SCHEME

I just saw in a folder called "test-project-instructions-and-test-obb" in the plugin there's a step that's not included on the repo markdown. It says to add: android.library.reference.2=../../plugins/com.flyingsoftgames.xapkreader/android-sdk/extras/google/play_apk_expansion/downloader_library

to /platforms/android/project.properties

But I already have a value for that (see below), should I change it or is the above for testing with Google Play or another version?

target=android-25
android.library.reference.1=CordovaLib
cordova.system.library.1=com.google.android.gms:play-services-base:+
android.library.reference.2=com.flyingsoftgames.xapkreader/lilwatfphlcc-downloader_library
android.library.reference.3=com.flyingsoftgames.xapkreader/lilwatfphlcc-library
cordova.gradle.include.1=cordova-plugin-crosswalk-webview/lilwatfphlcc-xwalk.gradle
agamemnus commented 7 years ago

This is for an older version. That should be removed.

Is your obb uncompressed?

roedoejet commented 7 years ago

Yes, I used 7zip and set the compression level to "store"

agamemnus commented 7 years ago

There must be something simple we are missing. Can you create a small sample project based on your settings that I can run?

roedoejet commented 7 years ago

Sure. You can clone the sandbox I have for the app here: https://github.com/roedoejet/lilwat-test.git

I'm calling the audio in controllers.js and have the img and text in www/templates/search.html

Or do you want something with fewer bells and whistles? This way you have what I have.

roedoejet commented 7 years ago

I've got to run out for a couple hours soon to another job but I'll be back in a few hours. I really appreciate you looking at this!

agamemnus commented 7 years ago

I assume you are testing this with Android... are you using the latest Android platform version, or which version? Your code doesn't say.

roedoejet commented 7 years ago

testing on a device running 5.1

agamemnus commented 7 years ago

Also -- the obb file -- it's not there.

roedoejet commented 7 years ago

Oops. Sorry about that. just added it but with most of the audio taken out. There are three files, audio/183Sounds20060420153235640knife_lil.mp3, audio/test.jpg, audio/test.txt

agamemnus commented 7 years ago

Thx.

agamemnus commented 7 years ago

Downloaded it and installed latest Android platform, but didn't test.... please remind me tomorrow...

roedoejet commented 7 years ago

Ok great. thanks, I'll do that.

roedoejet commented 7 years ago

Any update on this? ... a friendly reminder :)

agamemnus commented 7 years ago

Checking now.

agamemnus commented 7 years ago

Maven? Might this be an issue?

agamemnus commented 7 years ago

No, that isn't it. Still checking a few different things.

agamemnus commented 7 years ago

Here is the problem: you do not have the File plugin installed, and for some reason your whitelist plugin is some random old dev version.

roedoejet commented 7 years ago

Huh, I didn't know I needed the File plugin, but that makes sense. The whitelist plugin I added was the one here which is listed on the readme, is that not right? https://github.com/agamemnus/cordova-plugin-whitelist

agamemnus commented 7 years ago

Oh, weird. I had no idea it was a dev version... but it IS old. :P

roedoejet commented 7 years ago

lol yes, so is it still required or does the newer version/main repo of cordova-plugin-whitelist work?

agamemnus commented 7 years ago

I did do a few different things.

If that still doesn't work, try instalilng a clean whitelist plugin as well, and try this for a meta tag: <meta http-equiv="Content-Security-Policy" content="default-src * 'self' 'unsafe-inline' http://* https://* 'unsafe-eval';">

agamemnus commented 7 years ago

No, it's not required if you have the various tags to change the security policy, etc.

agamemnus commented 7 years ago

You could also just delete the plugin...

roedoejet commented 7 years ago

Ok, I got the net::ERR_UNKNOWN_URL_SCHEME error to go away by removing the whitelist plugin altogether and by using the updated meta tag above. Now I'm getting 404's :( did the content actually come through for you? Thanks so much again for looking into this. I'll keep looking into it.

agamemnus commented 7 years ago

It did. You added the File plugin?

agamemnus commented 7 years ago

Update your code on github and I'll look at it again. I did do a number of things which might have had an effect...

roedoejet commented 7 years ago

Yep. I added the File plugin. It looks like the cordova-compat plugin got installed as a dependency or something. I've updated the repo with my changes

agamemnus commented 7 years ago

Ok, give me a bit and I will try again.

roedoejet commented 7 years ago

thanks!

agamemnus commented 7 years ago

It'll be tomorrow. I'm stuck on a bug (?) in another library and very tired. Sry.

roedoejet commented 7 years ago

no problem. you could also make a pull request to the repo with your local copy and I can try and see what other changes you made. g'night!

roedoejet commented 7 years ago

any luck? I'm heading out to work but will be back this afternoon/evening to have another look. Had me stumped yesterday.

agamemnus commented 7 years ago

I was busy all day yesterday. I am looking now, that I am wrapping up my bug work for the other project.

roedoejet commented 7 years ago

OK, no problem. Again, I really appreciate you looking into this. Be back in a few hours.

agamemnus commented 7 years ago

It's not working. I keep having issues with Error: Unexpected end of JSON input when I try to add the android platform, etc.