【问题标题】:Android Nativescript app crashing on start upAndroid Nativescript 应用程序在启动时崩溃
【发布时间】:2021-08-26 23:15:28
【问题描述】:

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

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

我想知道 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 firebase mobile nativescript nativescript-angular


    【解决方案1】:

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

    targetSDKVersion 减少到 29。

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

    摆脱"webpack"

    【讨论】:

      【解决方案2】:

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

      【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多