Android-runtime: Nativescript app builds and crashes upon launch

Created on 25 Apr 2017  路  17Comments  路  Source: NativeScript/android-runtime

Please, provide the details below:

Application builds on both platforms, but runs on IOS only as it crashes upon launch on Android, while it used to run as should before (can't tell what's the change that broke it since i usually test it on IOS), it simply crashes on emulator and my s7.
here's the build log tns_build_android_log.txt

Did you verify this is a real problem by searching [Stack Overflow]

I searched everywhere, found some suggestions like removing Platform and node_modules folders and rebuild, but that did't work

### Please provide the following version numbers that your issue occurs with:

  • CLI: 2.5.2
  • Cross-platform modules: 2.3.0
  • Runtime(s): 2.5.0
  • package.json:
{
  "description": "NativeScript Application",
  "license": "SEE LICENSE IN <your-license-filename>",
  "readme": "NativeScript Application",
  "repository": "<fill-your-repository-here>",
  "nativescript": {
    "id": "com.makhzoumifoundation.general",
    "tns-ios": {
      "version": "2.5.0"
    },
    "tns-android": {
      "version": "2.5.0"
    }
  },

  "dependencies": {
    "nativescript-intl": "0.0.10",
    "nativescript-loading-indicator": "^2.3.2",
    "nativescript-local-notifications": "^1.2.1",
    "nativescript-push-notifications": "^0.1.2",
    "nativescript-sqlite": "^1.1.2",
    "nativescript-statusbar": "^1.0.0",
    "nativescript-telerik-ui-pro": "file:///Users/ryanzaatari/Documents/Development/NativeScript/nativescript-ui-pro.tgz",
    "nativescript-theme-core": "^1.0.3",
    "tns-core-modules": "^2.5.2"
  },
  "devDependencies": {
    "babel-traverse": "6.23.1",
    "babel-types": "6.23.0",
    "babylon": "6.16.1",
    "lazy": "1.0.11"
  }
}
question

All 17 comments

Hi @ryanzaatari,
I reviewed this case on my side while using the above-given information and the mentioned plugins, however, was unable to reproduce this runtime exception.
It would help if you provide sample project, which could help us to research further this case and allow us to debug the problem on our side.

Something that I could suggest is to setup __enableVerboseLogging(); in the very beginning of the app.ts or app.js file, which will enable logging all runtime errors.
For example:
app.ts

declare var __enableVerboseLogging:any
__enableVerboseLogging();
import "./bundle-config";
import * as app from 'application';

app.start({ moduleName: 'main-page' });

app.js

__enableVerboseLogging();
require("./bundle-config");
var app = require("application");
app.start({ moduleName: 'main-page' });

After that, you could run adb logcat command in the terminal and start the app on the device or emulator. When the app crash, please send us the full log from the terminal.

@ryanzaatari I would also ask that you copy-pasted just the adb logcat report, and or shared what the exception is so that we could pinpoint what the cause could be. Thank you.

@tsonevn & @Pip3r4o Thank you for pointing out the enableVerboseLogging setting, as I wasn't aware of that!
Here is the output of adb logcat:

Also, tns run android outputted the following:
chromium: [INFO:library_loader_hooks.cc(163)] Chromium logging enabled: level = 0, default verbosity = 0
04-26 15:48:00.694 27023 27023 I cr_BrowserStartup: Initializing chromium process, singleProcess=true
chromium: [ERROR:child_thread_impl.cc(762)] Request for unknown Channel-associated interface: ui::mojom::GpuMain
chromium: [INFO:CONSOLE(0)] "Document was loaded from Application Cache with manifest https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40-loader.appca
che", source: https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40-loader.html (0)
chromium: [INFO:CONSOLE(0)] "Application Cache Checking event", source: https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40-loader.html (0)
chromium: [INFO:CONSOLE(0)] "Application Cache NoUpdate event", source: https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40-loader.html (0)

04-26 15:48:45.809 27212 27212 E AndroidRuntime: FATAL EXCEPTION: main
04-26 15:48:45.809 27212 27212 E AndroidRuntime: Process: com.makhzoumifoundation.general, PID: 27212
04-26 15:48:45.809 27212 27212 E AndroidRuntime: java.lang.RuntimeException: Unable to get provider com.google.firebase.provider.FirebaseInitProvider: java.lang.IllegalStateException: Incorrect provider authority in manifest. Most likely due to a missing applicationId variable in application's build.gradle.

What's the applicationId entry in your package.json and in app/App_Resources/Android/app.gradle ? Have you setup the push plugin as described in the README?

Also the logs with chromium: [TAGS:CONSOLE] are logged by a webview - I reckon you use one in your application. Nothing to worry about.

in package.json:
"id": "com.makhzoumifoundation.general"
However in app.gradle, content is commented out !?

// Add your native dependencies here:

// Uncomment to add recyclerview-v7 dependency
//dependencies {
// compile 'com.android.support:recyclerview-v7:+'
//}

And yes, I did setup push plugin following the README, below is the AndroidManifest.xml file content:
`
package="__PACKAGE__"
android:versionCode="1"
android:versionName="1.0">

<supports-screens
    android:smallScreens="true"
    android:normalScreens="true"
    android:largeScreens="true"
    android:xlargeScreens="true"/>

<uses-sdk
    android:minSdkVersion="17"
    android:targetSdkVersion="__APILEVEL__"/>

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>

<application
    android:name="com.tns.NativeScriptApplication"
    android:allowBackup="true"
    android:icon="@drawable/icon"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.tns.NativeScriptActivity"
        android:label="@string/title_activity_kimera"
        android:configChanges="keyboardHidden|orientation|screenSize">

            <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>


`

@ryanzaatari is that all of app.gradle's content? There should be an android { defaultConfig { applicationId = "my.application.MyApplicationId" } } entry, which I am not seeing.

@Pip3r4o Yes, that's the whole thing, is there anyway to regenerate the file again then ?

@ryanzaatari tns create myapp create a new independent application and copy its app.gradle content in your project. Replace the applicationId with the one present in the package.json.

@Pip3r4o that caused the crash indeed, after pasting the new app.gradle content, and replaced the ApplicationId, the app now builds and runs perfectly fine.

Cheers!

Hey, I the same issue on Android, but I use nativescript with angular. I have tried __enableVerboseLogging(); but it shows nothing. Here is my package.json:

{
  "description": "Azoft Device Tracking System",
  "nativescript": {
    "id": "org.nativescript.AzoftDeviceTracking",
    "tns-android": {
      "version": "3.0.0"
    }
  },
  "dependencies": {
    "@angular/animations": "~4.1.3",
    "@angular/common": "~4.1.3",
    "@angular/compiler": "~4.1.3",
    "@angular/core": "~4.1.3",
    "@angular/forms": "~4.1.3",
    "@angular/http": "~4.1.3",
    "@angular/platform-browser": "~4.1.3",
    "@angular/platform-browser-dynamic": "~4.1.3",
    "@angular/router": "~4.1.3",
    "nativescript-angular": "~3.0.0",
    "nativescript-barcodescanner": "2.5.1",
    "nativescript-cardview": "2.0.0-rc.0",
    "nativescript-loading-indicator": "2.3.2",
    "nativescript-localstorage": "1.1.2",
    "nativescript-permissions": "1.2.3",
    "nativescript-theme-core": "~1.0.4",
    "reflect-metadata": "~0.1.10",
    "rxjs": "~5.4.0",
    "tns-core-modules": "3.0.0",
    "zone.js": "~0.8.10"
  },
  "devDependencies": {
    "babel-traverse": "6.24.1",
    "babel-types": "6.24.1",
    "babylon": "6.17.1",
    "lazy": "1.0.11",
    "nativescript-dev-android-snapshot": "0.*.*",
    "nativescript-dev-sass": "1.1.1",
    "nativescript-dev-typescript": "~0.4.5",
    "tns-platform-declarations": "3.0.1",
    "typescript": "~2.3.2"
  }
}

No idea how to debug it, could somebody help me?

Hi @FriOne,
I tested your case while using the attached package.json file and was able tor reproduce a problem with executing one of the hooks for nativescript-dev-sass plugin.
Could you remove the nativescript-dev-sass plugin and verify, if you will still have an issue with app start after the build.
You could also try to create a clear nativescript project with tns create sample --ng and to check if you will have the same problem.

In case the issue still exists, please send us a project, which could be debugged locally and give us some more info about your environment(CLI, node versions).

Guess you are right, but I reverted back to 2.5 and it was a little bit painful :)
I will try it later, thanks! I'm just curious if there is a way to find where the error really is, without removing the packages ..

Hi @FriOne,
Do you have a chance to verify, whether you will have the same problem while using NativeScript 3.0 after you remove nativescript-dev-sass from the project?
If you are able to build the application without the plugin, most probably there is an issue with the plugin or it is not migrated to NativeScript 3.0.

Hi sir I have same problem.

Here is my adb log

06-02 14:13:48.903 31316 31316 E AndroidRuntime: Process: com.arktivetour.mohammedbashiru, PID: 31316
06-02 14:13:48.903 31316 31316 E AndroidRuntime: java.lang.RuntimeException: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException: 
06-02 14:13:48.903 31316 31316 E AndroidRuntime: 
06-02 14:13:48.903 31316 31316 E AndroidRuntime: Cannot compile /data/data/com.arktivetour.mohammedbashiru/files/app/main.js
06-02 14:13:48.903 31316 31316 E AndroidRuntime: 
06-02 14:13:48.903 31316 31316 E AndroidRuntime: SyntaxError: Unexpected identifier
06-02 14:13:48.903 31316 31316 E AndroidRuntime: File: "file:///data/data/com.arktivetour.mohammedbashiru/files/app/main.js, line: 6, column: 7
06-02 14:13:48.903 31316 31316 E AndroidRuntime: 
06-02 14:13:48.903 31316 31316 E AndroidRuntime: StackTrace: 
06-02 14:13:48.903 31316 31316 E AndroidRuntime:    Frame: function:'require', file:'', line: 1, column: 266
06-02 14:13:48.903 31316 31316 E AndroidRuntime: 
06-02 14:13:48.903 31316 31316 E AndroidRuntime: 
06-02 14:13:48.903 31316 31316 E AndroidRuntime: SyntaxError: Unexpected identifier
06-02 14:13:48.903 31316 31316 E AndroidRuntime: File: "<unknown>, line: 1, column: 265
06-02 14:13:48.903 31316 31316 E AndroidRuntime: 
06-02 14:13:48.903 31316 31316 E AndroidRuntime: StackTrace: 
06-02 14:13:48.903 31316 31316 E AndroidRuntime:    Frame: function:'require', file:'', line: 1, column: 266
06-02 14:13:48.903 31316 31316 E AndroidRuntime: 
06-02 14:13:48.903 31316 31316 E AndroidRuntime: 
06-02 14:13:48.903 31316 31316 E AndroidRuntime:    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6227)
06-02 14:13:48.903 31316 31316 E AndroidRuntime:    at android.app.ActivityThread.access$1100(ActivityThread.java:211)
06-02 14:13:48.903 31316 31316 E AndroidRuntime:    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1778)
06-02 14:13:48.903 31316 31316 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:107)
06-02 14:13:48.903 31316 31316 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:214)
06-02 14:13:48.903 31316 31316 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:7116)
06-02 14:13:48.903 31316 31316 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
06-02 14:13:48.903 31316 31316 E AndroidRuntime:    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
06-02 14:13:48.903 31316 31316 E AndroidRuntime:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:925)
06-02 14:13:48.903 31316 31316 E AndroidRuntime: Caused by: com.tns.NativeScriptException: 
06-02 14:13:48.903 31316 31316 E AndroidRuntime: 
06-02 14:13:48.903 31316 31316 E AndroidRuntime: Cannot compile /data/data/com.arktivetour.mohammedbashiru/files/app/main.js
06-02 14:13:48.903 31316 31316 E AndroidRuntime: 
06-02 14:13:48.903 31316 31316 E AndroidRuntime: SyntaxError: Unexpected identifier
06-02 14:13:48.903 31316 31316 E AndroidRuntime: File: "file:///data/data/com.arktivetour.mohammedbashiru/files/app/main.js, line: 6, column: 7
06-02 14:13:48.903 31316 31316 E AndroidRuntime: 
06-02 14:13:48.903 31316 31316 E AndroidRuntime: StackTrace: 
06-02 14:13:48.903 31316 31316 E AndroidRuntime:    Frame: function:'require', file:'', line: 1, column: 266
06-02 14:13:48.903 31316 31316 E AndroidRuntime: 
06-02 14:13:48.903 31316 31316 E AndroidRuntime: 
06-02 14:13:48.903 31316 31316 E AndroidRuntime: SyntaxError: Unexpected identifier
06-02 14:13:48.903 31316 31316 E AndroidRuntime: File: "<unknown>, line: 1, column: 265
06-02 14:13:48.903 31316 31316 E AndroidRuntime: 
06-02 14:13:48.903 31316 31316 E AndroidRuntime: StackTrace: 
06-02 14:13:48.903 31316 31316 E AndroidRuntime:    Frame: function:'require', file:'', line: 1, column: 266
06-02 14:13:48.903 31316 31316 E AndroidRuntime: 
06-02 14:13:48.903 31316 31316 E AndroidRuntime: 
06-02 14:13:48.903 31316 31316 E AndroidRuntime:    at com.tns.Runtime.runModule(Native Method)
06-02 14:13:48.903 31316 31316 E AndroidRuntime:    at com.tns.Runtime.runModule(Runtime.java:624)
06-02 14:13:48.903 31316 31316 E AndroidRuntime:    at com.tns.Runtime.run(Runtime.java:616)
06-02 14:13:48.903 31316 31316 E AndroidRuntime:    at com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:21)
06-02 14:13:48.903 31316 31316 E AndroidRuntime:    at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1182)
06-02 14:13:48.903 31316 31316 E AndroidRuntime:    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6222)
06-02 14:13:48.903 31316 31316 E AndroidRuntime:    ... 8 more
06-02 14:13:48.904 31316 31316 W System.err: java.lang.RuntimeException: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException: 
06-02 14:13:48.904 31316 31316 W System.err: 
06-02 14:13:48.904 31316 31316 W System.err: Cannot compile /data/data/com.arktivetour.mohammedbashiru/files/app/main.js
06-02 14:13:48.904 31316 31316 W System.err: 
06-02 14:13:48.904 31316 31316 W System.err: SyntaxError: Unexpected identifier
06-02 14:13:48.904 31316 31316 W System.err: File: "file:///data/data/com.arktivetour.mohammedbashiru/files/app/main.js, line: 6, column: 7
06-02 14:13:48.904 31316 31316 W System.err: 
06-02 14:13:48.904 31316 31316 W System.err: StackTrace: 
06-02 14:13:48.905 31316 31316 W System.err:    Frame: function:'require', file:'', line: 1, column: 266
06-02 14:13:48.905 31316 31316 W System.err: 
06-02 14:13:48.905 31316 31316 W System.err: 
06-02 14:13:48.905 31316 31316 W System.err: SyntaxError: Unexpected identifier
06-02 14:13:48.905 31316 31316 W System.err: File: "<unknown>, line: 1, column: 265
06-02 14:13:48.905 31316 31316 W System.err: 
06-02 14:13:48.905 31316 31316 W System.err: StackTrace: 
06-02 14:13:48.905 31316 31316 W System.err:    Frame: function:'require', file:'', line: 1, column: 266
06-02 14:13:48.905 31316 31316 W System.err: 
06-02 14:13:48.905 31316 31316 W System.err:    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6227)
06-02 14:13:48.905 31316 31316 W System.err:    at android.app.ActivityThread.access$1100(ActivityThread.java:211)
06-02 14:13:48.905 31316 31316 W System.err:    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1778)
06-02 14:13:48.905 31316 31316 W System.err:    at android.os.Handler.dispatchMessage(Handler.java:107)
06-02 14:13:48.905 31316 31316 W System.err:    at android.os.Looper.loop(Looper.java:214)
06-02 14:13:48.905 31316 31316 W System.err:    at android.app.ActivityThread.main(ActivityThread.java:7116)
06-02 14:13:48.905 31316 31316 W System.err:    at java.lang.reflect.Method.invoke(Native Method)
06-02 14:13:48.905 31316 31316 W System.err:    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
06-02 14:13:48.905 31316 31316 W System.err:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:925)
06-02 14:13:48.905 31316 31316 W System.err: Caused by: com.tns.NativeScriptException: 
06-02 14:13:48.905 31316 31316 W System.err: 
06-02 14:13:48.906 31316 31316 W System.err: Cannot compile /data/data/com.arktivetour.mohammedbashiru/files/app/main.js
06-02 14:13:48.906 31316 31316 W System.err: 
06-02 14:13:48.906 31316 31316 W System.err: SyntaxError: Unexpected identifier
06-02 14:13:48.906 31316 31316 W System.err: File: "file:///data/data/com.arktivetour.mohammedbashiru/files/app/main.js, line: 6, column: 7
06-02 14:13:48.906 31316 31316 W System.err: 
06-02 14:13:48.906 31316 31316 W System.err: StackTrace: 
06-02 14:13:48.906 31316 31316 W System.err:    Frame: function:'require', file:'', line: 1, column: 266
06-02 14:13:48.906 31316 31316 W System.err: 
06-02 14:13:48.906 31316 31316 W System.err: 
06-02 14:13:48.906 31316 31316 W System.err: SyntaxError: Unexpected identifier
06-02 14:13:48.906 31316 31316 W System.err: File: "<unknown>, line: 1, column: 265
06-02 14:13:48.906 31316 31316 W System.err: 
06-02 14:13:48.906 31316 31316 W System.err: StackTrace: 
06-02 14:13:48.906 31316 31316 W System.err:    Frame: function:'require', file:'', line: 1, column: 266
06-02 14:13:48.906 31316 31316 W System.err: 
06-02 14:13:48.906 31316 31316 W System.err:    at com.tns.Runtime.runModule(Native Method)
06-02 14:13:48.906 31316 31316 W System.err:    at com.tns.Runtime.runModule(Runtime.java:624)
06-02 14:13:48.906 31316 31316 W System.err:    at com.tns.Runtime.run(Runtime.java:616)
06-02 14:13:48.906 31316 31316 W System.err:    at com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:21)
06-02 14:13:48.906 31316 31316 W System.err:    at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1182)
06-02 14:13:48.906 31316 31316 W System.err:    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6222)

My package JSON

{
  "name": "arktivetour",
  "version": "1.0.0",
  "description": "Tour application by iamMohammedb",
  "author": "Mohammed Bashiru <[email protected]>",
  "license": "MIT",
  "nativescript": {
    "id": "com.arktivetour.mohammedbashiru",
    "tns-ios": {
      "version": "5.3.1"
    },
    "tns-android": {
      "version": "5.3.1"
    }
  },
  "dependencies": {
    "@vue/devtools": "5.0.0-beta.3",
    "email-validator": "^2.0.3",
    "moment": "^2.24.0",
    "nativescript-fonticon": "^2.0.0",
    "nativescript-imagepicker": "^6.2.0",
    "nativescript-localstorage": "^2.0.0",
    "nativescript-permissions": "^1.3.6",
    "nativescript-socket.io": "^0.9.0",
    "nativescript-theme-core": "^1.0.4",
    "nativescript-toast": "^2.0.0",
    "nativescript-ui-dataform": "^4.0.0",
    "nativescript-ui-sidedrawer": "^6.0.0",
    "nativescript-vue": "^2.0.0",
    "nativescript-vue-devtools": "^1.0.0",
    "tns-core-modules": "^5.1.2",
    "vuex": "^3.0.1"
  },
  "devDependencies": {
    "@babel/core": "^7.0.0",
    "@babel/preset-env": "^7.0.0",
    "babel-loader": "^8.0.2",
    "babel-traverse": "6.26.0",
    "babel-types": "6.26.0",
    "babylon": "6.18.0",
    "clean-webpack-plugin": "^0.1.19",
    "copy-webpack-plugin": "^4.5.2",
    "css-hot-loader": "^1.4.2",
    "css-loader": "^1.0.0",
    "lazy": "1.0.11",
    "mini-css-extract-plugin": "^0.4.1",
    "nativescript-dev-webpack": "^0.17.0-2018-09-12-01",
    "nativescript-vue-template-compiler": "^2.0.0-alpha.3",
    "nativescript-worker-loader": "~0.9.0",
    "node-sass": "^4.9.2",
    "sass-loader": "^7.1.0",
    "uglifyjs-webpack-plugin": "~1.2.7",
    "vue-loader": "^15.2.6",
    "webpack": "^4.32.2",
    "webpack-bundle-analyzer": "~2.13.1",
    "webpack-cli": "^3.1.0"
  }
}

Looking forward to your assistance. Thank you.

HI @dantanie,
Try to upgrade {N} and the other used dependencies to the latest available version and check if you will be able to recreate the issue. Check out the update instructions here.

Hi @tsonevn Its working. I omitted the

--bundle
When building the app and thats why it was crashing

Hi @dantanie,
I am glad to hear that, you were able to solve the issue on your side, however, can you send us a sample project, which can help us in investigating, why this problem happens with a bundle.
Note: With upcoming {N} v 6.0, the only way to build NS project will be while using the bundle.

Was this page helpful?
0 / 5 - 0 ratings