Android Nativescript 应用在启动时崩溃

Android Nativescript app crashing on start up

我正在构建一个可以处理 iOS 和 Android 平台的 Nativescript 应用程序。这是一个使用蓝牙权限、firebase 的应用程序,它的 targetSDK 是 30(由于 Google Play Policy)

我的应用程序在启动时崩溃,但仅在 ANDROID 时崩溃。我不知道为什么 tns debug android 不输出任何消息。我的所有文件中的应用程序 ID 都相同。我不知道该怎么办。我在较旧的 Android 运行 Android 8 上测试了相同的代码并且工作正常。它仅适用于较新的设备。

我想知道 Android 特定代码是否有问题,但我不确定是什么。

This issue may be caused by:
    * crash at startup (try `tns debug android --debug-brk` to check why it crashes)
    * different application identifier in your package.json and in your gradle files (check your identifier in `package.json` and in all *.gradle files in your App_Resources directory)
    * device is locked
    * manual closing of the application
Unable to apply changes on device: R58M50KS8YL. Error is: Application com.xxxxllc.xxxx is not running.

这是我的 app.gradle,我的 applicationId 与 nativescript.config.ts 文件和 package.json 文件中的相同。

android {
  defaultConfig {
    applicationId "com.xxxxllc.xxxx"
    minSdkVersion 21
    targetSdkVersion 30
    generatedDensities = []
  }
  aaptOptions {
    additionalParameters "--no-version-vectors"
  }
}

package.json

"nativescript": {
    "id": "com.xxxxllc.xxxx"
  },
...

nativescript.config.ts

export default {
  id: 'com.xxxxllc.xxxx',
  appPath: 'src',
  appResourcesPath: 'App_Resources',
  android: {
    v8Flags: '--expose_gc',
    markingMode: 'none'
  }
} as NativeScriptConfig;

完整 package.json

"dependencies": {
    "@angular/animations": "~11.2.7",
    "@angular/cdk": "~11.2.7",
    "@angular/common": "~11.2.7",
    "@angular/compiler": "~11.2.7",
    "@angular/core": "~11.2.7",
    "@angular/forms": "~11.2.7",
    "@angular/platform-browser": "~11.2.7",
    "@angular/router": "~11.2.7",
    "@bradmartin/nativescript-urlhandler": "^2.0.1",
    "@mhtghn/nativescript-highcharts": "^1.0.2",
    "@nativescript-community/ble": "^3.0.25",
    "@nativescript-community/insomnia": "^2.0.2",
    "@nativescript-community/ui-drawer": "0.0.28",
    "@nativescript/angular": "~11.8.0",
    "@nativescript/core": "^8.0.8",
    "@nativescript/firebase": "^11.1.3",
    "@nativescript/theme": "~3.0.1",
    "@proplugins/nativescript-purchase": "^6.0.0",
    "@triniwiz/nativescript-toasty": "~4.1.3",
    "bluebird": "3.5.5",
    "crypto-es": "^1.2.7",
    "nativescript-permissions": "^1.3.11",
    "nativescript-sentry": "^2.0.1",
    "npm-check-updates": "^11.8.3",
    "reflect-metadata": "^0.1.13",
    "rxjs": "~6.6.7",
    "zone.js": "~0.11.4"
  },
  "devDependencies": {
    "@angular/compiler-cli": "~11.2.7",
    "@nativescript/android": "8.0.0",
    "@nativescript/ios": "8.0.0",
    "@nativescript/types": "~8.0.0",
    "@nativescript/webpack": "5.0.0-dev.5",
    "@ngtools/webpack": "^11.2.14",
    "webpack": "5.48.0",
    "sass": "~1.35.1",
    "ts-node": "~10.0.0",
    "typescript": "~4.0.0"
  },

以下修复了 Android 11 部手机上的崩溃错误:

减少 targetSDKVersion 到 29。

@nativescript/wepback 更改为 "5.0.0-rc.4"

正在摆脱 "webpack"

我在删除 nativescript-sentry 之前遇到了同样的问题