Nativescript: release apk no work in 3.4.1 version

Created on 1 Feb 2018  路  5Comments  路  Source: NativeScript/NativeScript

Please, provide the details below:

I finish code my code and anything fine in debug mode , after I release apk and install it. The Layout is run and cannot navigate to my another page.

I find out below 2 link but no work to me.

https://github.com/NativeScript/NativeScript/issues/3257
https://github.com/telerik/nativescript-ui-feedback/issues/131

Which platform(s) does your issue occur on?

Android

{
  "description": "NativeScript Application",
  "license": "SEE LICENSE IN <your-license-filename>",
  "readme": "NativeScript Application",
  "repository": "<fill-your-repository-here>",
  "nativescript": {
    "id": "com.dabaolah.driver",
    "tns-android": {
      "version": "3.4.1"
    }
  },
  "dependencies": {
    "nativescript-barcodescanner": "^2.7.4",
    "nativescript-geolocation": "^4.2.3",
    "nativescript-loading-indicator": "^2.4.0",
    "nativescript-localstorage": "^1.1.5",
    "nativescript-phone": "^1.3.1",
    "nativescript-plugin-firebase": "^5.1.5",
    "nativescript-pro-ui": "^3.3.0",
    "nativescript-theme-core": "^1.0.4",
    "tns-core-modules": "^3.4.0"
  },
  "devDependencies": {
    "babel-traverse": "6.4.5",
    "babel-types": "6.4.5",
    "babylon": "6.4.5",
    "copy-webpack-plugin": "~4.3.0",
    "css-loader": "~0.28.7",
    "extract-text-webpack-plugin": "~3.0.2",
    "lazy": "1.0.11",
    "nativescript-dev-webpack": "^0.9.1",
    "nativescript-worker-loader": "~0.8.1",
    "raw-loader": "~0.5.1",
    "resolve-url-loader": "~2.2.1",
    "uglifyjs-webpack-plugin": "~1.1.6",
    "webpack": "~3.10.0",
    "webpack-bundle-analyzer": "^2.9.1",
    "webpack-sources": "~1.1.0"
  }
}

android

Most helpful comment

@yclau I guess you are building in release with Webpack as there was a webpack.config.js file.
Initially I have reproduced the issue but I was able to run your project in release and bundled with Webpack with the following command (release with Wwbpack bundling)

tns run android --bundle --env.uglify --env.snapshot --env.aot --release --for-device --key-store-path ./my-release-key.jks --key-store-password <pass> --key-store-alias <alias> --key-store-alias-password <alias-pass>

and few small changes in bundle.js file

if (global.TNS_WEBPACK) {
    // registers tns-core-modules UI framework modules
    require("bundle-entry-points");

    // register application modules
    // This will register each `page` postfixed xml, css, js, ts, scss etc. in the app/ folder

    // Important! Note that I have manually added the word "content"
    const context = require.context("~/", true, /(page|content|fragment)\.(xml|css|js|ts|scss|less|sass)$/);

    global.registerModule("nativescript-pro-ui/sidedrawer", function() { return require("nativescript-pro-ui/sidedrawer"); });
    global.registerModule("nativescript-pro-ui/listview", function() { return require("nativescript-pro-ui/listview"); });
}

Two things about the changes in bundle.js file

  • in the context regex I have added the word content because not all your XML pages are ending in -page (the one in shared-view/drawer-content is ending in -content) - details explained here
    const context = require.context("~/", true, /(page|content|fragment)\.(xml|css|js|ts|scss|less|sass)$/);
    global.registerWebpackModules(context);
  • I have registered the UI controls from nativescript-pro-ui plugin in bundle config as shown here
    global.registerModule("nativescript-pro-ui/sidedrawer", function() { return require("nativescript-pro-ui/sidedrawer"); });
    global.registerModule("nativescript-pro-ui/listview", function() { return require("nativescript-pro-ui/listview"); });

If there are any additional UI plugins (that are using xmlns-myControlName anywhere in the XML: files) you will need to register them as well.

After those changes, the project was successfully built in release and I was able to navigate from the login page to the drawer page as expected

All 5 comments

@yclau providing screenshots is not enough to investigate what might be causing your issue.
Consider providing sample project or trying to debug locally the logic behind your login page.

One thing you should look for is if the firebase authentication is triggered and successful.(I am guessing you are using email authentication via nativescript-plugin-firebase which you can monitor it at console.firebase.google.com)

e.g.

  firebase.login({
    type: firebase.LoginType.PASSWORD,
    passwordOptions: {
      email: '[email protected]',
      password: 'theirpassword'
    }
  }).then(

      function (result) {
        // is your code receiving a result here
        let res = JSON.stringify(result);
        console.log(res);
      },
      function (errorMessage) {
        // is your code throwing an error here
        console.log(errorMessage);
      }
  );

The above is just a suggestion what might be causing your issue. Still without a code base to work with the issue might have totally different roots. Let me know if you can isolate the problem in a sample project.

@NickIliev i already sent code by email to you. I really can't find out what is problem and i no using any firebase authentication in my project. And I no get any crash report in firebase crash report

@yclau I guess you are building in release with Webpack as there was a webpack.config.js file.
Initially I have reproduced the issue but I was able to run your project in release and bundled with Webpack with the following command (release with Wwbpack bundling)

tns run android --bundle --env.uglify --env.snapshot --env.aot --release --for-device --key-store-path ./my-release-key.jks --key-store-password <pass> --key-store-alias <alias> --key-store-alias-password <alias-pass>

and few small changes in bundle.js file

if (global.TNS_WEBPACK) {
    // registers tns-core-modules UI framework modules
    require("bundle-entry-points");

    // register application modules
    // This will register each `page` postfixed xml, css, js, ts, scss etc. in the app/ folder

    // Important! Note that I have manually added the word "content"
    const context = require.context("~/", true, /(page|content|fragment)\.(xml|css|js|ts|scss|less|sass)$/);

    global.registerModule("nativescript-pro-ui/sidedrawer", function() { return require("nativescript-pro-ui/sidedrawer"); });
    global.registerModule("nativescript-pro-ui/listview", function() { return require("nativescript-pro-ui/listview"); });
}

Two things about the changes in bundle.js file

  • in the context regex I have added the word content because not all your XML pages are ending in -page (the one in shared-view/drawer-content is ending in -content) - details explained here
    const context = require.context("~/", true, /(page|content|fragment)\.(xml|css|js|ts|scss|less|sass)$/);
    global.registerWebpackModules(context);
  • I have registered the UI controls from nativescript-pro-ui plugin in bundle config as shown here
    global.registerModule("nativescript-pro-ui/sidedrawer", function() { return require("nativescript-pro-ui/sidedrawer"); });
    global.registerModule("nativescript-pro-ui/listview", function() { return require("nativescript-pro-ui/listview"); });

If there are any additional UI plugins (that are using xmlns-myControlName anywhere in the XML: files) you will need to register them as well.

After those changes, the project was successfully built in release and I was able to navigate from the login page to the drawer page as expected

Hi @NickIliev ,
Thank you your support. I try research and solve almost 1 week , finally you solved my problem.
Thank you.

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings