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

nativescript-geolocation crash on geolocation.enableLocationRequest()

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

每当我在 mounted() 或单击按钮时调用 geolocation.enableLocationRequest(),应用程序就会崩溃。

虽然在 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>

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

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);
    }

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

Cannot enable the location service. Error: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/internal/zzbck;

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

In order to fix this you might pin the version number in your app/App_Resources/Android/before-plugins.gradle file (if the file does not exist, just create it):

android {  
  // other stuff here

  project.ext {
    googlePlayServicesVersion = "16.+"
  }
}