Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to get location #44

Closed
alexjuniodev opened this issue May 30, 2018 · 29 comments
Closed

Failed to get location #44

alexjuniodev opened this issue May 30, 2018 · 29 comments

Comments

@alexjuniodev
Copy link

alexjuniodev commented May 30, 2018

I'm getting the error when it calls

.invokeMethod('getLocation')

Future<Map<String, double>> get getLocation => _channel
.invokeMethod('getLocation')
.then((result) => result.cast<String, double>());

inside location.dart.

The message error is "Failed to get location"
The app asks for permition.

=============================================
(build.gradle)

buildscript {
repositories {
google()
jcenter()
}

dependencies {
    classpath 'com.android.tools.build:gradle:3.0.1'
    classpath 'com.google.gms:google-services:3.1.2'
    classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.2-4'
}

}

============================================
(pubspec.yaml)

dependencies:
flutter:
sdk: flutter
image_picker: 0.4.1
google_sign_in: 3.0.2
firebase_analytics: 0.3.3
firebase_auth: 0.5.5
firebase_database: 0.4.6
firebase_storage: 0.3.0
cached_network_image: "^0.4.1"
rxdart: ^0.16.7
cupertino_icons: ^0.1.0
photo_view: 0.0.2
flutter_map: ^0.0.1
location: 1.3.3
geohash: 0.1.1

==============================================
(messages)

Reloaded 3 of 651 libraries in 1.025ms.
E/flutter ( 8349): [ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] Unhandled exception:
E/flutter ( 8349): PlatformException(ERROR, Failed to get location., null)
E/flutter ( 8349): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:547:7)
E/flutter ( 8349): #1      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:279:18)
E/flutter ( 8349): <asynchronous suspension>
E/flutter ( 8349): #2      Location.getLocation (package:location/location.dart:12:8)
E/flutter ( 8349): #3      new ControllerLocation (package:flutter_chat/utils/geographic/ControllerLocation.dart:17:15)
E/flutter ( 8349): #4      _MyMapWidgetState.build (package:flutter_chat/pages/map_screen.dart:96:30)
E/flutter ( 8349): #5      StatefulElement.build (package:flutter/src/widgets/framework.dart:3730:27)
E/flutter ( 8349): #6      ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3642:15)
E/flutter ( 8349): #7      Element.rebuild (package:flutter/src/widgets/framework.dart:3495:5)
E/flutter ( 8349): #8      StatefulElement.update (package:flutter/src/widgets/framework.dart:3799:5)
E/flutter ( 8349): #9      Element.updateChild (package:flutter/src/widgets/framework.dart:2699:15)
E/flutter ( 8349): #10     RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:4379:32)
E/flutter ( 8349): #11     MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4769:17)
E/flutter ( 8349): #12     Element.updateChild (package:flutter/src/widgets/framework.dart:2699:15)
E/flutter ( 8349): #13     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3653:16)
E/flutter ( 8349): #14     Element.rebuild (package:flutter/src/widgets/framework.dart:3495:5)
E/flutter ( 8349): #15     ProxyElement.update (package:flutter/src/widgets/framework.dart:3909:5)
E/flutter ( 8349): #16     Element.updateChild (package:flutter/src/widgets/framework.dart:2699:15)
E/flutter ( 8349): #17     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3653:16)
E/flutter ( 8349): #18     Element.rebuild (package:flutter/src/widgets/framework.dart:3495:5)
E/flutter ( 8349): #19     ProxyElement.update (package:flutter/src/widgets/framework.dart:3909:5)
E/flutter ( 8349): #20     Element.updateChild (package:flutter/src/widgets/framework.dart:2699:15)
E/flutter ( 8349): #21     RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:4379:32)
E/flutter ( 8349): #22     MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4769:17)
E/flutter ( 8349): #23     Element.updateChild (package:flutter/src/widgets/framework.dart:2699:15)
E/flutter ( 8349): #24     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3653:16)
E/flutter ( 8349): #25     Element.rebuild (package:flutter/src/widgets/framework.dart:3495:5)
E/flutter ( 8349): #26     StatefulElement.update (package:flutter/src/widgets/framework.dart:3799:5)
E/flutter ( 8349): #27     Element.updateChild (package:flutter/src/widgets/framework.dart:2699:15)
E/flutter ( 8349): #28     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3653:16)
E/flutter ( 8349): #29     Element.rebuild (package:flutter/src/widgets/framework.dart:3495:5)
E/flutter ( 8349): #30     ProxyElement.update (package:flutter/src/widgets/framework.dart:3909:5)
E/flutter ( 8349): #31     Element.updateChild (package:flutter/src/widgets/framework.dart:2699:15)
E/flutter ( 8349): #32     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3653:16)
E/flutter ( 8349): #33     Element.rebuild (package:flutter/src/widgets/framework.dart:3495:5)
E/flutter ( 8349): #34     StatefulElement.update (package:flutter/src/widgets/framework.dart:3799:5)
E/flutter ( 8349): #35     Element.updateChild (package:flutter/src/widgets/framework.dart:2699:15)
E/flutter ( 8349): #36     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4661:14)
E/flutter ( 8349): #37     Element.updateChild (package:flutter/src/widgets/framework.dart:2699:15)
E/flutter ( 8349): #38     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3653:16)
E/flutter ( 8349): #39     Element.rebuild (package:flutter/src/widgets/framework.dart:3495:5)
E/flutter ( 8349): #40     StatelessElement.update (package:flutter/src/widgets/framework.dart:3702:5)
E/flutter ( 8349): #41     Element.updateChild (package:flutter/src/widgets/framework.dart:2699:15)
E/flutter ( 8349): #42     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4661:14)
E/flutter ( 8349): #43     Element.updateChild (package:flutter/src/widgets/framework.dart:2699:15)
E/flutter ( 8349): #44     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3653:16)
E/flutter ( 8349): #45     Element.rebuild (package:flutter/src/widge
@AlexandreRoba
Copy link

I'm having the same error... Any update on this?

@aslamzee
Copy link

Any update on this issue ?

@vagrantrobbie
Copy link
Contributor

Same here. I am accepting the permission request but PERMISSION_DENIED is always thrown and returns location null

@vagrantrobbie
Copy link
Contributor

Strangely, the onLocationChanged Stream works

@philseeley
Copy link

philseeley commented Jul 23, 2018

Bit more info... I've two apps, one that uses the onLocationChanged listener and one that simply calls getLocation once. On a fresh phone boot I get the same error calling getLocation. If I then run the other app that uses the onLocationChanged listener, then the first app's call to getLocation starts working.
This is using the Nexus 5 API 24 AVD.

@MarcoLude
Copy link

Same here. I started having the problem after I had added the image_picker dependecy which made me accept the permission request to use location for pictures.
Don't know why

@andersonmadeira
Copy link

Same here, any update?

@Vignesh150493
Copy link

Will there be any updates on this?

@ibrierley
Copy link

Someone want to put up an example that can be used to test that fails ? May be good to isolate if it's a problem with the package, or some phones or whatever/

@jibbers42
Copy link

I get this issue if I disable wifi in the simulator. I wanted to test my app at different network speeds and latencies, but it won't start with wifi off due to this error when calling getLocation(). I'm also using image_picker (if that's related).

@vagrantrobbie
Copy link
Contributor

Does pubspec order dependency matter? What happens if 'location' is included before 'image_picker'?

@jibbers42
Copy link

'location' was already before 'image_picker', but I didn't think to try switching them the other way. I've changed to 'geolocator' which seems to be working fine initially - time will tell. I'll update if I decide to try switching them around.

@oliverseries
Copy link

any update on this?

@myleswh
Copy link

myleswh commented Feb 1, 2019

'getLocation' uses 'getLastLocation()' on Android which can return null in a number of scenarios.
https://developer.android.com/training/location/retrieve-current

I had a attempt at fixing this here 6666cf8
but closed the PR as I couldn't get it working for all scenarios (If location is off or unavailable 'await getLocation' will never return).

@myleswh
Copy link

myleswh commented Feb 1, 2019

I've updated 6666cf8 and it seems to be working fine.

Anyone who wants to test can use

dependencies:
location:
git: https://github.com/myleswh/flutterlocation.git

@wagnerdelima
Copy link

Will there be any update on this?

@Lyokone
Copy link
Owner

Lyokone commented Feb 20, 2019

Hey, its supposed to be corrected in the last version, pls check this.

@wagnerdelima
Copy link

@Lyokone I tried your suggestions. Yet it doesn't work.

My dependencies on android/build.gradle are
`dependencies {

    classpath 'com.android.tools.build:gradle:3.3.0'

    classpath 'com.google.gms:google-services:4.2.0'
}

`

My Gradle.properties on android/gradle.properties are:
`
org.gradle.jvmargs=-Xmx1536M

android.useAndroidX=true

android.enableJetifier=true
`

Is there any other way?

@wagnerdelima
Copy link

@Lyokone the only thing I get is PlatformException(ERROR, Failed to get location., null) exception

Any idea?

@Lyokone
Copy link
Owner

Lyokone commented Feb 20, 2019

Are you compiling against the version 28 of the SDK ?
`compileSdkVersion 28``

Do you also have added all the permission the application needs ?

@wagnerdelima
Copy link

`
compileSdkVersion 28

lintOptions {
    disable 'InvalidPackage'
}

defaultConfig {
    // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
    applicationId "maidsimple.app.msapp"
    minSdkVersion 21
    targetSdkVersion 28
    multiDexEnabled true
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}`

And this:

<uses-permission android:name="android.permission.INTERNET"/>

    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<meta-data android:name="com.google.android.geo.API_KEY"
           android:value="my key is here"/>

I think I am all set

@wagnerdelima
Copy link

wagnerdelima commented Feb 20, 2019

@Lyokone depicted above

@wagnerdelima
Copy link

Any news on this, anybody?

@adisiji
Copy link

adisiji commented Mar 11, 2019

I surrender with this error, and change it to this + permission library

@Lyokone
Copy link
Owner

Lyokone commented Mar 16, 2019

Hey, version 2.1 should help you get more consistent results, pls check it out and reopen if its still not fixed.

@Lyokone Lyokone closed this as completed Mar 16, 2019
@DorIndivo
Copy link

i just updated to the 2.1.0 version and i still have this problem on my android emulator

@uzairamer
Copy link

It's still an ongoing issue. Even the documentation is misleading.

@Karlheinzniebuhr
Copy link

Same error, any solution yet?

@shahmirzali49
Copy link

any progress? update? same error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests