我一直在研究需要地图支持和用户身份验证登录的应用程序。当我尝试添加Fire Base用户身份验证时,我使用地图视图创建了一个工作正常的应用程序。地图视图不起作用
代码示例:
主页:
class MapPage extends StatefulWidget {
@override
_MapPageState createState() => new _MapPageState();
}
class _MapPageState extends State<MapPage> {
MapView view =new MapView();
CameraPosition cameraPosition;
var staticMapProvider =new StaticMapProvider(apiKey);
Uri staticMapUri;
@override
void initState() {
// TODO: implement initState
super.initState();
cameraPosition =new CameraPosition(new Location(13.007515, 80.208595), 15.0);
staticMapUri =staticMapProvider.getStaticUri(new Location(13.007515, 80.208595),12,height: 200,width: 200,
mapType: StaticMapViewType.roadmap);
}
showMap()
{
view.show(new MapOptions(
title: "Location Tracking" ,
showUserLocation: true,
initialCameraPosition: new CameraPosition(new Location(13.007515, 80.208595), 150.0),
mapViewType: MapViewType.normal,
)
);
}
@override
Widget build(BuildContext context) {
return new Scaffold(
body: new Container(
child: new InkWell(
child : new Image.network(staticMapUri.toString()),
onTap:
showMap
)
),
);
}
}
android / build.gradle:
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:3.2.1'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.2-4'
}
android / app / build.gradle:
dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
apply plugin: 'com.google.gms.google-services'
pubspec.yaml:
dependencies:
map_view:
firebase_auth: '^0.5.5'
cloud_firestore:
问题得到:
**I/art (11855): Rejecting re-init on previously-failed class ava.lang.Class<com.google.android.gms.maps.model.CameraPosition>
F/flutter (11855): [FATAL:flutter/shell/platform/android/platform_view_android_jni.cc(60)] Check failed: CheckException(env).
F/libc (11855): Fatal signal 6 (SIGABRT), code -6 in tid 11855 (ompany.retroapp)
Lost connection to device.**
,以及当我删除了Fire Base身份验证及其依赖项时。地图视图工作正常。 如何集成Firebase身份验证和地图视图?
答案 0 :(得分:0)
当firebase和mapview使用不同版本的Google Play服务时会发生这种情况。
可以通过在app / build.gradle文件中添加此行来解决。
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true
将此行添加到build.gradle文件中
subprojects {
// project.evaluationDependsOn(':app')
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "26.1.0"
}
}
}
}