【问题标题】:nativescript-geolocation crash on geolocation.enableLocationRequest()geolocation.enableLocationRequest() 上的 nativescript-geolocation 崩溃
【发布时间】:2020-02-07 00:12:41
【问题描述】:

我在模拟器上使用 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

【问题讨论】:

  • 请补充详细信息,至少有完整的崩溃日志会更好。
  • @Manoj ,我添加了更多信息。你怎么看?

标签: android nativescript nativescript-vue


【解决方案1】:

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

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

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

android {  
  // other stuff here

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

【讨论】:

  • 天哪,兄弟,再次拯救生命。 ? 谢谢!
猜你喜欢
  • 2021-04-25
  • 1970-01-01
  • 2021-12-13
  • 1970-01-01
  • 1970-01-01
  • 2020-03-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多