agamemnus / cordova-plugin-xapkreader

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

Render extension apk scheme/path customizable #136

Closed maurocolella closed 5 years ago

agamemnus commented 5 years ago

Couple things...

1) The main branch is supposed to be empty.

2) I'm not sure what you are doing here.... you are removing the xapk_expansion_authority string but adding http://localhost:8888 instead, with no specific expansion authority? This seems like a mega-breaking change.

Let's break this down...

My current code is:

cr.call(Uri.parse("content://" + expansionAuthority), "set_expansion_file_version_data", null, bundle);

But you want to do:

String baseUri = bundle.getString("xapk_ui_uri", "");
cr.call(Uri.parse(baseUri), "set_expansion_file_version_data", null, bundle);

So if you want to use http://localhost:8888 as an alternative, how about this?

String baseURI= bundle.getString("xapk_base_uri", "");
if (baseUri == '') String baseURI = "content://" + bundle.getString("xapk_expansion_authority", "");
cr.call(Uri.parse(baseURI), "set_expansion_file_version_data", null, bundle);`

(and then the default should be an empty string, not http://localhost:8888) (also, not sure why you are calling it xapk_ui_uri .. why not just xapk_base_uri?

maurocolella commented 5 years ago

Ok, first of all @agamemnus , thank you for your reply.

Believe it or not, I was not intending for this PR to be remerged toward the master; I was instead waiting for instructions for a rebase. These didn't come and I merely opened the PR for discussion.

Now, I will tip for help clarifying some of the aspects here indeed. Couple of coffees; I am familiar with Java, not so much with the Android APIs.

What I am trying is to use http://localhost:8888 or any other pseudo-http uri to access content from an Android Expansion APK. I say pseudo-http; in the case where URis don't match, I would like for requests to just go to an actual httpd, embedded or otherwise.

This seems to offer more opportunities for fallback than vanilla content URIs.

Further: I am having problems when deploying the plugin from that branch, with Cordova 8 I get:

cordova/platforms/android/com.flyingsoftgames.xapkreader/app-downloader_library/build.gradle' line: 47

* What went wrong:
A problem occurred evaluating project ':com.flyingsoftgames.xapkreader:downloader_library'.
> Could not get unknown property 'cdvCompileSdkVersion' for object of type com.android.build.gradle.LibraryExtension.

And

cordova/platforms/android/gradlew: Command failed with exit code 1 Error output:
Picked up _JAVA_OPTIONS: 
Failed to notify ProjectEvaluationListener.afterEvaluate(), but primary configuration failure takes precedence.
java.lang.IllegalStateException: compileSdkVersion is not specified.

Would love to hear your thoughts.

agamemnus commented 5 years ago

Those error messages seem familiar... I think I've seen someone post them before... Unfortunately I've been AWOL for a bit on this plugin. It's kind of annoying when the plugin keeps breaking because they keep changing everything!

So those changes you just made in those last 3 commits -- do they fix any of those two problems you just mentioned?

In any case, for those 3 commits, I would be worried that potentially it could break Cordova 6.5 builds (even though Gradle and Cordova versions I guess are separate things). We'd have to make a new branch where the problems you cited only started happening -- maybe it's not 8. Could be 7, etcetc.

maurocolella commented 5 years ago

Unfortunately, no luck fixing the build issues with these. I have been playing with environment variables to target specific sdks and build tools, I managed to make some progress, but there seem to be missing references to dependencies.

If the approach (using an http scheme and http-like urls) seems sound to you (does it?), I will maybe try to update the libraries.

It seems their latest version are still backward-compatible with Android4.4, and could potentially resolve some of the conflicts.

After that, I'll have to rebase on Monday. If I find the changes helpful, I could potentially open a separate request, and propose a version with upgraded libraries.

agamemnus commented 5 years ago

If the approach (using an http scheme and http-like urls) seems sound to you (does it?), I will maybe try to update the libraries.

Yes, it seems okay.

I'll take a look again tomorrow to check your progress... good luck...!

maurocolella commented 5 years ago

Thank you!

On Sat, 24 Nov 2018 at 16:15 agamemnus notifications@github.com wrote:

If the approach (using an http scheme and http-like urls) seems sound to you (does it?), I will maybe try to update the libraries.

Yes, it seems okay.

I'll take a look again tomorrow to check your progress... good luck...!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/agamemnus/cordova-plugin-xapkreader/pull/136#issuecomment-441351434, or mute the thread https://github.com/notifications/unsubscribe-auth/AAuftBLmvK40fAthDYrDNtu38IanclNyks5uyQAHgaJpZM4Ywvvj .

maurocolella commented 5 years ago

I am almost there. Aside from a missing string (in my cordova project using the plugin, cordova/platforms/android/app/src/main/res/values) and the need to update the build.gradle of cordova/platforms/android/com.flyingsoftgames.xapkreader/app-apkx_library

To use:

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    implementation project(":CordovaLib")
}

The plugin deploys ok with the new dependencies.

BUT compilation fails with:

cordova/platforms/android/com.flyingsoftgames.xapkreader/app-apkx_library/src/com/google/android/vending/expansion/downloader/impl/DownloaderService.java:26:
error: package com.google.android.vending.licensing does not exist
import com.google.android.vending.licensing.AESObfuscator;

side-note: I did go for the tip. But gittip is gone, I avoid Paypal for personal reasons - I find the documentary requirements excessive - and I took a look at your game, but I definitely qualify as a heavily privacy-loving person. By all means, give me any other way to express gratitude and I will.

maurocolella commented 5 years ago

Fixed the errors a bit further and now I get:

error: cannot find symbol
import com.google.android.vending.licensing.AESObfuscator;
agamemnus commented 5 years ago

NIce. Yes, need to update the comments regarding gittip and the game, I guess...

I'll look at this obfuscator thing shortly. I wonder if maybe we don't need it... But probably just needs a path change...

agamemnus commented 5 years ago

Hmm. I wonder if you actually added licensing directory to your project, or I dunno...

The current structure of the two Google libraries is as follows:

android-sdk/extras/google/play_apk_expansion/downloader_library
android-sdk/extras/google/play_licensing

As you can see, they don't share a parent directory.

maurocolella commented 5 years ago

At present, both dependencies compile. However, for the licensing library, I get:

...uses or overrides a deprecated API. 
Note: Recompile with -Xlint:deprecation for details. 

This is using android-28 for the compileSDK with buildtools 27.0.1, and the latest revisions of Google dependencies.

I am now looking at community-maintained better-apk-expansion to help resolve the target inconsistencies.

agamemnus commented 5 years ago

Ok, good!

"Slightly" over-engineered... a bit of an under-statement. And then not maintained!

I would happily switch over to that if it works without warnings/errors.

maurocolella commented 5 years ago

Me too! Will keep you posted.

On Mon, 26 Nov 2018 at 11:08 agamemnus notifications@github.com wrote:

Ok, good!

"Slightly" over-engineered... a bit of an under-statement. And then not maintained!

I would happily switch over to that if it works without warnings/errors.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/agamemnus/cordova-plugin-xapkreader/pull/136#issuecomment-441506183, or mute the thread https://github.com/notifications/unsubscribe-auth/AAuftKkVnSsmCcjb4Mk04DxMk4wTc5oIks5uy1sPgaJpZM4Ywvvj .

maurocolella commented 5 years ago

I am getting there, by bundling the new libraries through jitpack, like:

<framework src="com.github.bolein:better-licensing:1.5.0" />
<framework src="com.github.bolein.better-apk-expansion:downloader_library:5.0.3" />

When deploying the plugin, I still have to add a manual reference to jitpack in buld.gradle, as per instructions from the author of these libraries.

I now have to further refactor the code in order to make use of the new interfaces.

agamemnus commented 5 years ago

This is just about nap time for me, but let me know if you get stuck somewhere and maybe I could help.

maurocolella commented 5 years ago

Thank you. Think I'll be ok. It should be possible to contribute some of these back - the deployment with jitpack is really a cinch.

maurocolella commented 5 years ago

I'll have to withdraw this PR, delete the repo and rebase.

I was able to achieve what I want, thanks a lot @agamemnus.

The above <framework> code, and all relevant instructions on https://github.com/bolein/better-apk-expansion were key for me.

Simply set the framework references, update your build.gradle to include a maven reference for jitpack, then update the interface as directed.

I'll give it a couple of hours before I close this.

maurocolella commented 5 years ago

Actually, I need help one last time. Something goes awry,

     Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x0
        at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:216)
        at android.content.res.Resources.getInteger(Resources.java:1094)
        at com.flyingsoftgames.xapkreader.XAPKReader.initialize(XAPKReader.java:71)
agamemnus commented 5 years ago

Feels like some old files got in the way...

On Tue, Nov 27, 2018, 1:31 AM Mauro Colella <notifications@github.com wrote:

Actually, I need help one last time. Something goes awry,

 Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x0
    at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:216)
    at android.content.res.Resources.getInteger(Resources.java:1094)
    at com.flyingsoftgames.xapkreader.XAPKReader.initialize(XAPKReader.java:71)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/agamemnus/cordova-plugin-xapkreader/pull/136#issuecomment-441944259, or mute the thread https://github.com/notifications/unsubscribe-auth/ADFJWKcg3kb7bxWtbHZtNc9tOaEV7_hnks5uzNwsgaJpZM4Ywvvj .

agamemnus commented 5 years ago

Thank you. I will patch.

On Wed, Nov 28, 2018, 12:33 AM Mauro Colella <notifications@github.com wrote:

Closed #136 https://github.com/agamemnus/cordova-plugin-xapkreader/pull/136.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/agamemnus/cordova-plugin-xapkreader/pull/136#event-1991487600, or mute the thread https://github.com/notifications/unsubscribe-auth/ADFJWG9ZpCnfJ-qwqB9tMCy0X8hO5Slqks5uziATgaJpZM4Ywvvj .