Closed agamemnus closed 8 years ago
I am wondering then if you are actually using a new platforms/android
build? That has its own version separate from the Cordova version and they should be updated in parallel.
I'm using Cordova 5.0 + Ionic 1.0.0 (1.5.0 CLI), building with command 'ionic build android'
After that, do you do ionic plugin add https://github.com/igormas/cordova-plugin-xapkreader
? (note this is igormas's fork)
@agamemnus thank you! For same reason that folder was not generated. I tried a new fresh install and now all works :D i will test the APK now.
I'm back on this again today - @Shinji89 did you get the whole plugin working?
Ok, Matt, I have a few questions: With Cordova 4, were you able to use the non-Google Play build with the current version normally? No stalled download issues? If yes, were you using a debug build or a release build, and in either case, were you using a debug certificate?
Same questions for 5.
@mattrayner i will test it in the next week.
@agamemnus I've not tried it in Cordova 4 - I'm not too worried about it not downloading outside of Google play for my app at the moment - as long as I can read the files and it will download when published as Alpha, Beta or Production (which I'm currently testing) that's ok with me
My app deadline has been moved back a little so I have some more time to work on this.
I've also discovered that you can have multiple origin tags such as:
<!-- A wildcard can be used to whitelist the entire network,
over HTTP and HTTPS.
*NOT RECOMMENDED* -->
<allow-navigation href="*" />
<!-- Allow all unrecognized URLs to open installed apps
*NOT RECOMMENDED* -->
<allow-intent href="*" />
<!-- Don't block any requests -->
<access origin="*" />
<access origin="content:///*" />
<access origin="cdvfile:///*" />
they do not appear to overwrite each other - the above allows for content:///*
even though cdvfile:///*
follows
@Shinji89 Awesome!
I am still getting these errors though:
06-09 17:31:01.435: E/AndroidProtocolHandler(19946): Unable to open content URL: content://com.bdnetworkXXX/img/pages/XXX.jpg
Have you been able to get any of them open at all?
Do you have spaces or caps in the filename?
You are using the expansion content provider thingo instead of the project name in content://, right?
Woohoo i finally managed to retrieve the content from the expansion file. I'm using cordova 5, i haven't tested the downloader yet but when the file is downloaded(i copied it manually) then everything seems to work. Important points:
content security meta tag
<meta http-equiv="Content-Security-Policy"
content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
Igor, that shouldn't happen. I am reading xapk_expansion_authority
without issues, although I do get ERR_UNKNOWN_URL_SCHEME for content://
, but that might be related to a too-new Chromium or Crosswalk version. Are you using Crosswalk? If not, what Chrome version are you using?
agamemnus, I'm using crosswalk (engine c0.7.1), currently the xapk_expansion_authority value in my project is com.test.expansion but I changed my package name to $project_I'd and everything works ok. I changed it because I saw that the plugin is looking for the expansion files in 'Android/obb/$project_id' folder. If everything works correct in your project, then probably I missed something. I'll double check it again today.
c0.7.1? What is that? ... can you link me?
Its just the crosswalk version, nothing special.
So you are using cordova plugin add cordova-plugin-crosswalk-webview
?
No, i'm using ionic so in order to add crosswalk I am running ionic browser add crosswalk. http://blog.ionic.io/crosswalk-comes-to-ionic/
I am not sure how ionic adds crosswalk. This may be an issue with the exact Chromium and crosswalk version ionic uses, or maybe not. You are definitely not getting net::ERR_UNKNOWN_URL_SCHEME
on the content:// requests?
Where do you see this error ? Anyway I'm receiving the wanted image for the content://com.test.expansion/wantedImg.png request.
I get the error in Developer Tools in Chrome when I create a debug build. (You will need to hard-code isDebug
to true in XAPKDownloaderActivity.java
to use a debug build with the same cert as release.)
@agamemnus i have no errors in console when running with idDebug=true. this is how i retrieved my image < img src="content://$package_name/www/assets/img/1x.png" > . The image was retrieved and rendered successfully in the view. Do you have crosswalk in your project ?
Yes, I am using cordova plugin add cordova-plugin-crosswalk-webview
.
Regarding your content URL, check your plugins/android.json
file and your platforms/android/res/values/xapkreader.xml
file for any duplicates or different values of xapk_expansion_authority
.
Does the plugin works well in your project ?
No, it doesn't work. At first I thought it did but it was just loading the backup files stored on my server. It just gives me net::ERR_UNKNOWN_URL_SCHEME
errors.
What crosswalk version do you use ? I guess you using cordova 5 right ?
Right, Cordova 5. I don't know what the version is but I guess it is the stable version for 5.
you can check the version in package.json of the crosswalk plugin (plugins/cordova-plugin-crosswalk-webview). I checked yesterday with 1.2.0 and its works.
Odd, well, it is 1.2.0.
How do you sending the requests? Have you tried using the img tag (< img src="content://..." >) ? this is the only way i tested the plugin....
Basically, yes. new Image ()
...
Try to put img tag within html (when i tested i put it as the first child of the body element). Just making sure it doesn't work under the conditions i tested it.
I've followed your above and can't get it to work - This is my most recent error:
06-11 11:54:37.957: E/AndroidProtocolHandler(5641): Unable to open content URL: content://com.test.expansion/main_extension/img/icons/menu-test-drive.png
I have the file in Android/obb/com.test.expansion/mail.***.***.***.***.obb
Does the file need to be named in some specific way that I'm missing?
I'm not using crosswalk or ionic - just the base android chrome browser
@mattrayner you need correct the name of the main file, it should be in the following structure Android/obb/$package_name/main.$version.$package_name.obb
@igormas - is version the version that shows up in the play developer console or the version that is set in config.xml?
the developer console appends 8 to my version so config.xml shows android-version='20' and play shows 208
@igormas - I now get:
06-11 12:06:29.820: E/AndroidProtocolHandler(7907): Unable to open content URL: content://com.bdnetwork.peugeot208/main_extension/img/black.jpg
06-11 12:06:29.823: E/ActivityThread(7907): Failed to find provider info for com.bdnetwork.peugeot208
It should be the value of android:versionCode of manifest tag in AndroidManifest.xml
hmm, that's still not working for me. If I set my content urls to com.test.expansion as set in android.json it gets rid of the ActivityThread issue but moving the files still doesnt help
What is the value of xapk_expansion_authority variable ?
In android.json: com.test.expansion
in xapkreader.xml: com.test.expansion
So try to change the expansion file name to main.$version.com.test.expansion.obb, and put in the following path Android/obb/com.test.expansion. So in your device you have the following structure: Android/obb/com.test.expansion/main.$version.com.test.expansion.obb
trying that now... This is what my Android File Explorer looks like:
Same error:
06-11 12:32:33.190: E/AndroidProtocolHandler(12029): Unable to open content URL: content://com.test.expansion/main_extension/img/icons/menu-test-drive.png
maybe it's a problem with my zip file?
Do you have a zip command that you know works?
Change the name to main.20.com.test.expansion.obb. I edited my previous comment, you probably read it before the edit :)
Updated tree:
Same error
Is there a way of checking if the app can see the file on the device's file system from cordova?
I had the same issue, try to change the package name in all relevant places to app id (app id in config.xml (id attribute of the widget tag) ). By the way your version number is the same as android:versionCode ?
Cordova 5 ignores the ant build system. It uses gradle, instead. That means that the links to the Google Play downloader and licensing libraries are broken. To fix that, we need to use a
build-extras.gradle
file, and do some other things...Due to some various Cordova 5 issues/bugs, a fully working Cordova 5 version isn't currently available. (there is a test Cordova-5 branch, however) Here are steps to make this plugin work for Cordova 5 (PLEASE NOTE THESE ARE STILL DRAFT INSTRUCTIONS): 1) Create a
/platforms/android/com.flyingsoftgames.xapkreader/
directory. 2) Copy your/plugins/com.flyingsoftgames.xapkreader/android-sdk/extras/google/play_apk_expansion/downloader_library
directory contents and your/plugins/com.flyingsoftgames.xapkreader/android-sdk/extras/google/play_licensing/library
directory contents to/platforms/android/com.flyingsoftgames.xapkreader/downloader_library
and/platforms/android/com.flyingsoftgames.xapkreader/library
. 3) Instead of the single reference we added before, add this instead toproject.properties
:4) Inside
downloader_library
, add a file namedbuild-extras.gradle
, with the following contents:5) The automatic downloader DOES NOT SEEM TO WORK. We must disable it. In
platforms/android/src/com/flyingsoftgames/xapkreader/XAPKDownloaderActivity.java
, changereturn isDebug;
toreturn true;
.6a) Cordova 5 has a whitelist plugin requirement. New builds have it by default. You must add this:
cordova plugin add cordova-plugin-whitelist
. In yourindex.html
file, you also need to add a Content-Security-Policy meta tag. Note that the instructions on the whitelist plugin on github do not show the most permissive meta tag and forget aboutcontent://
orcdvfile://
. The most permissive meta tag seems to be:<meta http-equiv="Content-Security-Policy" content="* * 'self' default-src 'unsafe-inline' 'unsafe-eval' http://* https://* data: cdvfile://* content://*;">
. (content:// and cdvfile:// should really be included by default. If you want to omit those, I made a patch here: https://github.com/agamemnus/cordova-plugin-whitelist)6b) Make sure to add
allow-navigation
, andallow-intent
, and extraaccess origin
tags toconfig.xml
. E.G.:NOTE 1: Please do not post any logs here (unless absolutely necessary)! NOTE 2: If you are on Crosswalk, note that you must use the plugin method for Cordova 5+ builds. The migrate method no longer works.