打开静态 URI 时颤振map_view崩溃



我有一个map_view并使用staticMapURI显示完整的视图地图,但是当我点击地图的那一刻,应用程序崩溃了:

I/zygote  (11465): Rejecting re-init on previously-failed class java.lang.Class<com.google.android.gms.maps.model.CameraPosition>: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/internal/safeparcel/zza;
I/zygote  (11465):   at void com.apptreesoftware.mapview.MapViewPlugin.<clinit>() (MapViewPlugin.kt:-1)
I/zygote  (11465):   at void com.apptreesoftware.mapview.MapViewPlugin.registerWith(io.flutter.plugin.common.PluginRegistry$Registrar) (MapViewPlugin.kt:-1)
I/zygote  (11465):   at void io.flutter.plugins.GeneratedPluginRegistrant.registerWith(io.flutter.plugin.common.PluginRegistry) (GeneratedPluginRegistrant.java:32)
I/zygote  (11465):   at void com.rumblewayne.scottandvikiapp.MainActivity.onCreate(android.os.Bundle) (MainActivity.java:12)
I/zygote  (11465):   at void android.app.Activity.performCreate(android.os.Bundle, android.os.PersistableBundle) (Activity.java:7009)
I/zygote  (11465):   at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:7000)
I/zygote  (11465):   at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1214)
I/zygote  (11465):   at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2731)
I/zygote  (11465):   at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2856)
I/zygote  (11465):   at void android.app.ActivityThread.-wrap11(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
I/zygote  (11465):   at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1589)
I/zygote  (11465):   at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:106)
I/zygote  (11465):   at void android.os.Looper.loop() (Looper.java:164)
I/zygote  (11465):   at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6494)
I/zygote  (11465):   at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
I/zygote  (11465):   at void com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run() (RuntimeInit.java:438)
I/zygote  (11465):   at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:807)
I/zygote  (11465): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.internal.safeparcel.zza" on path: DexPathList[[zip file "/data/app/com.rumblewayne.scottandvikiapp-GNTruwp_-c2PU_b1tngU3w==/base.apk"],nativeLibraryDirectories=[/data/app/com.rumblewayne.scottandvikiapp-GNTruwp_-c2PU_b1tngU3w==/lib/x86, /data/app/com.rumblewayne.scottandvikiapp-GNTruwp_-c2PU_b1tngU3w==/base.apk!/lib/x86, /system/lib, /vendor/lib]]
I/zygote  (11465):   at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:125)
I/zygote  (11465):   at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:379)
I/zygote  (11465):   at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
I/zygote  (11465):   at void com.apptreesoftware.mapview.MapViewPlugin.<clinit>() (MapViewPlugin.kt:-1)
I/zygote  (11465):   at void com.apptreesoftware.mapview.MapViewPlugin.registerWith(io.flutter.plugin.common.PluginRegistry$Registrar) (MapViewPlugin.kt:-1)
I/zygote  (11465):   at void io.flutter.plugins.GeneratedPluginRegistrant.registerWith(io.flutter.plugin.common.PluginRegistry) (GeneratedPluginRegistrant.java:32)
I/zygote  (11465):   at void com.rumblewayne.scottandvikiapp.MainActivity.onCreate(android.os.Bundle) (MainActivity.java:12)
I/zygote  (11465):   at void android.app.Activity.performCreate(android.os.Bundle, android.os.PersistableBundle) (Activity.java:7009)
I/zygote  (11465):   at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:7000)
I/zygote  (11465):   at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1214)
I/zygote  (11465):   at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2731)
I/zygote  (11465):   at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2856)
I/zygote  (11465):   at void android.app.ActivityThread.-wrap11(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
I/zygote  (11465):   at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1589)
I/zygote  (11465):   at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:106)
I/zygote  (11465):   at void android.os.Looper.loop() (Looper.java:164)
I/zygote  (11465):   at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6494)
I/zygote  (11465):   at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
I/zygote  (11465):   at void com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run() (RuntimeInit.java:438)
I/zygote  (11465):   at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:807)
I/zygote  (11465):
F/flutter (11465): [FATAL:flutter/shell/platform/android/platform_view_android_jni.cc(60)] Check failed: CheckException(env).
F/libc    (11465): Fatal signal 6 (SIGABRT), code -6 in tid 11465 (scottandvikiapp), pid 11465 (scottandvikiapp)
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'google/sdk_gphone_x86/generic_x86:8.1.0/OSM1.180201.021/4741582:userdebug/dev-keys'
Revision: '0'
ABI: 'x86'
pid: 11465, tid: 11465, name: scottandvikiapp  >>> com.rumblewayne.scottandvikiapp <<<
signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
Abort message: '[FATAL:flutter/shell/platform/android/platform_view_android_jni.cc(60)] Check failed: CheckException(env). 
'
eax 00000000  ebx 00002cc9  ecx 00002cc9  edx 00000006
esi f29abd10  edi 00002cc9
xcs 00000023  xds 0000002b  xes 0000002b  xfs 0000006b  xss 0000002b
eip f720aaf0  ebp aca5a3d9  esp ff86e8b8  flags 00000296
backtrace:
#00 pc 00000af0  [vdso:f720a000] (__kernel_vsyscall+16)
#01 pc 0001edf8  /system/lib/libc.so (syscall+40)
#02 pc 0001f073  /system/lib/libc.so (abort+115)
#03 pc 00330ffe  /data/app/com.rumblewayne.scottandvikiapp-GNTruwp_-c2PU_b1tngU3w==/lib/x86/libflutter.so
#04 pc 00331733  /data/app/com.rumblewayne.scottandvikiapp-GNTruwp_-c2PU_b1tngU3w==/lib/x86/libflutter.so
#05 pc 00083d2a  /data/app/com.rumblewayne.scottandvikiapp-GNTruwp_-c2PU_b1tngU3w==/lib/x86/libflutter.so
#06 pc 000821fe  /data/app/com.rumblewayne.scottandvikiapp-GNTruwp_-c2PU_b1tngU3w==/lib/x86/libflutter.so
#07 pc 000d2993  /data/app/com.rumblewayne.scottandvikiapp-GNTruwp_-c2PU_b1tngU3w==/lib/x86/libflutter.so
#08 pc 0009329c  /data/app/com.rumblewayne.scottandvikiapp-GNTruwp_-c2PU_b1tngU3w==/lib/x86/libflutter.so
#09 pc 00092e5a  /data/app/com.rumblewayne.scottandvikiapp-GNTruwp_-c2PU_b1tngU3w==/lib/x86/libflutter.so
#10 pc 00097a76  /data/app/com.rumblewayne.scottandvikiapp-GNTruwp_-c2PU_b1tngU3w==/lib/x86/libflutter.so
#11 pc 00014af7  /system/lib/libutils.so (android::SimpleLooperCallback::handleEvent(int, int, void*)+39)
#12 pc 00015936  /system/lib/libutils.so (android::Looper::pollInner(int)+982)
#13 pc 000154d6  /system/lib/libutils.so (android::Looper::pollOnce(int, int*, int*, void**)+118)
#14 pc 000e262b  /system/lib/libandroid_runtime.so (android::android_os_MessageQueue_nativePollOnce(_JNIEnv*, _jobject*, long long, int)+59)
#15 pc 007d5428  /system/framework/x86/boot-framework.oat (offset 0x606000) (android.app.NativeActivity.onWindowFocusChangedNative [DEDUPED]+136)
#16 pc 0000371e  /dev/ashmem/dalvik-jit-code-cache (deleted)
#17 pc 4f293241  <unknown>
#18 pc 0d3fffff  /dev/ashmem/dalvik-main space (region space) (deleted)
#19 pc 0d3fffff  /dev/ashmem/dalvik-main space (region space) (deleted)
Lost connection to device.

我在其他帖子中读到您需要确保您的依赖项匹配等,但是当我尝试链接帖子中显示的内容时,我似乎可以让它工作。

我当前的依赖项如下所示:

dependencies:
map_view: ^0.0.12
image_picker: ^0.4.1
url_launcher: ^3.0.0
firebase_storage: ^0.3.7
firebase_database: ^1.0.1
shared_preferences: ^0.4.1
transparent_image: ^0.1.0
chewie: ^0.6.0
camera: ^0.2.1
video_player: ^0.6.0
path_provider: ^0.4.0
connectivity: ^0.3.1
zoomable_image: ^1.2.0
json_annotation: ^0.2.4
firebase_messaging: ^1.0.2
image: ^1.1.33
path: ^1.5.1
uuid: ^1.0.0
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
dev_dependencies:
build_runner: ^0.8.0
json_serializable: ^0.5.2
flutter_launcher_icons: ^0.3.2
flutter_test:
sdk: flutter

任何人都可以深入了解如何解决此问题吗?

更新:

import 'package:map_view/map_view.dart';
import 'CompositionSubscription.dart';
import 'package:flutter/material.dart';
class CustomMap extends StatefulWidget {
String mapTitle;
List markers;
CameraPosition initialPosition;
CustomMap(this.mapTitle, this.markers, this.initialPosition);
@override
CustomMapState createState() => new CustomMapState(this.mapTitle, this.markers, this.initialPosition);
}
class CustomMapState extends State<CustomMap>  {
final String mapTitle;
final List<Marker> markers;
final CameraPosition initialPosition;
CustomMapState(this.mapTitle, this.markers, this.initialPosition);
MapView mapView = new MapView();
var compositeSubscription = new CompositeSubscription();
@override Widget build(BuildContext context) {
mapView.show(
new MapOptions(
mapViewType: MapViewType.normal,
showUserLocation: true,
initialCameraPosition: initialPosition,
title: mapTitle),
toolbarActions: [new ToolbarAction("Back", 1)]
);
var setMarkers = mapView.onMapReady.listen((_) {
mapView.setMarkers(markers);
mapView.zoomToFit(padding: 100);
});
compositeSubscription.add(setMarkers);
var toolbarAction = mapView.onToolbarAction.listen((id) {
if (id == 1) {
Navigator.pop(context);
mapView.dismiss();
compositeSubscription.cancel();
}
});
compositeSubscription.add(toolbarAction);
return new Scaffold();
}
}

在点击地图的上一个屏幕中。

var churchStaticMarkers = [ new Marker("Church", "St Dunstan's Church", 51.0206245,0.2605629, color: Colors.red)];
var churchLocation = new Location(51.0206245, 0.2605629);
var staticMapProvider = new StaticMapProvider("XXXXX");
var churchStaticMapUri = staticMapProvider.getStaticUriWithMarkers(
churchStaticMarkers,
maptype: StaticMapViewType.roadmap,
center: churchLocation
);
var churchMapContainer = new Container(
child: new InkWell(
child: new Stack(
children: <Widget>[
new Container(
child: new Center(
child: new CircularProgressIndicator(),
),
padding: new EdgeInsets.all(16.0),
),
new Center(
child: new FadeInImage.memoryNetwork(
placeholder: kTransparentImage,
image: churchStaticMapUri.toString(),
),
),
],
),
onTap: () {
Navigator.push(
context,
new MaterialPageRoute(builder: (context) => new CustomMap(churchMapTitle, churchMapMarkers, churchPosition)),
);
},
),
margin: new EdgeInsets.only(left: 8.0, top: 8.0, right: 8.0),
);

尽管 Flutter 是为跨平台而制作的,但并非所有内容都是用 Dart 编写的。某些部分需要特定于平台的(本机(代码。因此,需要将一些内容添加到代码中(请参阅 pub.dartlang.org(

人造人

您将对 AndroidManifest.xml 文件进行多次编辑。在你的 Flutter 项目中,你可以在 android/app/src/main 下找到这个文件位置。

在 AndroidManifest.xml 中,在标记上方添加以下使用权限。

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

在 AndroidManifest.xml 中,在应用程序标记中添加以下行。请务必将your_api_key替换为生成的一个。

<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="your_api_key"/>
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version"/>

将 MapActivity 添加到您的 AndroidManifest 中.xml

<activity android:name="com.apptreesoftware.mapview.MapActivity" android:theme="@style/Theme.AppCompat.Light.DarkActionBar"/>

在你的android/build.gradle文件中。在 buildScript 依赖项下添加:

classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.2-4'

在安卓设备或模拟器上运行您的应用程序。确认在显示地图时会看到地图详细信息。如果您只看到米色屏幕,则可能是您的 API 密钥不正确。

苹果

地图插件将在需要时请求您的用户位置。 iOS 要求您在 Info.plist 文件中解释此用法 在ios/Runner/Info.plist中设置NSLocationWhenInUseUsageDescription。 例:

<key>NSLocationWhenInUseUsageDescription</key>
<string>Using location to display on a map</string>

编辑:

此外,您还应该将 MapOptions initialCameraPosition Location 包装在 CameraPosition 中

initialCameraPosition: new CameraPosition(initialPosition)

最新更新