nativescript-cli icon indicating copy to clipboard operation
nativescript-cli copied to clipboard

The sample Javascript app crashes after starting

Open NickIliev opened this issue 10 years ago • 5 comments

From @michelkal on November 4, 2016 13:8

Following the tutorial here When I start the App with tns run android or tns run android --emulator it runs well but when I run tns livesync android the App crashes with the below error.

tns livesync android
Project successfully prepared (android)
Transferring project files...
Successfully transferred all files.
Applying changes...
Successfully synced application org.nativescript.sampleGroceries on device emulator-5554.
W/System.err( 2387):    at com.tns.Runtime.callJSMethodNative(Native Method)
W/System.err( 2387):    at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:865)
W/System.err( 2387):    at com.tns.Runtime.callJSMethodImpl(Runtime.java:730)
W/System.err( 2387):    at com.tns.Runtime.callJSMethod(Runtime.java:716)
W/System.err( 2387):    at com.tns.Runtime.callJSMethod(Runtime.java:697)
W/System.err( 2387):    at com.tns.Runtime.callJSMethod(Runtime.java:687)

I'm running this on windows 10.

Copied from original issue: NativeScript/NativeScript#3025

NickIliev avatar Nov 04 '16 13:11 NickIliev

Hey @michelkal

Can you provide us with some additional information about the versions of CLI and runtime you are using? I have tested it on my side and the branch is working as expected. Tested with

  "nativescript": {
    "id": "org.nativescript.groceries",
    "tns-ios": {
      "version": "2.3.0"
    },
    "tns-android": {
      "version": "2.3.0"
    }
  },
  "dependencies": {
    "@angular/common": "2.0.0",
    "@angular/compiler": "2.0.0",
    "@angular/core": "2.0.0",
    "@angular/http": "2.0.0",
    "@angular/platform-browser": "2.0.0",
    "@angular/platform-browser-dynamic": "2.0.0",
    "@angular/platform-server": "2.0.0",
    "@angular/router": "3.0.0",
    "nativescript-angular": "1.0.0",
    "reflect-metadata": "0.1.8",
    "rxjs": "5.0.0-beta.12",
    "tns-core-modules": "2.3.0"
  },

NickIliev avatar Nov 04 '16 15:11 NickIliev

I had the same error, the issue arise with some android emulators and real devices with api level 19. I had this issue with the latest nativescript (2.30) version in windows 10 and mac os x El Capitan. This error is replicated in several issues that were closed but not solved. I read that some dependencies need api level 21 could you please confirm this? THen i'll see if is possible to target only api level 21+ devices, TIA

plaincoder avatar Nov 06 '16 15:11 plaincoder

This is the console output after the apk is built and deployed:

Project successfully built
Successfully deployed on device with identifier '4f3998fa'.
V/GoogleSignatureVerifier(17031): dxiLDmpHpDsz2WCbdxgxRczfey5YZnTJ4VZbH0xqWVW/8lGmPav5xVwnIiJS6HXk+BVKZF+JcWjA
W/dalvikvm(17005):              in Lcom/tns/Runtime;.callJSMethodNative:(IILjava/lang/String;IZ[Ljava/lang/Object;)Ljava/lang/Object; (CallVoidMethodA)
I/dalvikvm(17005):   at com.tns.Runtime.callJSMethodNative(Native Method)
I/dalvikvm(17005):   at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:865)
I/dalvikvm(17005):   at com.tns.Runtime.callJSMethodImpl(Runtime.java:730)
I/dalvikvm(17005):   at com.tns.Runtime.callJSMethod(Runtime.java:716)
I/dalvikvm(17005):   at com.tns.Runtime.callJSMethod(Runtime.java:697)
I/dalvikvm(17005):   at com.tns.Runtime.callJSMethod(Runtime.java:687)

This is the package.json in the main directory :

{
  "name": "Groceries",
  "version": "1.0.0",
  "description": "A NativeScript-built iOS and Android app for managing grocery lists",
  "repository": {
    "type": "git",
    "url": "https://github.com/nativescript/sample-Groceries.git"
  },
  "keywords": [
    "NativeScript"
  ],
  "author": "TJ VanToll <[email protected]> (https://www.tjvantoll.com/)",
  "license": "MIT",
  "bugs": {
    "url": "https://github.com/nativescript/sample-Groceries/issues"
  },
  "homepage": "https://github.com/nativescript/sample-Groceries/groceries",
  "nativescript": {
    "id": "org.nativescript.groceries",
    "tns-android": {
      "version": "2.3.0"
    },
    "tns-ios": {
      "version": "2.3.0"
    }
  },
  "scripts": {
    "tslint": "tslint \"app/**/*.ts\""
  },
  "dependencies": {
    "@angular/common": "~2.1.2",
    "@angular/compiler": "~2.1.2",
    "@angular/core": "~2.1.2",
    "@angular/forms": "~2.1.2",
    "@angular/http": "~2.1.2",
    "@angular/platform-browser": "~2.1.2",
    "@angular/platform-browser-dynamic": "~2.1.2",
    "@angular/router": "~3.1.2",
    "email-validator": "1.0.4",
    "nativescript-angular": "~1.1.2",
    "nativescript-iqkeyboardmanager": "1.0.1",
    "nativescript-social-share": "1.3.1",
    "nativescript-unit-test-runner": "^0.3.3",
    "reflect-metadata": "^0.1.8",
    "rxjs": "5.0.0-beta.12",
    "tns-core-modules": "^2.3.0"
  },
  "devDependencies": {
    "zone.js": "~0.6.21",
    "babel-traverse": "6.8.0",
    "babel-types": "6.8.1",
    "babylon": "6.8.0",
    "codelyzer": "0.0.28",
    "filewalker": "0.1.2",
    "jasmine-core": "^2.4.1",
    "karma": "^1.2.0",
    "karma-jasmine": "^1.0.2",
    "karma-nativescript-launcher": "^0.4.0",
    "lazy": "1.0.11",
    "nativescript-dev-typescript": "^0.3.2",
    "tslint": "^3.14.0",
    "typescript": "^2.0.3"
  }
}

plaincoder avatar Nov 06 '16 19:11 plaincoder

Hey @plaincoder our sample-Groceries application and tested it with nativescript@next and it works as expected on my side with livesync. I've used the @next release because we've included some livesync related fixes in it. IN order to use the @next release of our CLI follow these steps:

npm uninstall -g nativescript
npm install -g nativescript@next
rm -rf platforms
tns livesync --watch android

Will close this issue but please do not hesitate to contact me if you need additional assistance.

NickIliev avatar Dec 05 '16 14:12 NickIliev

Hi, I am writing plugin for paytm gateway and i am getting the following errors, so can you please tell me whats the error or how to debug that error or where it occurred ?

W/System.err( 2637): at com.tns.Runtime.callJSMethodNative(Native Method) W/System.err( 2637): at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.ja va:1197) W/System.err( 2637): at com.tns.Runtime.callJSMethodImpl(Runtime.java:1061) W/System.err( 2637): at com.tns.Runtime.callJSMethod(Runtime.java:1047) W/System.err( 2637): at com.tns.Runtime.callJSMethod(Runtime.java:1028) W/System.err( 2637): at com.tns.Runtime.callJSMethod(Runtime.java:1018)

and my code is ::

 `var app = require("application");
var newPayment = function (arg) {
    var service = com.paytm.pgsdk.PaytmPGService.getStagingService();
    var merchant = arg.merchant;
    var customer = arg.customer;
    var checksumUrls = arg.checksumUrls;

    var paramObject = {};
    // paramMap["REQUEST_TYPE"] = "DEFAULT";
    paramObject["MID"] = merchant.id; 
    paramObject["CHANNEL_ID"] = merchant.channelId; // "WAP";
    paramObject["INDUSTRY_TYPE_ID"] = merchant.industryTypeId; // "Retail";
    paramObject["WEBSITE"] = merchant.website; //"WEB_STAGING";
    paramObject["THEME"] = "merchant";

    paramObject["CUST_ID"] = customer.id;
    paramObject["EMAIL"] = customer.email;
    paramObject["MOBILE_NO"] = customer.mobileNumber;
    paramObject["ORDER_ID"] = customer.orderId;
    paramObject["TXN_AMOUNT"] = customer.txnAmount;

    var paramMap = toHashMap(paramObject);
    console.log("parammap:::", paramMap);

    var order = new com.paytm.pgsdk.PaytmOrder(paramMap);
     var merchant = new com.paytm.pgsdk.PaytmMerchant(checksumUrls.generation, checksumUrls.verification);
    console.log("Merchant:::", merchant);
    var  activity = app.android.foregroundActivity || app.android.startActivity;
    service.initialize(order, merchant, null);
    console.log("Service intialised");

    //Start the Payment Transaction. Before starting the transaction ensure that initialize method is called.
    service.startPaymentTransaction(
       app.android.foregroundActivity || app.android.startActivity, true, true,
        new com.paytm.pgsdk.PaytmPaymentTransactionCallback({
            onTransactionSuccess: function (paramBundle) {
                android.widget.Toast.makeText(app.android.context, "Transaction Successful", android.widget.Toast.LENGTH_SHORT).show();
            },
            onTransactionFailure: function (paramString, paramBundle) {
                android.widget.Toast.makeText(app.android.context, "Transaction Failure", android.widget.Toast.LENGTH_SHORT).show();
            },

            networkNotAvailable: function () {
                android.widget.Toast.makeText(app.android.context, "Check Network connection", android.widget.Toast.LENGTH_SHORT).show();
            },
            clientAuthenticationFailed: function (paramString) {
                android.widget.Toast.makeText(app.android.context, "Client Authentication Failed", android.widget.Toast.LENGTH_SHORT).show();
            },
            someUIErrorOccurred: function (paramString) {
                android.widget.Toast.makeText(app.android.context, "UI Error Occur", android.widget.Toast.LENGTH_SHORT).show();
            },
            onErrorLoadingWebPage: function (paramInt, paramString1, paramString2) {
                android.widget.Toast.makeText(app.android.context, "Error On Loading", android.widget.Toast.LENGTH_SHORT).show();
            },

            onBackPressedCancelTransaction: function () {
                android.widget.Toast.makeText(app.android.context, "Back Button pressed by user", android.widget.Toast.LENGTH_SHORT).show();
            }
        }));
}
var toHashMap = function (obj) {
    var node = new java.util.HashMap();
    for (var property in obj) {
        if (obj.hasOwnProperty(property)) {
            if (obj[property] !== null) {
                node.put(property, String(obj[property]));
            }
        }
    }
    return node;
};
exports.newPayment = newPayment;`

reference url for what i wrote the nativescript wrapper is :: http://paywithpaytm.com/developer/paytm_sdk_doc/?target=example

sarvagayatri avatar Mar 01 '17 05:03 sarvagayatri