Browse Source

android端定位失败解决

wr_2024_invoice
wurong 5 months ago
parent
commit
f3f778757a
  1. 4
      android/build.gradle
  2. 2
      android/gradle/wrapper/gradle-wrapper.properties
  3. 2
      lib/address/address_map_page.dart
  4. 2
      lib/setting/permission_setting_page.dart
  5. 6
      lib/utils/location.dart
  6. 122
      pubspec.lock
  7. 4
      pubspec.yaml

4
android/build.gradle

@ -1,5 +1,5 @@
buildscript { buildscript {
ext.kotlin_version = '1.6.0' ext.kotlin_version = '1.7.10'
repositories { repositories {
maven { maven {
url 'https://maven.aliyun.com/repository/google' url 'https://maven.aliyun.com/repository/google'
@ -24,7 +24,7 @@ buildscript {
dependencies { dependencies {
// classpath 'com.android.tools.build:gradle:4.1.0' // classpath 'com.android.tools.build:gradle:4.1.0'
classpath 'com.android.tools.build:gradle:4.1.1' classpath 'com.android.tools.build:gradle:7.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.huawei.agconnect:agcp:1.4.1.300' classpath 'com.huawei.agconnect:agcp:1.4.1.300'
classpath 'com.mob.sdk:MobSDK:+' classpath 'com.mob.sdk:MobSDK:+'

2
android/gradle/wrapper/gradle-wrapper.properties vendored

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

2
lib/address/address_map_page.dart

@ -104,7 +104,7 @@ class _AddressMapPage extends State<AddressMapPage> {
Future.delayed(Duration(seconds: 6), () { Future.delayed(Duration(seconds: 6), () {
EasyLoading.dismiss(); EasyLoading.dismiss();
}); });
} else if (await PH.Permission.location.isUndetermined) { } else if (await PH.Permission.location.isDenied) {
await PH.Permission.location.request(); await PH.Permission.location.request();
} else { } else {
if (Platform.isIOS) { if (Platform.isIOS) {

2
lib/setting/permission_setting_page.dart

@ -117,7 +117,7 @@ class _PermissionSettingPage extends State<PermissionSettingPage> {
} }
if (await permission.isPermanentlyDenied) { if (await permission.isPermanentlyDenied) {
requestDialog(position); requestDialog(position);
} else if (await permission.isUndetermined) { } else if (await permission.isDenied) {
await permission.request(); await permission.request();
queryPermission(); queryPermission();
} else { } else {

6
lib/utils/location.dart

@ -47,7 +47,11 @@ class LocationInstance {
EasyLoading.dismiss(); EasyLoading.dismiss();
} }
}); });
Position locationData = await Geolocator.getCurrentPosition(); Position locationData = await Geolocator.getCurrentPosition(
desiredAccuracy: LocationAccuracy.medium,
timeLimit: const Duration(seconds: 30),
forceAndroidLocationManager: true,
);
isNext = false; isNext = false;
locationCallback.call(locationData); locationCallback.call(locationData);
} }

122
pubspec.lock

@ -401,18 +401,50 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: geolocator name: geolocator
sha256: "3018f6a37b1ec3c9dfb1adaa1ce406c0522c293a1a623ead94c32cd93a255fd3" sha256: "5c496b46e245d006760e643cedde7c9fa785a34391b5eca857a46358f9bde02b"
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "6.1.12" version: "8.2.1"
geolocator_android:
dependency: transitive
description:
name: geolocator_android
sha256: "3fa9215caf1e4463adbdf1f21b07fdcb9bc2af2ef1df3715a52376b87bebb087"
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.2.1"
geolocator_apple:
dependency: transitive
description:
name: geolocator_apple
sha256: bc2aca02423ad429cb0556121f56e60360a2b7d694c8570301d06ea0c00732fd
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.3.7"
geolocator_platform_interface: geolocator_platform_interface:
dependency: transitive dependency: transitive
description: description:
name: geolocator_platform_interface name: geolocator_platform_interface
sha256: aa11c4cb9eb31f096ffc62cf54858f869bd437de327cba660577ddd594a8f3fa sha256: b8cc1d3be0ca039a3f2174b0b026feab8af3610e220b8532e42cff8ec6658535
url: "https://pub.flutter-io.cn"
source: hosted
version: "4.1.0"
geolocator_web:
dependency: transitive
description:
name: geolocator_web
sha256: "102e7da05b48ca6bf0a5bda0010f886b171d1a08059f01bfe02addd0175ebece"
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.0.9" version: "2.2.1"
geolocator_windows:
dependency: transitive
description:
name: geolocator_windows
sha256: "4f4218f122a6978d0ad655fa3541eea74c67417440b09f0657238810d5af6bdc"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.1.3"
gradient_widgets: gradient_widgets:
dependency: "direct main" dependency: "direct main"
description: description:
@ -665,18 +697,42 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: permission_handler name: permission_handler
sha256: fb4666087528b1cbf91d98771cf50b14f36f4d8756ec7e7a8629dd3cb55442b7 sha256: "5749ebeb7ec0c3865ea17e3eb337174b87747be816dab582c551e1aff6f6bbf3"
url: "https://pub.flutter-io.cn"
source: hosted
version: "9.2.0"
permission_handler_android:
dependency: transitive
description:
name: permission_handler_android
sha256: a512e0fa8abcb0659d938ec2df93a70eb1df1fdea5fdc6d79a866bfd858a28fc
url: "https://pub.flutter-io.cn"
source: hosted
version: "9.0.2+1"
permission_handler_apple:
dependency: transitive
description:
name: permission_handler_apple
sha256: "99e220bce3f8877c78e4ace901082fb29fa1b4ebde529ad0932d8d664b34f3f5"
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "5.1.0+2" version: "9.1.4"
permission_handler_platform_interface: permission_handler_platform_interface:
dependency: transitive dependency: transitive
description: description:
name: permission_handler_platform_interface name: permission_handler_platform_interface
sha256: f7e3c798f7c4dd215e4ca8843695b3a63a5b79c9aa04f296d316f13a15d518ba sha256: "6760eb5ef34589224771010805bea6054ad28453906936f843a8cc4d3a55c4a4"
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.0.2" version: "3.12.0"
permission_handler_windows:
dependency: transitive
description:
name: permission_handler_windows
sha256: cc074aace208760f1eee6aa4fae766b45d947df85bc831cde77009cdb4720098
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.1.3"
petitparser: petitparser:
dependency: transitive dependency: transitive
description: description:
@ -709,14 +765,22 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "3.1.0" version: "3.1.0"
platform_detect:
dependency: transitive
description:
name: platform_detect
sha256: aab1dd0e19af823c0bbfc2d0f364e33abc52bd13be27711fea98bade0fe35213
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.4.0"
plugin_platform_interface: plugin_platform_interface:
dependency: transitive dependency: transitive
description: description:
name: plugin_platform_interface name: plugin_platform_interface
sha256: c3ebbff365bfb1b5f7b690c9857d2dabea167f35b05eb7586186499b407efb37 sha256: da3fdfeccc4d4ff2da8f8c556704c08f912542c5fb3cf2233ed75372384a034d
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.0.3" version: "2.1.6"
pointycastle: pointycastle:
dependency: transitive dependency: transitive
description: description:
@ -741,6 +805,14 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "6.0.5" version: "6.0.5"
pub_semver:
dependency: transitive
description:
name: pub_semver
sha256: "3c51ec0aaeccb85cacfe824816c60e1e3c53da586c64e1166422a906a4f7251c"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.4.4"
pull_to_refresh: pull_to_refresh:
dependency: "direct main" dependency: "direct main"
description: description:
@ -1023,18 +1095,10 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: url_launcher name: url_launcher
sha256: e1e0c46fcd777c0f0bd7f4541b747c28ad4e925f93344cebf667ef76c695533a sha256: "0a1f90f605bbfa9832b3514cea3a74693c6e569b8a1999fabeba12d8216a85c9"
url: "https://pub.flutter-io.cn"
source: hosted
version: "5.7.10"
url_launcher_linux:
dependency: transitive
description:
name: url_launcher_linux
sha256: c489023cdd864a19c0be63bb3796bec21ea4bc16bfe09568953f1828e02151c9
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.0.1+4" version: "5.4.0"
url_launcher_macos: url_launcher_macos:
dependency: transitive dependency: transitive
description: description:
@ -1047,26 +1111,18 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: url_launcher_platform_interface name: url_launcher_platform_interface
sha256: c6bd00f46e8c348703d0ae691850eb2052be8e1338dc3ae6f72af53b962da157 sha256: "9b5396f49780ac4f3e6563ab0936d8218182b0f1498318b5a7d1528e0293704f"
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.0.9" version: "1.0.1"
url_launcher_web: url_launcher_web:
dependency: transitive dependency: transitive
description: description:
name: url_launcher_web name: url_launcher_web
sha256: eaa6de8ac353681794533edcedd69dd8b39ed987bf2360d172185eff8283dbc2 sha256: b7478fa6476d0971fd41508bea0b4a25c59ccd263daea09f22f8ca4114559043
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.1.5+3"
url_launcher_windows:
dependency: transitive
description:
name: url_launcher_windows
sha256: "034479b1dafd8f01de81267d8117eb5ae019e0dddcc23f4b14ed31253a2635d9"
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.0.1+3" version: "0.1.3"
vector_math: vector_math:
dependency: transitive dependency: transitive
description: description:
@ -1204,5 +1260,5 @@ packages:
source: hosted source: hosted
version: "5.4.1" version: "5.4.1"
sdks: sdks:
dart: ">=2.18.0 <3.0.0" dart: ">=2.19.0 <3.0.0"
flutter: ">=3.0.0" flutter: ">=3.0.0"

4
pubspec.yaml

@ -39,9 +39,9 @@ dependencies:
number_precision: ^2.0.2+1 number_precision: ^2.0.2+1
permission_handler: ^5.0.1+1 permission_handler: ^9.0.2
geolocator: ^6.1.12 geolocator: ^8.2.1
# location: ^3.2.4 # location: ^3.2.4
dio: ^3.0.10 dio: ^3.0.10

Loading…
Cancel
Save