Skip to content

Instantly share code, notes, and snippets.

@joshbuchea
Last active October 2, 2017 12:28
Show Gist options
  • Save joshbuchea/775711c040ab94a4efc8 to your computer and use it in GitHub Desktop.
Save joshbuchea/775711c040ab94a4efc8 to your computer and use it in GitHub Desktop.
Steps to get cordova-plugin-xapkreader working with Ionic/Cordova 5 project

Android Build - Expension Steps

These are instructions for configuring an Android expansion pack for an Ionic project (Cordova 5.0). These instructions include the bundle ID of a specific app, please replace with your own.

Resources:

Create Expansion File Archive

  1. Create a directory named main_expansion in the root directory of your project. Place any expansion files inside this folder.
  2. Create archive: zip -v -dc -r -x \*.DS_Store -Z store main_expansion main_expansion

Rename Expansion File

Rename main_expansion.zip using the following format: [main|patch].<expansion-version>.<package-name>.obb

Example: main.100002.com.companyname.myapp.obb

Copy Expansion Files to Device for Testing

Create directory com.companyname.myapp inside of /Android/obb/. Result should be: <Device Storage>/Android/obb/com.companyname.myapp/

For Ben Bunny:

<Device Storage>/Android/obb/com.code_monkeys.app.benbunny/

Note: Replace any hyphens with an underscore. Our domain is actually code-monkeys.com.

Update HTML/CSS/JS References to Expansion Pack Files

Previous: <img src="folder/wallpaper2.png">

Updated: <img src="content://com.companyname.myapp/main_expansion/folder/wallpaper2.png">

For Ben Bunny: <source src="content://com.code-monkeys.app.benbunny/main_expansion/videos/page3.mp4" type="video/mp4">

Prepare & Install Plugin

Download & prepare plugin

cd ~
mkdir -p ~/projects/cordova-plugins
cd ~/projects/cordova-plugins
git clone git@github.com:agamemnus/cordova-plugin-xapkreader.git
cd cordova-plugin-xapkreader
git checkout cordova-5.0

Install Plugin

ionic plugin add ~/projects/cordova-plugins/cordova-plugin-xapkreader

Modify android.json (plugins/android.json)

In android.json, look for and modify com.test.expansion and YOUR_GOOGLE_PLAY_LICENSE_KEY:

expansion authority URI (xapk_expansion_authority):

com.code-monkeys.app.benbunny

google play public key (xapk_google_play_public_key):

Note:

Remove any duplicate entries for xapk_expansion_authority & xapk_google_play_public_key.

Modify build-extras.gradle (platforms/android/com.flyingsoftgames.xapkreader/$PROJECT_NAME-downloader_library/build-extras.gradle)

Modify build-extras.gradle (platforms/android/com.flyingsoftgames.xapkreader/benbunny-downloader_library/build-extras.gradle)

Replace $PROJECT_NAME-library with benbunny-library

Replace file contents with:

dependencies {
    debugCompile project(path: ':com.flyingsoftgames.xapkreader:benbunny-library',configuration: "debug")
    releaseCompile project(path: ':com.flyingsoftgames.xapkreader:benbunny-library',configuration: "release")
}
@vance
Copy link

vance commented Jun 27, 2016

I've tried every combination, including relative paths... I can't get it to compile.

  • Where:
    Script '/Users/username/dev/fscape_gap/app/platforms/android/com.flyingsoftgames.xapkreader/explore-downloader_library/build-extras.gradle' line: 2

  • What went wrong:
    A problem occurred evaluating script.

    Project with path ':com.flyingsoftgames.xapkreader:explore-library' could not be found in project ':com.flyingsoftgames.xapkreader:downloader_library'.

Also tried ..: for relative paths to up a level.

dependencies {
    debugCompile project(path: '..:explore-library',configuration: "debug")
    releaseCompile project(path: '..:explore-library',configuration: "release")
}

where path is this with app name 'explore'

android/com.flyingsoftgames.xapkreader
               /explore-downloader_library
                      +build-exras.gradle
               /explore-library

@oilenrock07
Copy link

I am able to load image successfully like this (image path is hardcoded):

<img src="content://com.lychee.mymovies/main_expansion/tt0316654.jpg" >

but not this (even though they have same value):

<img [src]="movie.Poster" >

Please advise. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment