-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MAIN_VERSION can be more than 1 #3
Comments
According to the getExpansionAPKFileName method of com.google.android.vending.expansion.downloader.Helpers class, MAIN_VERSION should be a boolean and defined to true for main file or false for patch file. I'm not sure of the solution because I have rarely used it, but I think you have to set MAIN_VERSION to 0. |
That doesn't seem to match up with their code in APKExpansionSupport.getAPKExpansionFiles which uses mainVersion directly to create the file name. And actually, I think where you use String fileName = Helpers.getExpansionAPKFileName(ctx, true, patchVersion); I am not sure if that is even needed. Everything I have seen for documentation for getAssetFileDescriptor says to just pass a filename relative to the root of the zip, so just this AssetFileDescriptor fileDescriptor = expansionFile.getAssetFileDescriptor(filename); Maybe thing's have changed from when thish was updated from Android Market to Google Play? |
Looking closer at Helper.getExpansionAPKFileName, it looks like you are simply supposed to pass a boolean variable to it to say whether or not you want the main file, or the patch file, but that is unrelated to MAIN_VERSION in your code. |
I never took a deeper look at this api so maybe it's not the right way to do. |
Yes, I will try to get a pull request done soon. Also, It's probably worth including a class to extend the APEZProvider class, so that the contents of a zip file can be accessed with URLs. Using XAPReader.get() was slow for many images, but using the provider class, I was able to set images to content://com.my.app.expansion/photos/photo.jpg and have them load fine. |
Sorry for the delay on this. I have a fork done, with all the code changes, but want to make sure it's well tested first, and I had a large project come up for work. |
Hi psyon. XAPKReader.get( Where exactly I must write this? Thanks. |
I used the APEZProvider class. https://github.com/psyon/phonegap-xapkreader/blob/psyon-fixes/src/android/XAPKProvider.java I will have a pull request soon to make sure this gets into Mousts code, but for now you can drop that file into the plugin directory. With that file in place, you would have to add this to AndroidManifest.xml
Replace the $MAIN_VERSION and $PATCH_VERSION From there, you would be able to simply read the file like this
|
Thanks for your quick response. I have placed XAPKProvider.java in plugins folder, in org.apache.cordova.xapkreader\src\android, and even in platforms\android\src\org\apache\cordova\xapkreader. Nothing seems to work. That is all I have done so far:
Here I must mention that I installed the plugin from your git page and not from moust because I noticed that you have made some changes. -Then I added the necessary libraries. Thanks for your time, psyon. |
If you installed from my repo, then the file should have already been there, and the stuff for the manifest should have been added automatically. the code changes in my repo were done on a live app, and I copied the changes to the repo, but I have not tested it yet. Once my repo is tested, I will send a pull request to merge it into moust's |
well.. that's interesting because I reinstalled it 2 times and everytime I have the same folder structure with the same files (XAPKAlarmReceiver, XAPKDownloaderActivity, XAPKDownloaderService, XAPKDownloaderService). |
You are probably using the master branch of my repo, and not the psyon-fixes branch. Im not even sure if you can install from my changes. Ill merge to the master branch, and you can give it a try then. |
that explains everything. thank you |
It should be merged into the master branch on my repo now. |
everything installs fine now. But I have the same problem with AndroidManifest. Those code lines make my app to stop working before starts. In XAPKProvider this line |
Told you I hadn't tested it yet :P I changed the package names in the repo. |
then I'll wait until you will test it :) anyway, thanks for your time |
That may very well be the only issue. The code itself I have tested in a separate project, but I put the code in manually, and not via the plugin. The only issue should be if the plugin installs properly. |
Tomorrow I will start a project from 0 and I'll add everything manually to see what happens. |
I just had the package names wrong when I typed them in. I've updated the repo now, and it should have the correct names. I won't have a chance until Monday next week to sit down and play with it directly. If you get a chance, and see anything wrong, please give some feed back. Hopefully we can get this merged into Mousts repo soon and save some other people some headaches. |
today I tried again..unfortunately unsuccessfully I created a new, clean phonegap app where I have installed manually and automatically your plugin. When I try to install the app on phone or on an emulator it just stop working (
the app starts and is trying to download the expansion file, but I can't acces the files inside expansion. thanks |
Hi adys123! You can fix this bug changing the android:name="org.apache.xapkreader.XAPKProvider" Of the line that you copied by: android:name="org.apache.cordova.xapkreader.XAPKProvider" I'm stucked downloading the expansion pack 😢 i'm always getting a error telling me that the expansion pack doesn't exist or has a wrong size and It's uploaded to the store 😟 I don't know what to do. Any ideas? I also tried to load bob file locally (I copied it into Android/obb//) and the app loads correctly, but i'm not able to use content://org.apache.cordova.xapkreader.expansion/... to load anything, the app crashes 😟 May I change any package name or something? Thanks! |
Thanks a lot llKoull. @llKoull .. this may be a stupid question, but have you placed obb file into Android/obb or into Android/obb/com.bla.bla ? For anyone that can't make their content to show up in application you need to change this |
Hi adys123! I placed It into Android/obb/"Package ID"/ then my App loads but i can't see any image 😟 Using img src="content://org.apache.cordova.xapkreader.expansion/image.jpg" is working for you? "Unable to open content URL: content://org.apache.cordova.xapkreader.expansion/img/logo.png" How did you make the obb file? I just take the ing and video folders and zipped them. Then I just renamed the .zip file to .obb I seems to work but I couldn't load anything 😟 Thanks! |
For me it works well To create the obb file I zipped them then I changed .zip to .obb, just like you did. But when you zipped them, have you selected the |
No, I just compress the Zip file from my Mac using Right-click -> Compress. Should I use WinRar? |
give it a try.. |
Right. You must create the zip file with no compression. You can do it with the following command : |
😳 I don't know how to do It hehehehe. I've got 2 folders "video" and "img" and I want to put them together on the same bob file. I just selected them, right-click -> "Compress" and then I renamed the file to main.1.xx.xxxx.xxxx.zip and main.1.xx.xxxx.xxxx.obb. Can you tell me how can i do that with the command zip? Thanks! |
I tried with WinRar but It doesn't work 😟 I don't know what to do. It tell me "Unable to open content URL: ..."
But the It crashes and tells me that It's unable to open the content url 😟 when I try to load:
Any ideas? Thanks for all your answers! |
Which android version are you using to do the tests? I'm using Android 4.4.4 and I don't know if It could be a problem 😟 |
4.4.2 |
I tried with 4.4.4 and App crashes, same code on 4.3 doesn't crash but doesn't show any image (maybe the path is wrong 😟). |
The So you can try this fork if you want, or use the javascript method described in the README file for this repository. |
The code isn't unstable, just the plugin install files :P I will try to make it a point to get it all tested and worked out this week. My kids are back in school as of Today, so that should allow for more time. |
Hi! psyon! I installed this plugin from your repo and I think that the installation was nice. I only had to change one package name from the manifest.xml. The problem is that I can't use Thanks! |
have you verified that the expansion file has a compression level of 0? |
I think so, I tried to use the command that Moust told me I made a folder called main.2.xxxx.xxxx.xxxx, inside that folder I added 2 folders "img" and "video", and finally I compressed (with the command I said before) the folder main.2.xxxx.xxxx.xxxx. Doing all this process I think that I've got: |-> main.2.xxx.xxxx.xxxx.obb Then, If I want to access a file called, for example, logo.png that is into img folder, I should do something like that: Is that correct? Thanks! |
You don't want to compress the main.2.xxx.xxxx.xxxx folder, just the contents of it. Your img and videos folder should be in the root of the zip file. |
Ok, I'm going to try 😉 |
I did the Zip again, renamed It to .obb and then I copied It to the tablet and tried to load the img:
The app crashes and just after an error that tells me
The app doesn't crash it only says Thanks! |
I got the null pointer exception when compression level wasn't 0 in my tests... but, I did fine one other issue with the plugin.xml that I just pushed a change for, and I am testing right now. Stay tuned... and I will let you know when I make sure thats working, then we can troubleshoot without worrying about whether or not its my code. |
Great! Thanks psyon!!! |
Ok, my repo should be updated, and I made a test project, and installed the plugin, and everything worked fine. Give it a shot. The only XAPKDownloaderActivity.java tries to import io.cordova.helloworld, and my package name was different, so I had to change that. I had the same issue with Mousts repo though. Do you know if there is a way to have that source file be changed to match the package name automatically Moust? |
I'm having the same issues on both devices 😢 |
Yes it's an other problem.
But I haven't any idea of how to do it differently without this reference to the application package. :/ |
I worked with IIKoull outside this discussion to get things working. My repo should be all good to go. I can send a pull request when ever, but I would probably prefer you did a test since it is being merged into your code. Would you be able to do that, or do you just want me to send a pull request? |
Yeah! It works like a charm! Thanks again for your help psyon!! |
It sounds good! |
Um.... Neither moust's nor psyon's public versions actually has the mainVersion working correctly... psyon... did you update your version to one that can handle a mainVersion other than 1?... |
Yes, mine uses other versions just fine. What issue are you having? |
I am testing with a file that starts with "main.4.com."... |
The main version in my app is 20140812, and it's working fine to check and download the file. OH! I set PATCH_VERSION to the same version as my MAIN_VERSION, that may be why. Give that a try to see if that is the issue. |
Well.. it isn't, correct.
mainVersion isn't a version here, it's a boolean. And it's 1.
So yes... it uses the patch version... in any case, the code only checks and processes one file... |
Yes, I know what code you were talking about. boolean mainVersion = this.getIntent().getIntExtra("mainVersion", 1) > 0 ? true : false; That line will make mainVersion be true if MAIN_VERSION is any value 1 or greater. That boolean value is then passed along with the PATCH_VERSION to the expansionFilesDelivered() function, which passes them along to Helpers.getExpansionAPKFileName(). As long as MAIN_VERSION is one or greater, and PATCH_VERSION is set to what ever your main version is, the code will work. That code is different than the code used in XPAKReader.java, which calls ZipResourceFile expansionFile = APKExpansionSupport.getAPKExpansionZipFile(ctx, mainVersion, patchVersion); which passes both integer values for versions to getAPKExpansionZipFile() which then determines if it should use the patch file or not. So, to make it work for now, set MAIN_VERSION and PATCH_VERSION to the same thing. What needs to be done still though, is that the downloader needs to check to see if the patch and main version both exist, since a patch shouldn't exist without a main expansion file, and download either file that is missing if needed. |
All right. |
Question: Why not use (I have some code that doesn't crash using that, but it won't load any files either...) |
The downloader activity class of this plugin is in part based on the SampleDownloaderActivity class but adapted to some requirements for a Cordova project.. Further I did it with my limited Java/Android skills, so it can certainly be improve. Otherwise I solved the io.cordova.hellocordova.R import issue with the following code which does not require to import this package: I also reuse the psyon's work to integrate the provider's functionality and improved some part of the code. |
Way ahead of you -- No need to get the package name when you can just get the individual xml strings. For example, in
|
Simply setting MAIN_VERSION to 1 and the PATCH_VERSION to my version code (20140723) worked to make the app download the expansion file, but it did not work to access the file. I had to set MAIN_VERSION to the same version as PATCH_VERSION for it to work.
The text was updated successfully, but these errors were encountered: