rekabhq / background_locator

A Flutter plugin for updating location in background.
MIT License
288 stars 329 forks source link

In debug, not receiving any location entries on physical device (Android Redmi Note 7, MIUI 12) #195

Open torian257x opened 3 years ago

torian257x commented 3 years ago

I copied your example over along with the extra files and packages needed to fix all errors from https://github.com/rekab-app/background_locator/tree/master/example/lib

problem is that no entries appear in

Last run: ?

Status: is running

I thought maybe something is off with my gps / location settings but if I enable mock locations https://play.google.com/store/apps/details?id=ru.gavrikov.mocklocations&hl=en&gl=US I am able to see that my gps signal moves on a path (I check in google maps) no updates anyway

btw I feel like, to enable the request permission in debug, I had to change my debug manifest to this:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.locatortest1">
    <!-- Flutter needs it to communicate with the running application
         to allow setting breakpoints, to provide hot reload, etc.
    -->
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.INTERNET"/>
</manifest>

If I left it like you had in the example, it wouldn't receive permission for location updates I think. There would just be no popup to give permission. After updating this manifest, and running flutter clean and redeploy the app, the popup did come.

here is my output:

event sent after app closed: {id: 0, progressId: null, message: Running "flutter pub get" in locatortest1...}
event sent after app closed: {id: 0, progressId: null, finished: true}
Launching lib/main.dart on Redmi Note 7 in debug mode...
Running Gradle task 'assembleDebug'...
✓ Built build/app/outputs/flutter-apk/app-debug.apk.
Installing build/app/outputs/flutter-apk/app.apk...
Waiting for Redmi Note 7 to report its views...
I/OpenGLRenderer(17082): Davey! duration=825ms; Flags=1, IntendedVsync=65572605031580, Vsync=65572621698246, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=65572631513682, AnimationStart=65572631622120, PerformTraversalsStart=65572631630818, DrawStart=65573349218943, SyncQueued=65573359170974, SyncStart=65573359514047, IssueDrawCommandsStart=65573359887120, SwapBuffers=65573428561182, FrameCompleted=65573430957484, DequeueBufferDuration=2096000, QueueBufferDuration=1010000, 
I/Choreographer(17082): Skipped 47 frames!  The application may be doing too much work on its main thread.
W/Looper  (17082): Slow Looper main: doFrame is 798ms late because of 2 msg, msg 1 took 801ms (seq=10 running=31ms runnable=10ms io=50ms late=26ms h=android.view.Choreographer$FrameHandler c=android.view.Choreographer$FrameDisplayEventReceiver)
Debug service listening on ws://127.0.0.1:41685/kxDTO-ekp78=/ws
Syncing files to device Redmi Note 7...
I/flutter (17082): Initializing...
W/le.locatortest(17082): Accessing hidden method Lsun/misc/Unsafe;->getUnsafe()Lsun/misc/Unsafe; (greylist,core-platform-api, linking, allowed)
W/le.locatortest(17082): Accessing hidden method Lsun/misc/Unsafe;->objectFieldOffset(Ljava/lang/reflect/Field;)J (greylist,core-platform-api, linking, allowed)
W/le.locatortest(17082): Accessing hidden method Lsun/misc/Unsafe;->compareAndSwapObject(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z (greylist, linking, allowed)
W/le.locatortest(17082): Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, linking, allowed)
I/flutter (17082): Initialization done
I/flutter (17082): Running false
I/le.locatortest(17082): ProcessProfilingInfo new_methods=913 is saved saved_to_disk=1 resolve_classes_delay=8000
D/BackgroundLocatorPlugin(17082): start locator with Google client
W/ActivityThread(17082): SCHED: com.example.locatortest1/.MainActivity [80, r=235ms, a=56ms, w=77127ms]
W/ActivityThread(17082): SCHED: com.example.locatortest1/.MainActivity [91, r=45ms, a=4ms, w=27881ms]

once I press stop I receive:

D/BackgroundLocatorPlugin(17082): Locator service is not running, nothing to stop

image

torian257x commented 3 years ago

just doesn't seem to work.

solution could be for me to switch plugins - this one works after following the steps I outlined: https://github.com/Lyokone/flutterlocation/issues/502

notice: doing the same steps for the plugin of this repo, doesn't work.

andrewzakhartchouk commented 3 years ago

This might be a permissions issue. If you go to Settings > Location > Give your app the 'Allow all the time' permission. You could reach the permissions by going through the App's settings page too.

Like I mentioned in #184, its possibly due to the permission request not working as desired.

torian257x commented 3 years ago

I tried just doing that right now. Doesnt work either. I tried flipping it on and off a couple times (the service).

Launching lib/main.dart on Redmi Note 7 in debug mode...
Running Gradle task 'assembleDebug'...
✓ Built build/app/outputs/flutter-apk/app-debug.apk.
Waiting for Redmi Note 7 to report its views...
Debug service listening on ws://127.0.0.1:36943/3m-NhS40qys=/ws
Syncing files to device Redmi Note 7...
I/flutter (28554): Initializing...
W/le.locatortest(28554): Accessing hidden method Lsun/misc/Unsafe;->getUnsafe()Lsun/misc/Unsafe; (greylist,core-platform-api, linking, allowed)
W/le.locatortest(28554): Accessing hidden method Lsun/misc/Unsafe;->objectFieldOffset(Ljava/lang/reflect/Field;)J (greylist,core-platform-api, linking, allowed)
W/le.locatortest(28554): Accessing hidden method Lsun/misc/Unsafe;->compareAndSwapObject(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z (greylist, linking, allowed)
W/le.locatortest(28554): Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, linking, allowed)
I/flutter (28554): Initialization done
I/flutter (28554): Running false
D/BackgroundLocatorPlugin(28554): start locator with Google client
D/BackgroundLocatorPlugin(28554): Locator service is not running, nothing to stop
D/BackgroundLocatorPlugin(28554): start locator with Google client
D/BackgroundLocatorPlugin(28554): Locator service is not running, nothing to stop
W/ActivityThread(28554): SCHED: com.example.locatortest1/.MainActivity [88, r=358ms, a=48ms, w=74717ms]
D/BackgroundLocatorPlugin(28554): Locator service is not running, nothing to stop
D/BackgroundLocatorPlugin(28554): start locator with Google client
D/BackgroundLocatorPlugin(28554): Locator service is not running, nothing to stop
W/ActivityThread(28554): SCHED: com.example.locatortest1/.MainActivity [91, r=149ms, a=13ms, w=20670ms]
Lost connection to device.
saravananmnm commented 3 years ago

Accessing hidden method Lsun/misc/Unsafe;->compareAndSwapObject(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z (greylist, linking, allowed)

Same error! inside api call not happens.