-
Notifications
You must be signed in to change notification settings - Fork 274
PhoneGap Build Installation
#Installation instructions for PhoneGap Build.#
The last days, PGB has tried to include gradle support in its CLI-5 versions, and as of 2015-09-30 this seems to work, finally; see http://phonegap.com/blog/phonegap-build/ and check current status PGB tweets in http://status.build.phonegap.com/
This is what we at Logics Software did to use the master 0.6.1 version of the premium plugin in our apps with PGB - it is far easier than before, and technically better (hopefully):
- Create a new branch based on #master, e.g.
grdl
- Set your unique plugin id and version (see below)
- No more modifications required!
###Add Your Private PGB Plugin###
- As usual (see below)
- Note: PGB does not support "public PGB-plugins" anymore, but your private PGB-plugins are OK
- Since PGB has reverted default configurations several times the last days, we currently force cli-5.2.0 and gradle:
<preference name="phonegap-version" value="cli-5.2.0" />
<preference name="android-build-tool" value="gradle" />
- Do not forget to include the whitelist plugin: http://community.phonegap.com/nitobi/topics/notes-for-upgrading-to-cli-5-1-1-on-pgb Since there are still problems with ios 9 on PGB, we use the legacy plugin instead
<gap:plugin name="cordova-plugin-legacy-whitelist" source="npm" />
<allow-navigation href="*" />
- And in our HTML file, we include the "allow all" CSP (to get rid of the plugin logcat warnings):
<meta http-equiv="Content-Security-Policy" content="default-src * 'unsafe-inline' 'unsafe-eval'" />
For us, this works - Good luck!
With PGB, using the premium version of this plugin in you app is more difficult than using the free version:
- Due to license restrictions, a public PGB plugin "cordova-background-geolocation (premium)" is not allowed; you first must prepare and add your own private PGB plugin, and then add this to your apps as usual
- For private PGB plugins you must have a paid PhonegapBuild account - the free account is not sufficient.
- PGB does not support all the Cordova features used in the plugin, especially if you want to compile for Android
The following shows what we at Logics Software did to use the edge 0.5.4 version of the premium plugin in our apps with PGB.
###Github Setup###
- Fork the transistorsoft repository to your own github account
- Create a new branch based on edge 0.5.4, e.g.
edge_pgb
###Make your plugin.xml PGB Compatible###
- Since PGB uses a global namespace for all its plugins, you must make your own unique plugin id.
Instead of
id="com.transistorsoft.cordova.background-geolocation"
use something likecom.mycompany.cordova.background-geolocation
- For our tests, we added a counter to the transistorsoft plugin version, something like
version="0.5.40"
,version="0.5.41"
- Since we do not use Cordova 5 with PGB, we uncommented / commented out the relevant portions
This is how our plugin.xml looks like now:
<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="de.logics.cordova.background-geolocation"
version="0.5.45">
<name>BackgroundGeolocation</name>
<description>Sophisticated, battery-efficient background-geolocation plugin for Cordova</description>
<license>MIT</license>
<keywords>cordova, phonegap, background geolocation</keywords>
<engines>
<engine name="cordova" version=">=3.0.0" />
</engines>
<!--
Pre-Cordova 5, non-npm plugin reference. Uncomment this if you're not using Cordova 5.
-->
<dependency id="org.apache.cordova.dialogs" />
<!-- Cordova 5 npm-style plugin referernce. Comment this out if you're not using Cordova 5
<dependency id="cordova-plugin-dialogs" />
-->
<js-module ...
###Add Your Private PGB Plugin###
- In the PGB menu bar, select Plugins
- In the PGB Plugins page, select Submit Plugin. Note: this requires a paid PGB account.
- Select Plugin Type Private - only I can use this plugin. Note: Due to license restrictions, public plugins are not allowed
- Set the Plugin Git Repository URL to your private Github repo.
- In Optional Tag or Branch, type your repo branch, e.g.
edge_pgb
- Click Submit Plugin
Selecting Your Plugins, you should now see your private plugin, showing the plugin version you specified in the plugin.xlm
.
Notes on "updating" your PGB plugin:
- Whenever you update the Github repo of your plugin branch, you must submit the repo as a new PGB plugin version as well: On submit, PGB forks your repo and then uses this cached version
- For this to work, you must update the version (or the id) of your plugin in the 'plugin.xml`. That is why we we added a counter to the transistorsoft plugin version
- Seems you must update your current app source code as well after submitting a new plugin version: This prevents PGB from using the previous plugin version for the untouched app (just upload same app source code again)..
###Add Android Support 0.5.4### This step is only required if you want to compile your app for Android.
For Android, gradle is used to compile the plugin before compiling your app, as specified in file src/android/build.gradle
:
compile 'com.google.android.gms:play-services:7.5.0'
compile 'de.greenrobot:eventbus:3.0.0-beta1'
compile(name:'tslocationmanager', ext:'aar')
Since gradle is not supported in PGB, you must "hand-code" these gradle steps:
- The plugin requires the Google Play-Services, version 7.5.0.
Since PGB does not support the
Framework
tag, you must include a suitable plugin via thedependency
tag instead. For this, we use our version of the ubiquitous but outdatedcom.google.play
plugin. - The plugin requires the
eventbus
lib, version 3.0.0-beta1. You can download the respectiveeventbus-3.0.0-beta1.jar
from http://maven.org, and copy this JAR tosrc/android
in your repo. - The plugin requires the transistorsoft background geolocation lib. You can find the respective
classes.jar
file insrc/android/libs/tslocationmanager.aar
: Open this ZIP file, and copyclasses.jar
tosrc/android
as well.
In your repo, src/android
now contains the two addional jars eventbus-3.0.0-beta1.jar
and classes.jar
, and you can update the plugin.xml
accordingly:
- Out-comment the not supported
framework
andresource-file
tags - Add the
dependency
tag for your Google play services plugin - Add the two
source-file
tags for the two additional jars
The Android part of out plugin.xml
now starts like this:
<platform name="android">
<!-- removed for PGB: default versions 3.7.0 / 3.7.0 / 3.7.0 - no cli-5.1.1 -->
<!--
<framework src="src/android/build.gradle" custom="true" type="gradleReference" />
<resource-file src="src/android/libs/tslocationmanager.aar" target="src/android/libs/tslocationmanager.aar" />
-->
<source-file src="src/android/CDVBackgroundGeolocation.java" target-dir="src/com/transistorsoft/cordova/bggeo" />
<source-file src="src/android/BootReceiver.java" target-dir="src/com/transistorsoft/cordova/bggeo" />
<!-- added for PGB: default versions 3.7.0 / 3.7.0 / 3.7.0 - no cli-5.1.1 -->
<dependency id="com.google.playservices" url="https://github.com/LogicsSoftware/google-play-services.git" /><!-- V24, instead of framework -->
<source-file src="src/android/eventbus-3.0.0-beta1.jar" target-dir="libs" />
<source-file src="src/android/classes.jar" target-dir="libs" /> <!-- transistor-locationmanager.jar, extracted from libs/tslocationmanager.aar -->
<config-file target="AndroidManifest.xml" ...
Do not forget to increment the plugin version before resubmitting your plugin to PGB!
###Add Android Support 0.5.5+### This step is only required if you want to compile your app for Android.
Starting with Android 0.5.5, you find one more entry in file src/android/build.gradle
:
compile 'com.mcxiaoke.volley:library:1.0.18'
Starting with 0.5.5, the plugin requires the volley
lib, version 1.0.18. Proceed as with the eventbus
lib for 0.5.4:
- Download the respective
library-1.0.18.jar
from http://maven.org and copy this JAR tosrc/android
in your repo. - Add the respective
source-file
tag to yourplugin.xml
:
<source-file src="src/android/library-1.0.18.jar" target-dir="libs" />
Notes when merging an updated transistorsoft base into your repository
- In your
plugin.xml
, care for correct plugin id and version (append your incremented sequence number) - Extract the current
classes.jar
from thesrc/android/libs/tslocationmanager.aar
tosrc/android/
- Check the current
src/android/build.gradle
for new or updated entries. - Download the required JARs to your
src/android/
dir and care for the corresponding<source-file src="src/android/XXX.jar" target-dir="libs" />
tag in yourplugin.xml
- Submit your updated repo as private plugin to PGB
- Updload (probably same) app source code to PGB and build the app
Good Luck! For plugin 0.5.8 this worked for us..