Error in versionName for Nativescript 7 or later

Nativescript version: 8.3; vue/ts.

I'm facing an issue with assigning versioning to my Nativescript application. Despite following the guidelines, the versionName remains 1.0.0 and versionCode stays at 1. This problem persists whether I am debugging or running a release build.

According to the nativescript documentation and android documentation, I have set the versionName and versionCode in my AndroidManifest.xml ([project_root]/App_Resources/Android/src/main/AndroidManifest.xml) as follows:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    android:versionCode="3"
    android:versionName="1.0.2"
    package="__PACKAGE__">
...

Using @nativescript/appversion returns versionName of 1.0.0 and versionCode of 1:

let versionName = appversion.getVersionNameSync();
let versionCode = appversion.getVersionCodeSync();

The same outcome is observed when using (which appears to be deprecated):

var packageManager = Application.android.context.getPackageManager();
let versionName = packageManager.getPackageInfo(
  Application.android.context.getPackageName(), 0).versionName;
let versionCode = packageManager.getPackageInfo(
  Application.android.context.getPackageName(), 0).versionCode;

And also with:

var packageManager = Utils.android.getApplicationContext().getPackageManager();
let versionName = packageManager.getPackageInfo(
  Utils.android.getApplicationContext().getPackageName(), 0).versionName;
let versionCode = packageManager.getPackageInfo(
  Utils.android.getApplicationContext().getPackageName(), 0).versionCode;

My nsconfig.json is defined as:

{
    "appResourcesPath": "App_Resources"
}

Note: Though optional, I need this setup for compatibility with nativescript-app-sync and a local nativescript-app-sync-server. Just providing context.

Answer №1

Have you attempted updating the versionCode in app.gradle as well?

Try replacing your manifest with this snippet and see if it works.

<manifest xmlns:android="schemas.android.com/apk/res/android"
          xmlns:tools="schemas.android.com/tools" 
          package="PACKAGE" 
          android:versionCode="3" 
          android:versionName="1.0.2">

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

I am having trouble getting the guide for setting up a NextJS app with Typescript to function properly

For some time now, I have been experimenting with integrating Typescript into my NextJS projects. Initially, I believed that getting started with Typescript would be the most challenging part, but it turns out that installing it is proving to be even more ...

Thread of Worker, different document from oneself, unable to locate module

Is there a way to separate my worker thread into an external file from the main runtime file? Currently, my folder structure looks like this: src/ > service.ts // my 'main' > thread/ >> test.js In my service.ts file, I have the follo ...

What is the best way to troubleshoot the TypeScript error I am encountering in my JavaScript file?

Currently experiencing a TypeScript error within a JavaScript file https://i.sstatic.net/gBzWx.png The issue is within a folder containing only one JavaScript file, and there are no Node.js or package.json files present. I have disabled the TypeScript ex ...

What is the process for configuring PhpStorm to sync with TypeScript tsconfig.json in .vue files?

Vue.js (webpack + vueify) with TypeScript is my current setup. The ts configuration appears to be functioning, but only in .ts files. For instance, in tsconfig.json: "compilerOptions": { "strictNullChecks": false, So strictNullChecks works as expect ...

Unit testing for Angular service involving a mock Http GET request is essential for ensuring the

I am seeking guidance on how to test my service function that involves http get and post calls. I attempted to configure the spec file by creating an instance of the service, and also consulted several sources on creating a mockhttp service. However, I enc ...

Progress bar in a thread being enabled and updated

I am facing an issue where the progress bar does not display or update when accessed from a thread. Instead, I would like to show a progress spinner until the network activity (posting text data to the server) is complete. Below is my current code snippe ...

Can you reference a data type within a Typescript declaration of an Angular2 data model?

When working with Mongoose, there is a convenient way to reference another data definition. I'm curious if there is a similar approach we can take when defining a data module for Angular 2? In Mongoose var personSchema = Schema({ _id : Number, ...

Traversing Abstract Syntax Trees Recursively using TypeScript

Currently in the process of developing a parser that generates an AST and then traversing it through different passes. The simplified AST structure is as follows: type LiteralExpr = { readonly kind: 'literal', readonly value: number, }; type ...

The function did not return a Promise or value as expected when using async and await

    I have been working on implementing this code structure for my cloud functions using httpRequest. It has worked seamlessly with those httpRequest functions in the past. However, I recently encountered an error when trying to use it with the OnWrite ...

Leverage TypeScript generics to link props with state in a React class-based component

Can the state type be determined based on the prop type that is passed in? type BarProps = { availableOptions: any[] } type BarState = { selectedOption: any } export default class Bar extends React.Component<BarProps, BarState> { ...

GSON and citations

I have a small Android app that needs to communicate with a server via a socket. My question is: can I utilize Gson to serialize object references? For example, consider a class B: public class B{ int n; public B(int n){ this.n=n; } ...

When it comes to dealing with signature overload, the behavior of Record and Map may not align

This scenario may seem straightforward, but it's causing confusion. I have a function with an overloaded signature that can accept either a Record or a Map. However, even though I am passing a Map as an argument, TypeScript is treating it as a Record. ...

A guide on harnessing the power of a promise in Typescript

Although I am familiar with async/await/then, I recently stumbled upon something new that sparked my curiosity: Consider the following function: HelloWorld():Promise<string> { return new Promise(resolve => { setTimeout(() => { ...

Utilizing mapped types in a proxy solution

As I was going through the TS Handbook, I stumbled upon mapped types where there's a code snippet demonstrating how to wrap an object property into a proxy. type Proxy<T> = { get(): T; set(value: T): void; } type Proxify<T> = { ...

Watch a video directly from a ByteArrayOutputStream in your Android device

In the process of developing a video player, I am faced with the challenge of playing an encrypted video file that needs to be decrypted in real time. The decryption involves storing the decrypted content in a buffer (such as ByteArrayOutputStream) before ...

The functionality of the Request interface appears to be malfunctioning

Hey there, I'm currently working on building an API using Express and TypeScript. My goal is to extend the Request object to include a user property. I've done some research on Google and found several posts on StackOverflow that explain how to d ...

Typescript: Express RequestHandler variable potentially undefined even after validation within if statement

As I work on a solution for dynamically creating routes before the server fully initializes (not in response to a request, of course), I encountered an interesting issue. Here's a simplified example. In my actual code, there are more parameters like ...

How can I make sure that my function returns a mutated object that is an instance of the same class in

export const FilterUndefined = <T extends object>(obj: T): T => { return Object.entries(obj).reduce((acc, [key, value]) => { return value ? { ...acc, [key]: value } : acc; }, {}) as T; }; During a database migration process, I encounte ...

Display the elements within the ImageView array by utilizing a Thread

I am facing an issue with making a number of invisible elements visible in sequence using either Thread or runOnUiThread. My goal is to make the first element visible, then wait for half a second before making the next one visible, and so on. Here's ...

How can I retrieve information from MySQL and present it as a list in the "App List" tab on Android?

As a beginner in Android development, I have some questions that I need help with. 1...I currently have a database set up on my local host using MySQL server. It contains a table of all the "States". Q2...I have written a PHP script to connect to this da ...