flutter-geolocator icon indicating copy to clipboard operation
flutter-geolocator copied to clipboard

Geolocator not giving any output in Emulator

Open Bhavya-Budhia opened this issue 6 years ago • 13 comments

I am trying to get the location using following function

void getLocation() async {
    print('Hello');
    Position position = await Geolocator()
        .getCurrentPosition(desiredAccuracy: LocationAccuracy.low);

    print(position);
    print('Bye');
  }

I am calling this function is a RaisedButton. When I run the App I get the following messages.

Launching lib\main.dart on Android SDK built for x86 in debug mode...
Running Gradle task 'assembleDebug'...
√ Built build\app\outputs\apk\debug\app-debug.apk.
Installing build\app\outputs\apk\app.apk...
D/eglCodecCommon( 9864): allocate: ioctl allocate returned offset 0x3ffff6000 size 0x2000
D/EGL_emulation( 9864): eglMakeCurrent: 0xdbc1a060: ver 3 1 (tinfo 0xdbc0f800)
E/eglCodecCommon( 9864): glUtilsParamSize: unknow param 0x000082da
Debug service listening on ws://127.0.0.1:56484/JDxmJGp4vjI=/ws
Syncing files to device Android SDK built for x86...
E/eglCodecCommon( 9864): glUtilsParamSize: unknow param 0x000082da
D/EGL_emulation( 9864): eglMakeCurrent: 0xdbc1a300: ver 3 1 (tinfo 0xdbc0f020)
I/OpenGLRenderer( 9864): Davey! duration=12311ms; Flags=1, IntendedVsync=6591781130531, Vsync=6591781130531, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=6591783587900, AnimationStart=6591783714400, PerformTraversalsStart=6591783805100, DrawStart=6596073559600, SyncQueued=6596076166800, SyncStart=6596367942600, IssueDrawCommandsStart=6596370115200, SwapBuffers=6603511417200, FrameCompleted=6604384251300, DequeueBufferDuration=276110000, QueueBufferDuration=1617000, 
I/Choreographer( 9864): Skipped 756 frames!  The application may be doing too much work on its main thread.
I/OpenGLRenderer( 9864): Davey! duration=876ms; Flags=0, IntendedVsync=6604458845403, Vsync=6604458845403, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=6604462855900, AnimationStart=6604462966100, PerformTraversalsStart=6604463094300, DrawStart=6604463958900, SyncQueued=6604464039500, SyncStart=6604466433800, IssueDrawCommandsStart=6604468948300, SwapBuffers=6604473698600, FrameCompleted=6605338019700, DequeueBufferDuration=861825000, QueueBufferDuration=1246000, 
D/EGL_emulation( 9864): eglMakeCurrent: 0xdbc1a060: ver 3 1 (tinfo 0xdbc0f800)
I/OpenGLRenderer( 9864): Davey! duration=735ms; Flags=0, IntendedVsync=6608877399279, Vsync=6608877399279, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=6608879360800, AnimationStart=6608879426600, PerformTraversalsStart=6608881319400, DrawStart=6608881656000, SyncQueued=6608881761800, SyncStart=6608883107300, IssueDrawCommandsStart=6608883422400, SwapBuffers=6608884556200, FrameCompleted=6609614391900, DequeueBufferDuration=349000, QueueBufferDuration=1652000, 
I/Choreographer( 9864): Skipped 42 frames!  The application may be doing too much work on its main thread.
I/flutter ( 9864): Hello

This issue is happening after I upgraded to flutter new version. I am not having any problem while running the app on a physical device. I have tried deleting and building new emulator. Can anybody has any Idea how to solve this issue?

Bhavya-Budhia avatar May 10 '20 15:05 Bhavya-Budhia

Hi @Bhavya-Budhia, this seems issues seems like it could be solved by migrating your Android project to the Flutter post 1.12 project structure. Could you please follow this migration guide and let us know if it helped?

mvanbeusekom avatar May 11 '20 08:05 mvanbeusekom

I tried but it is still not running

Bhavya-Budhia avatar May 11 '20 09:05 Bhavya-Budhia

logs.txt

Bhavya-Budhia avatar May 13 '20 13:05 Bhavya-Budhia

This is obtained by running flutter run -v

Bhavya-Budhia avatar May 13 '20 13:05 Bhavya-Budhia

Same issue.

Simple code..
void getLocation() async { Position position = await Geolocator().getCurrentPosition(desiredAccuracy: LocationAccuracy.low); print(position); }

If I put print statements in before calling the GeoLocator function they output to the console. If I put print statements in after the GeoLocator call I get nothing.

hughsheehy avatar May 13 '20 15:05 hughsheehy

@hughsheehy Same here...

Lapatou avatar May 14 '20 18:05 Lapatou

I try on real device it's work on real device but not working on AVD emulator

Lapatou avatar May 14 '20 18:05 Lapatou

I use bluestack emulator instead avd and with https://stackoverflow.com/questions/24598577/connect-bluestacks-to-android-studio this help it worked just when i request location momentary switch tab to location on bluestack and back my app

Lapatou avatar May 14 '20 19:05 Lapatou

It's also not working for me.

kimbarcelo1 avatar May 17 '20 11:05 kimbarcelo1

This error is happening because the android emulator is not sending location coordinates. To correct this see:-

  • https://developer.android.com/studio/run/emulator

  • https://stackoverflow.com/questions/47528006/how-to-set-the-location-manually-in-android-studio-emulator

On newer version the location page is like this emulator

Just click the screen to select the location and click set location.

Bhavya-Budhia avatar May 20 '20 14:05 Bhavya-Budhia

I am trying to get the location using following function

void getLocation() async {
    print('Hello');
    Position position = await Geolocator()
        .getCurrentPosition(desiredAccuracy: LocationAccuracy.low);

    print(position);
    print('Bye');
  }

I am calling this function is a RaisedButton. When I run the App I get the following messages.

Launching lib\main.dart on Android SDK built for x86 in debug mode...
Running Gradle task 'assembleDebug'...
√ Built build\app\outputs\apk\debug\app-debug.apk.
Installing build\app\outputs\apk\app.apk...
D/eglCodecCommon( 9864): allocate: ioctl allocate returned offset 0x3ffff6000 size 0x2000
D/EGL_emulation( 9864): eglMakeCurrent: 0xdbc1a060: ver 3 1 (tinfo 0xdbc0f800)
E/eglCodecCommon( 9864): glUtilsParamSize: unknow param 0x000082da
Debug service listening on ws://127.0.0.1:56484/JDxmJGp4vjI=/ws
Syncing files to device Android SDK built for x86...
E/eglCodecCommon( 9864): glUtilsParamSize: unknow param 0x000082da
D/EGL_emulation( 9864): eglMakeCurrent: 0xdbc1a300: ver 3 1 (tinfo 0xdbc0f020)
I/OpenGLRenderer( 9864): Davey! duration=12311ms; Flags=1, IntendedVsync=6591781130531, Vsync=6591781130531, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=6591783587900, AnimationStart=6591783714400, PerformTraversalsStart=6591783805100, DrawStart=6596073559600, SyncQueued=6596076166800, SyncStart=6596367942600, IssueDrawCommandsStart=6596370115200, SwapBuffers=6603511417200, FrameCompleted=6604384251300, DequeueBufferDuration=276110000, QueueBufferDuration=1617000, 
I/Choreographer( 9864): Skipped 756 frames!  The application may be doing too much work on its main thread.
I/OpenGLRenderer( 9864): Davey! duration=876ms; Flags=0, IntendedVsync=6604458845403, Vsync=6604458845403, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=6604462855900, AnimationStart=6604462966100, PerformTraversalsStart=6604463094300, DrawStart=6604463958900, SyncQueued=6604464039500, SyncStart=6604466433800, IssueDrawCommandsStart=6604468948300, SwapBuffers=6604473698600, FrameCompleted=6605338019700, DequeueBufferDuration=861825000, QueueBufferDuration=1246000, 
D/EGL_emulation( 9864): eglMakeCurrent: 0xdbc1a060: ver 3 1 (tinfo 0xdbc0f800)
I/OpenGLRenderer( 9864): Davey! duration=735ms; Flags=0, IntendedVsync=6608877399279, Vsync=6608877399279, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=6608879360800, AnimationStart=6608879426600, PerformTraversalsStart=6608881319400, DrawStart=6608881656000, SyncQueued=6608881761800, SyncStart=6608883107300, IssueDrawCommandsStart=6608883422400, SwapBuffers=6608884556200, FrameCompleted=6609614391900, DequeueBufferDuration=349000, QueueBufferDuration=1652000, 
I/Choreographer( 9864): Skipped 42 frames!  The application may be doing too much work on its main thread.
I/flutter ( 9864): Hello

This issue is happening after I upgraded to flutter new version. I am not having any problem while running the app on a physical device. I have tried deleting and building new emulator. Can anybody has any Idea how to solve this issue?

hey friend just go the Flutter geolocator api link and in version go on version 3.0.1 and see the permission section in docs and copy these lines and pasted them in the android/app/src/main/AndroidManifest.xml file as child of the manifest youre issue will resolved for sure

shaarifsabah avatar Oct 25 '20 21:10 shaarifsabah

hello lads i tried again and followed @Bhavya-Budhia steps as well, i thought so at the beginning but still it just loops and doesn't get the location, i even tried on both android 11 and 12 with the android emulator x86_64 version and still nothing

final position = await Geolocator.getCurrentPosition(
  desiredAccuracy: LocationAccuracy.medium,
);

it doesn't get pass this await function and keeps awaitng

SPiercer avatar Mar 13 '22 10:03 SPiercer

I had the same issue and when I switched through all the possible desiredAccuracies, all the pending awaits got resolved at once and it's working ever since.

MKainbacher avatar May 10 '22 05:05 MKainbacher