1

We are working on a project with MobileFirst Platform 7.1, we are using mobilefirst-cli with cordova to create a project : mfp cordova create.

After we add android platform with : mfp cordova platform add android

Then we add this plugin : https://github.com/mauron85/cordova-plugin-background-geolocation

With this command : mfp cordova plugin add cordova-plugin-mauron85-background-geolocation

We have this message :

Adding "cordova-plugin-mauron85-background-geolocation"

Plugin "cordova-plugin-mauron85-background-geolocation" added successfully

But when I build my project, my plugins is not added in \platforms\android\assets\www\plugins

We used this plugin in a P.O.C. without mobilefirst and it worked.

If someone know this issue? Thank you in advance.

Community
  • 1
  • 1

1 Answers1

0

The plugin you are trying to add uses framework tags which are available in Cordova-Android 4.x and above. The version of Cordova-Android in MobileFirst Platform Foundation 7.1 is 3.6.4, so will not be able to parse that tag.

To get this plugin working, you'll need to install the iFix IF20160224-2343 or later. This iFix has changes that will allow you to import your project into Android Studio.

After installing this iFix, you'll want to clone the plugin and modify its plugin.xml. Remove all of the framework tags and the meta-data tag about google_play_services_version. Next, add this plugin to your project using: mfp cordova plugin add <path_to_plugin> The plugin should be added fine at this point.

Now to add Google Play Services and support v4 back into your app, you will need to import your project into Android Studio. Do so by importing the build.gradle file in your project's platform/android folder. Add the Google Play Services and support v4 dependencies to build.gradle file. Example of Google Play Services dependency

The version originally in your plugin.xml was a '+' meaning pull the latest (which currently is 8.4.0). 8.4.0 is incompatible with your compileSDKVersion 19, so we would suggest using an older version of Google Play Services, otherwise you would have to use a later SDK version. Keep in mind that SDK 19 is the fully supported version for this Cordova version, so we recommend changing the version of Google Play Services over changing the SDK version.

Run the app from Android Studio. This will build with Gradle instead of Ant, which the CLI uses, and pull down all of the dependencies correctly.

ktop
  • 16
  • 1
  • I managed to build my application as you said but it's looks like now MFP didn't work : `java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ibm.scanaa/com.ibm.scanaa.CordovaApp}: java.lang.RuntimeException: WLConfig(): Can't load wlclient.properties file` I had this in build.gradle : `compile 'com.android.support:support-v4:21.1.2'` `compile 'com.google.android.gms:play-services:8.4.0'` defaultConfig { multiDexEnabled true versionCode Integer.parseInt("" + getVersionCodeFromManifest() + "0") } dexOptions { javaMaxHeapSize "4g" } – Benjamin Dupont Mar 08 '16 at 17:23
  • Try using Google Play Services 8.3.0 if you have Android SDK 21 or 22. I've had problems where 8.4.0 only works with Android SDK 23. After importing into Android Studio, you should use Android Studio to deploy your app to emulator/device from now on. Use MFP CLI to push to the server. – ktop Mar 08 '16 at 18:00
  • I just tried adding this plugin in myself and I got it working on a plain MFP 7.1 app with adding these additional settings to build.gradle. And remember to only run from Android Studio. Since Google Play services is only being pulled in through Gradle, doing a mfp cordova run will build with ANT, which will error. `defaultConfig { multiDexEnabled true } dexOptions { javaMaxHeapSize "4g" }` These should go into the android{} closure of build.gradle – ktop Mar 08 '16 at 18:43
  • I forgot to push my application to my MFP Server, now it works, thank you for your help! – Benjamin Dupont Mar 09 '16 at 09:17
  • Interesting information. Where could I find those requirements on the official website? For example: which version of cordova-android to use for cordova-plugin-mfp version 8 and above? – alex351 Oct 02 '17 at 07:57