Android Nativescript app crashing on start up

Issue

I’m building a Nativescript app that will handle both the iOS and Android platforms. It’s an app that uses bluetooth permissions, firebase, and it’s targetSDK is 30 (due to Google Play Policy)

My app is crashing on start up, but ONLY ON ANDROID. I have no idea why and tns debug android outputs no message. My application id is the same across all my files. I’m not sure what to do. I tested the same code on an older Android running Android 8 and that worked fine. It’s only on newer devices.

I’m wondering if it’s something wrong with Android specific code, but I’m not sure what.

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.

Here is my app.gradle, with my applicationId the same as in the nativescript.config.ts file and package.json file.

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;

Full 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"
  },

Solution

The following fixed the crashing error on Android 11 phones:

Reducing targetSDKVersion to 29.

Changing @nativescript/wepback to "5.0.0-rc.4".

Getting rid of "webpack".

Answered By – Jose Chavez

Answer Checked By – Marilyn (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.