GetCurrentLocation在Android的调试中工作,但在版本apk中不工作
我对geolocator软件包有问题,当我在调试模式下运行我的应用程序时,一切都很好,但当我构建应用程序并使用发布模式时,它卡在我的加载屏幕上,其中包含geolocator软件包中的getcurrentlocationGetCurrentLocation在Android的调试中工作,但在版本apk中不工作,android,flutter,dart,plugins,geolocation,Android,Flutter,Dart,Plugins,Geolocation,我对geolocator软件包有问题,当我在调试模式下运行我的应用程序时,一切都很好,但当我构建应用程序并使用发布模式时,它卡在我的加载屏幕上,其中包含geolocator软件包中的getcurrentlocation Future<void> getCurrentLocation() async { try { Geolocator geolocator = Geolocator()..forceAndroidLocationManager = true;
Future<void> getCurrentLocation() async {
try {
Geolocator geolocator = Geolocator()..forceAndroidLocationManager = true;
Position position = await geolocator.getCurrentPosition(
desiredAccuracy: LocationAccuracy.low,
);
latitude = position.latitude;
longitude = position.longitude;
} catch (e) {
print(e);
}
}
Future getCurrentLocation()异步{
试一试{
Geolocator Geolocator=Geolocator()…forceAndroidLocationManager=true;
位置=等待地理定位器。getCurrentPosition(
所需精度:定位精度。低,
);
纬度=位置。纬度;
经度=位置。经度;
}捕获(e){
印刷品(e);
}
}
而且还添加到android清单访问。我在Geolocator软件包中遇到了同样的问题,我的许多用户无法访问他们的位置,也没有获得许可 解决的办法是改为使用
我无法确定这对我起作用的确切原因,但如果我有一个应用程序正在生产,将我的软件包更改为这对我有帮助。对于我的情况,我发现我必须将internet权限添加到AndroidManifest中。xml
<uses-permission android:name="android.permission.INTERNET" />
您是否向firebase控制台添加了发布密钥?我没有使用firebase,我只使用了来自Flatter Packages的geolocator插件。我现在使用这个软件包,同样的问题在调试模式下效果很好,在发布模式下没有任何问题。ps:当应用程序启动时,它需要权限,但保持加载位置,不会发生任何事情