张延森 3 年前
父节点
当前提交
182084ceb3
共有 4 个文件被更改,包括 26 次插入34 次删除
  1. 3
    3
      android/app/build.gradle
  2. 10
    10
      android/app/proguard-rules.pro
  3. 11
    20
      lib/models/app.dart
  4. 2
    1
      lib/utils/location.dart

+ 3
- 3
android/app/build.gradle 查看文件

@@ -62,7 +62,7 @@ android {
62 62
 
63 63
     buildTypes {
64 64
         debug {
65
-            minifyEnabled true
65
+            minifyEnabled false
66 66
         }
67 67
         release {
68 68
             // TODO: Add your own signing config for the release build.
@@ -70,8 +70,8 @@ android {
70 70
             signingConfig signingConfigs.debug
71 71
 
72 72
             //关闭混淆, 否则在运行release包后可能出现运行崩溃, TODO后续进行混淆配置
73
-            minifyEnabled true //删除无用代码
74
-//            shrinkResources false //删除无用资源
73
+            minifyEnabled false //删除无用代码
74
+            shrinkResources false //删除无用资源
75 75
         }
76 76
     }
77 77
 }

+ 10
- 10
android/app/proguard-rules.pro 查看文件

@@ -6,16 +6,16 @@
6 6
 #-keep class io.flutter.**  { *; }
7 7
 #-keep class io.flutter.plugins.**  { *; }
8 8
 
9
--keep class com.amap.api.**{*;}
10
-#3D 地图 V5.0.0之后
11
--keep class com.amap.api.maps.**{*;}
12
--keep class com.autonavi.**{*;}
13
--keep class com.amap.api.trace.**{*;}
14
-#定位
15
--keep class com.amap.api.location.**{*;}
16
--keep class com.amap.api.fence.**{*;}
17
--keep class com.loc.**{*;}
18
--keep class com.autonavi.aps.amapapi.model.**{*;}
9
+#-keep class com.amap.api.**{*;}
10
+##3D 地图 V5.0.0之后
11
+#-keep class com.amap.api.maps.**{*;}
12
+#-keep class com.autonavi.**{*;}
13
+#-keep class com.amap.api.trace.**{*;}
14
+##定位
15
+#-keep class com.amap.api.location.**{*;}
16
+#-keep class com.amap.api.fence.**{*;}
17
+#-keep class com.loc.**{*;}
18
+#-keep class com.autonavi.aps.amapapi.model.**{*;}
19 19
 
20 20
 ##搜索
21 21
 #-keep class com.amap.api.services.**{*;}

+ 11
- 20
lib/models/app.dart 查看文件

@@ -38,26 +38,17 @@ class AppController extends GetxController {
38 38
   void onInit() {
39 39
     super.onInit();
40 40
 
41
-    setTimeout(() {
42
-
43
-      // 尝试获取 location
44
-      requireLocation(onLocationChange).then((loc) {
45
-        _location = loc;
46
-      }).catchError((e) {
47
-        print(e);
48
-
49
-        showAlert(
50
-          title: '获取定位失败',
51
-          message: e.message,
52
-          onConfirm: () => exit(1),
53
-        );
54
-      });
55
-    }, 2000);
56
-    WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
57
-      AMapFlutterLocation.setApiKey(ConstConfig.amapApiKeys.androidKey!, ConstConfig.amapApiKeys.iosKey!);
58
-      // showPrivacy();
59
-      AMapFlutterLocation.updatePrivacyShow(true, true);
60
-      AMapFlutterLocation.updatePrivacyAgree(true);
41
+    // 尝试获取 location
42
+    requireLocation(onLocationChange).then((loc) {
43
+      _location = loc;
44
+    }).catchError((e) {
45
+      print(e);
46
+
47
+      showAlert(
48
+        title: '获取定位失败',
49
+        message: e.message,
50
+        onConfirm: () => exit(1),
51
+      );
61 52
     });
62 53
 
63 54
     // // 尝试获取一次人员信息

+ 2
- 1
lib/utils/location.dart 查看文件

@@ -44,7 +44,8 @@ Future _requirePermission() async {
44 44
 }
45 45
 
46 46
 Future requireLocation(AMAPListener listener) async {
47
-
47
+  AMapFlutterLocation.setApiKey(ConstConfig.amapApiKeys.androidKey!, ConstConfig.amapApiKeys.iosKey!);
48
+  showPrivacy();
48 49
   await _requirePermission();
49 50
   final AMapFlutterLocation location = AMapFlutterLocation();
50 51
   location.onLocationChanged().listen(listener);