transistorsoft / cordova-background-geolocation-lt

The most sophisticated background location-tracking & geofencing module with battery-conscious motion-detection intelligence for iOS and Android.
http://www.transistorsoft.com/shop/products/cordova-background-geolocation
Other
660 stars 277 forks source link

run on cordova-android: 6.3.0 #690

Closed gautambisht closed 6 years ago

gautambisht commented 6 years ago

I am trying to build an existing old code base using Ionic with IBM MobileFirst. The limitation with the IBM MobileFirst is it does not work with Cordova above 7.1 version. I am facing issue while building the Android app, it throws an error using this command “ionic Cordova platform add android@6.3.0“

Installing "cordova-background-geolocation" for android Plugin doesn't support this project's cordova-android version. cordova-android: 6.3.0, failed version requirement: >=7.0.0 Skipping 'cordova-background-geolocation' for android

My package.json configuration

"cordova-background-geolocation": "git+https://2cXXXXXXXX@github.com/transistorsoft/cordova-background-geolocation.git",

 "cordova-background-geolocation": {
    "LICENSE": "2205.........XXXX",
    "GOOGLE_API_VERSION": "11.8.0",
    "APPCOMPAT_VERSION": "24.1.0",
    "BACKGROUND_MODE_LOCATION": "<string>location</string>",
    "LOCATION_ALWAYS_AND_WHEN_IN_USE_USAGE_DESCRIPTION": "This app requires constant access to your location in order to track your position, even when the screen is off or the app is in the background.",
    "LOCATION_ALWAYS_USAGE_DESCRIPTION": "This app requires constant access to your location in order to track your position, even when the screen is off or the app is in the background.",
    "LOCATION_WHEN_IN_USE_USAGE_DESCRIPTION": "This app requires constant access to your location in order to track your position.",
    "MOTION_USAGE_DESCRIPTION": "Using the accelerometer increases battery-efficiency by intelligently toggling location-tracking only when the device is detected to be moving."
  }

Plugin list -

call-number 0.0.2 "Cordova Call Number Plugin" com.googlemaps.ios 2.6.0 "Google Maps SDK for iOS" cordova-background-geolocation 2.12.2 "BackgroundGeolocation" cordova-custom-config 5.0.2 "cordova-custom-config" cordova-plugin-add-swift-support 1.7.2 "AddSwiftSupport" cordova-plugin-background-fetch 5.4.1 "CDVBackgroundFetch" cordova-plugin-cocoalumberjack 0.0.4 "CocoaLumberjack" cordova-plugin-device 1.1.7 "Device" cordova-plugin-dialogs 1.3.4 "Notification" cordova-plugin-fingerprint-aio 1.3.3 "FingerprintAllInOne" cordova-plugin-globalization 1.11.0 "Globalization" cordova-plugin-google-analytics 1.8.3 "Google Universal Analytics Plugin" cordova-plugin-googlemaps 2.2.5 "cordova-plugin-googlemaps" cordova-plugin-inappbrowser 1.7.2 "InAppBrowser" cordova-plugin-ionic-webview 1.2.1 "cordova-plugin-ionic-webview" cordova-plugin-jumbomode 1.0 "Cordova Jumbo Mode" cordova-plugin-mfp 8.0.2017102403 "IBM MobileFirst Platform Foundation" cordova-plugin-mfp-jsonstore 8.0.2018040508 "IBM MobileFirst Platform Foundation JSONStore" cordova-plugin-mfp-push 8.0.2018040410 "IBM MobileFirst Platform Foundation - Push Notifications" cordova-plugin-network-information 1.3.4 "Network Information" cordova-plugin-okhttp 2.0.0 "OkHttp" cordova-plugin-secure-storage 2.6.8 "SecureStorage" cordova-plugin-splashscreen 4.1.0 "Splashscreen" cordova-plugin-statusbar 2.4.2 "StatusBar" cordova-plugin-whitelist 1.3.3 "Whitelist" cordova-plugin-x-toast 2.6.2 "Toast" cordova.plugins.diagnostic 3.9.2 "Diagnostic" ionic-plugin-keyboard 2.2.1 "Keyboard"

This is my system configuration

cli packages: (/usr/local/lib/node_modules)

@ionic/cli-utils  : 1.19.1
ionic (Ionic CLI) : 3.19.1

global packages:

cordova (Cordova CLI) : 7.1.0 

local packages:

@ionic/app-scripts : 3.1.0
Cordova Platforms  : android 6.3.0 ios 4.5.4
Ionic Framework    : ionic-angular 3.9.2

System:

Android SDK Tools : 26.1.1
ios-deploy        : 1.9.2 
Node              : v8.3.0
npm               : 5.3.0 
OS                : macOS Sierra
Xcode             : Xcode 9.2 Build version 9C40b 
christocracy commented 6 years ago

When you install the plugin from : "git+https://2cXXXXXXXX@github.com/transistorsoft/cordova-background-geolocation.git", you're installing the plugin from master, which requires Cordova 8 (cordova-android@7.x), which is version 2.12.2 of the plugin.

Use version 2.11.0 (append #2.11.0 on end of your install url)

gautambisht commented 6 years ago

I used bellow URL and ionic build took a long time but no error

Now when run "npm run dev:build:android" throws error LocationRequest locationRequest= LocationRequest.create() ^ class file for com.google.android.gms.internal.zzbfm not found
christocracy commented 6 years ago

post your platforms/android/project.properties

gautambisht commented 6 years ago

This file is automatically generated by Android Tools.

Do not modify this file -- YOUR CHANGES WILL BE ERASED!

#

This file must be checked in Version Control Systems.

#

To customize properties used by the Ant build system edit

"ant.properties", and override values to adapt the script to your

project structure.

#

To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):

proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

Project target.

target=android-26 android.library.reference.1=CordovaLib cordova.system.library.1=com.squareup.okhttp:okhttp-urlconnection:2+ cordova.gradle.include.1=cordova-plugin-mfp/fbt-build-extras.gradle cordova.system.library.2=com.google.android.gms:play-services-analytics:+ cordova.gradle.include.2=cordova-plugin-googlemaps/fbt-build-extras.gradle cordova.gradle.include.3=cordova-plugin-googlemaps/fbt-tbxml-android.gradle cordova.system.library.3=com.google.android.gms:play-services-maps:11.8.0 cordova.system.library.4=com.google.android.gms:play-services-location:11.8.0 cordova.system.library.5=com.android.support:support-core-utils:24.1.0 cordova.system.library.6=com.android.support:support-v4:26.+ cordova.system.library.7=com.android.support:appcompat-v7:26.+ cordova.gradle.include.4=cordova-plugin-jumbomode/fbt-build.gradle cordova.gradle.include.5=cordova-plugin-mfp-push/fbt-build-extras.gradle cordova.system.library.8=com.google.android.gms:play-services-gcm:+ cordova.gradle.include.6=cordova-plugin-background-fetch/fbt-build.gradle cordova.system.library.9=com.google.android.gms:play-services-location:11.8.0 cordova.system.library.10=com.android.support:appcompat-v7:24.1.0 cordova.gradle.include.7=cordova-background-geolocation/fbt-build.gradle

christocracy commented 6 years ago

A mess. All com.android.support and play-services version must be aligned. When you import multiple different versions, things go very bad. Your problem is related to your other 3rd party modules.

cordova.system.library.1=com.squareup.okhttp:okhttp-urlconnection:2+
cordova.gradle.include.1=cordova-plugin-mfp/fbt-build-extras.gradle
+cordova.system.library.2=com.google.android.gms:play-services-analytics:11.8.0
cordova.gradle.include.2=cordova-plugin-googlemaps/fbt-build-extras.gradle
cordova.gradle.include.3=cordova-plugin-googlemaps/fbt-tbxml-android.gradle
cordova.system.library.3=com.google.android.gms:play-services-maps:11.8.0
cordova.system.library.4=com.google.android.gms:play-services-location:11.8.0
+cordova.system.library.5=com.android.support:support-core-utils:27.0.0
+cordova.system.library.6=com.android.support:support-v4:27.0.0
+cordova.system.library.7=com.android.support:appcompat-v7:27.0.0
cordova.gradle.include.4=cordova-plugin-jumbomode/fbt-build.gradle
cordova.gradle.include.5=cordova-plugin-mfp-push/fbt-build-extras.gradle
+cordova.system.library.8=com.google.android.gms:play-services-gcm:11.8.0
cordova.gradle.include.6=cordova-plugin-background-fetch/fbt-build.gradle
cordova.system.library.9=com.google.android.gms:play-services-location:11.8.0
+cordova.system.library.10=com.android.support:appcompat-v7:27.0.0
gautambisht commented 6 years ago

any way to restrict this to use single versions for all app

christocracy commented 6 years ago

No, wish there was. Each plugin is responsible for its own dependencies.

My plugin exposes GOOGLE_API_VERSION, APP_COMPAT_V7_VERSION. You'll have to consult with each of your plugins to see if they expose similar config options. If they don't, raise an issue at those plugin repos and ask them to.

gautambisht commented 6 years ago

Thank you for the support

gautambisht commented 6 years ago

can you help me with this getting error while building uses-sdk:minSdkVersion 15 cannot be smaller than version 16 declared in library [com.transistorsoft:tsbackgroundfetch:0.2.0] /Users/gautam/Downloads/archive/platforms/android/build/intermediates/exploded-aar/com.transistorsoft/tsbackgroundfetch/0.2.0/AndroidManifest.xml Suggestion: use tools:overrideLibrary="com.transistorsoft.tsbackgroundfetch" to force usage

christocracy commented 6 years ago

In your config.xml:

<platform name="android">
    <preference name="android-minSdkVersion" value="16" />
gautambisht commented 6 years ago

it is there in config.xml

christocracy commented 6 years ago

The problem is in your Cordova app.

Destroy / re-add your android platform. NOTE: You'll have to reset your changes to project.properties above.

gautambisht commented 6 years ago

is this right way to do in config.xml

<plugin name="cordova-background-geolocation" spec="https://2c152****@github.com/transistorsoft/cordova-background-geolocation.git#2.11.0">
        <variable name="LICENSE" value="22053*****" />
        <variable name="GOOGLE_API_VERSION" value="11.8.0" />
        <variable name="APPCOMPAT_VERSION" value="24.1.0" />
        <variable name="BACKGROUND_MODE_LOCATION" value="&lt;string&gt;location&lt;/string&gt;" />
        <variable name="LOCATION_ALWAYS_AND_WHEN_IN_USE_USAGE_DESCRIPTION" value="This app requires constant access to your location in order to track your position, even when the screen is off or the app is in the background." />
        <variable name="LOCATION_ALWAYS_USAGE_DESCRIPTION" value="This app requires constant access to your location in order to track your position, even when the screen is off or the app is in the background." />
        <variable name="LOCATION_WHEN_IN_USE_USAGE_DESCRIPTION" value="This app requires constant access to your location in order to track your position." />
        <variable name="MOTION_USAGE_DESCRIPTION" value="Using the accelerometer increases battery-efficiency by intelligently toggling location-tracking only when the device is detected to be moving." />
    </plugin>
christocracy commented 6 years ago

Yes.