agamemnus / cordova-plugin-xapkreader

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

Compile issues using api 27+ (probably 23+) and cordova android 7.1.1 #133

Open chancezeus opened 5 years ago

chancezeus commented 5 years ago

I ran into various compile issues (undefined properties, missing "org.apache.http", etc) when trying to compile an android project with cordova-android version 7.1.1. Looking to solve some of the problems I googled around and found this github repo: https://github.com/danikula/Google-Play-Expansion-File. Since most of the problems originated from the expansion libraries I decided to try and resolve at least that part by using these pre-compiled versions.

Simply put: Step 1: create a build-xapkreader.gradle with the following content

repositories {
    maven { url 'https://dl.bintray.com/alexeydanilov/apk-expansion' }
}

Step 2: replace the following

<framework src="android-sdk/extras/google/play_apk_expansion/downloader_library" custom="true"/>
<framework src="android-sdk/extras/google/play_licensing/library" custom="true" />

with

<framework src="build-xapkreader.gradle" custom="true" type="gradleReference" />
<framework src="com.danikula.expansion:expansion:1.3.4@aar" />
<framework src="com.danikula.expansion:license:1.7.0@aar" />

Et voila: the app compiles

The last remaining issue is a folder structure issue, namely the res/values/xapkreader.xml has moved from the platforms/android folder into the platforms/android/app/src/main folder, leading to some warnings during plugin install because it cannot update the preferences properly. The only solution I can think of for this issue is using a hook instead defining these updates in config.xml, but I leave that till a later moment.

For now I suggest at least removing the uncompiled versions of the downloader and licensing libraries and using either the provided solution or compile them yourself and provide the resulting aar file(s) with the plugin (please PM if you need info on howto add "local" aar files, did that for a different custom plugin too).

chancezeus commented 5 years ago

Found the fix for the folder structure issue too according to the docs (see https://cordova.apache.org/docs/en/6.x/plugin_ref/spec.html#config-file) you can use a * as a wildcard and it will search the entire directory until it finds a matching file so instead of <config-file target="res/values/xapkreader.xml" parent="/*"> you should use <config-file target="*/values/xapkreader.xml" parent="/*">

agamemnus commented 5 years ago

Thanks for these helpful tips.

chancezeus commented 5 years ago

You're welcome, I find it interesting that google removed (or at least "blacklisted") the entire org.apache.http module, but never updated their own apk expansion (related) libraries. My first step towards fixing it was replacing the provided libraries with the newest (locally installed) versions, but that too was complaining about the missing org.apache.http imports.

agamemnus commented 5 years ago

It's definitely interesting...