geolocation.enableLocationRequest() 上的 nativescript-geolocation 崩溃

but*_*nas 1 android nativescript nativescript-vue

在模拟器nativescript-vue使用Android 10.0 (Pixel 3a)作为我的堆栈。

每当我调用geolocation.enableLocationRequest()onmounted()或 on button click 时,应用程序都会崩溃。

不过它在 iOS 上运行良好。

有任何想法吗?

更新 1 - 更多信息

清单文件:

<?xml version="1.0" encoding="utf-8"?>
<manifest
    xmlns:android="http://schemas.android.com/apk/res/android" package="__PACKAGE__" android:versionCode="10003" android:versionName="0.0.3">
    <supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" />
    <uses-sdk android:minSdkVersion="23" android:targetSdkVersion="__APILEVEL__" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.FLASHLIGHT" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-feature android:name="android.hardware.camera"/>
    <uses-feature android:name="android.hardware.camera.flash"/>
    <application android:name="com.tns.NativeScriptApplication" android:allowBackup="true" android:icon="@drawable/icon" android:label="@string/app_name" android:usesCleartextTraffic="true" android:theme="@style/AppTheme">
        <activity android:name="com.tns.NativeScriptActivity"
                  android:label="@string/title_activity_kimera"
                  android:configChanges="keyboardHidden|orientation|screenSize"
                  android:theme="@style/LaunchScreenTheme"
        >
            <meta-data android:name="SET_THEME_ON_LAUNCH" android:resource="@style/AppTheme" />
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="com.tns.ErrorReportActivity" />
    </application>
</manifest>
Run Code Online (Sandbox Code Playgroud)

这就是我点击按钮时所做的:

try {
            let that = this;
    geolocation.isEnabled().then(function (isEnabled) {
        if (!isEnabled) {
            geolocation.enableLocationRequest().then(function () {
                this.watchIds.push(geolocation.watchLocation(
                    function (loc) {
                        if (loc) {
                            console.log("Location service: " + loc.timestamp)
                            that.$store.dispatch('usersStore/editUserGeo', {lat: loc.latitude, lng: loc.longitude})
                            that.locations.push(loc);
                        }
                    },
                    function (e) {
                        console.log("Error: " + e.message);
                    },
                    {
                        iosAllowsBackgroundLocationUpdates: true,
                        desiredAccuracy: Accuracy.high,
                    }));
            }, function (e) {
                console.log("Error: " + (e.message || e));
            });
        }
    }, function (e) {
        console.log("Error: " + (e.message || e));
    });
    } catch (ex) {
        console.log("Error: " + ex.message);
    }
Run Code Online (Sandbox Code Playgroud)

发生崩溃时的设备日志:https : //pastebin.com/VuK5nEBi

Man*_*noj 5

无法启用定位服务。错误:java.lang.NoClassDefFoundError:解析失败:Lcom/google/android/gms/internal/zzbck;

这是一个已知问题,插件文档中已经给出了解决方案。

为了解决这个问题,您可以在 app/App_Resources/Android/before-plugins.gradle 文件中固定版本号(如果该文件不存在,只需创建它):

android {  
  // other stuff here

  project.ext {
    googlePlayServicesVersion = "16.+"
  }
}
Run Code Online (Sandbox Code Playgroud)