cowbell / cordova-plugin-geofence

Geofencing plugin for cordova
Apache License 2.0
264 stars 318 forks source link

Android 8 #258

Open bigbossmaher opened 6 years ago

bigbossmaher commented 6 years ago

I think the plugin is not working on android oreo devices

aryalprakash commented 6 years ago

@bigbossmaher I'm also facing problem on oreo devices.

bigbossmaher commented 6 years ago

we are waiting answer

bobolat commented 6 years ago

no update?im facing it too

mgrubinger commented 6 years ago

FYI, I got the notifications working on Android 8 with jupesoftware's fork: https://github.com/jupesoftware/cordova-plugin-geofence

Maybe there will be a PR at some point to incorporate the changes back into this repo?

t2wu commented 6 years ago

@mgrubinger This project seems to use Lambda expression and my project has no support for it. How do I make sure that it does?

mgrubinger commented 6 years ago

(sorry for the previous incorrect answer) I just went through this again and used your fork: https://github.com/t2wu/cordova-plugin-geofence) Then, in build.gradle change:

compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_6
        targetCompatibility JavaVersion.VERSION_1_6
    }

to

compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

and add jackOptions.enabled true to defaultConfig {} block

That worked for me, hope it helps :)

netwrkx commented 6 years ago

any idea why i'm getting this error... i'm using https://github.com/t2wu/cordova-plugin-geofence

06-03 21:48:09.568 13489 13489 E AndroidRuntime: java.lang.RuntimeException: Una
ble to start receiver com.cowbell.cordova.geofence.ReceiveTransitionsReceiver: j
ava.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Strin
g java.lang.String.replace(java.lang.CharSequence, java.lang.CharSequence)' on a
 null object reference

06-03 17:36:37.013 27568 27568 E AndroidRuntime: Caused by: java.lang.NullPointe
rException: Attempt to invoke virtual method 'java.lang.String java.lang.String.
replace(java.lang.CharSequence, java.lang.CharSequence)' on a null object refere
nce
06-03 17:36:37.013 27568 27568 E AndroidRuntime:        at com.cowbell.cordova.g
eofence.GeoNotificationNotifier.notify(GeoNotificationNotifier.java:47)
06-03 17:36:37.013 27568 27568 E AndroidRuntime:        at com.cowbell.cordova.g
eofence.ReceiveTransitionsReceiver.onReceive(ReceiveTransitionsReceiver.java:93)
t2wu commented 6 years ago

@netwrkx That's embarrassing for me. I was just hacking it for own project (for some special needs on iOS). And now I know a better way to approach it but have yet to do it on the iOS. You should use https://github.com/jupesoftware/cordova-plugin-geofence instead.

t2wu commented 6 years ago

@mgrubinger Thanks for the tips. Those work to by pass the error. Then I got into

java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

Possibly because other plugins are using different versions of gson-2.3.jar file. Do you have any idea how to fix that?

netwrkx commented 6 years ago

@t2wu both projects are working and I didn't even change the java version to 1.8, just that notification.getTitle() on GeoNotificationNotifier.java return null. All I had to do was to comment that line. Thanks

netwrkx commented 6 years ago

@t2wu any idea why notification.getTitle() returns null

t2wu commented 6 years ago

I have no idea! I am not using notification. Right now I just want to know how to get it to work on Android 8.

@mgrubinger Do you have to do anything particular to make it work on Android 8? Because I heard it needs to be a service, and a with a service I should receive a notification as soon as the service is activated. But I don't think the notification is sent, and also geofence exit didn't work for me, at least not with GPS simulation.

luigi37 commented 5 years ago

Hi all, any news here? By commenting out notification.getTitle() on GeoNotificationNotifier.java I managed to have notifications on enter geofence working on Android simulator 7.0 but no luck on Android 8 real device. Additionally I had to add the geolocation plugin and start a watch on geolocation to make the Android simulator work....

RunfastCoder commented 5 years ago

It seems this plugin is not updated for Android 8. Is someone able to get notification on android 8 ?

Regards, Alex.

mgrubinger commented 5 years ago

sorry for the late reply.

in a recent project we used this fork, which works on Android 8: https://github.com/okode/cordova-plugin-geofence

Note: okode's fork prompts for the Location Permission on app launch, which is not a desired behavior for us. We therefore forked it again to disable the Location Permission on startup and manage permissions ourselves using https://github.com/dpa99c/cordova-diagnostic-plugin if you want to go that route.

Forks, and then some more forks :D

Good luck 👍

RunfastCoder commented 5 years ago

Hi mgrubinger,

So, In order to make it works on Android 8 I have to uninstall the plugin then add it again with : cordova plugin add https://github.com/cowbell/cordova-plugin-geofence

Right ?

Thanks.

mgrubinger commented 4 years ago

Hi @RunfastCoder,

yes, uninstall it, but then I would recommend using this fork: https://github.com/okode/cordova-plugin-geofence

cordova plugin add https://github.com/okode/cordova-plugin-geofence

At least it worked for me using this fork.

RunfastCoder commented 4 years ago

Hi @mgrubinger,

I've tried to create a brand new project but and when I install the plugin I get this error : Installing "cordova-plugin-compat" for android Plugin doesn't support this project's cordova-android version. cordova-android: 7.1.4, failed version requirement: <6.3.0 Then, I get an error when I build the app with ionic cordova build android --prod : BUILD FAILED in 6s [ERROR] An error occurred while running subprocess cordova.

    cordova build android exited with exit code 1.

HERE IS THE DETAILS : BUILD FAILED in 6s 27 actionable tasks: 7 executed, 20 up-to-date /Users/administrator/projectPriv/platforms/android/gradlew: Command failed with exit code 1 Error output: /Users/administrator/projectPriv/platforms/android/app/src/main/java/com/cowbell/cordova/geofence/GeoNotificationNotifier.java:39: error: constructor Builder in class Builder cannot be applied to given types; mBuilder = new NotificationCompat.Builder(context, notificationChannel.getId()); ^ required: Context found: Context,String reason: actual and formal argument lists differ in length 1 error

FAILURE: Build failed with an exception.

Any help ?