Nativescript-cli: Android package name with two segments

Created on 29 Dec 2019  路  5Comments  路  Source: NativeScript/nativescript-cli

Should 'com' be included at the beginning of the package name?
It's like checking in native scripts. But this is not right.
Is there any way to uncheck this?

tns version 6.3.0

feature android help wanted

Most helpful comment

I was able to create an apk by commenting out the bottom line without 'com' prefix.


android-project-service.ts

`

public async validate(projectData: IProjectData, options: IOptions, notConfiguredEnvOptions?: INotConfiguredEnvOptions): Promise<IValidatePlatformOutput> {
        //this.validatePackageName(projectData.projectIdentifiers.android);// uncomment this..
        this.validateProjectName(projectData.projectName);
    const checkEnvironmentRequirementsOutput = await this.$platformEnvironmentRequirements.checkEnvironmentRequirements({
        platform: this.getPlatformData(projectData).normalizedPlatformName,
        projectDir: projectData.projectDir,
        options,
        notConfiguredEnvOptions
    });

    this.$androidToolsInfo.validateTargetSdk({ showWarningsAsErrors: true, projectDir: projectData.projectDir });

    return {
        checkEnvironmentRequirementsOutput
    };
}`

All 5 comments

I was able to create an apk by commenting out the bottom line without 'com' prefix.


android-project-service.ts

`

public async validate(projectData: IProjectData, options: IOptions, notConfiguredEnvOptions?: INotConfiguredEnvOptions): Promise<IValidatePlatformOutput> {
        //this.validatePackageName(projectData.projectIdentifiers.android);// uncomment this..
        this.validateProjectName(projectData.projectName);
    const checkEnvironmentRequirementsOutput = await this.$platformEnvironmentRequirements.checkEnvironmentRequirements({
        platform: this.getPlatformData(projectData).normalizedPlatformName,
        projectDir: projectData.projectDir,
        options,
        notConfiguredEnvOptions
    });

    this.$androidToolsInfo.validateTargetSdk({ showWarningsAsErrors: true, projectDir: projectData.projectDir });

    return {
        checkEnvironmentRequirementsOutput
    };
}`

@kyungjoongo2 the package name verification is going through this method which is basically verifying that you are using a valid package name (no underscores and no special characters). Can you let us know what is the package name that you are trying to assign for your project?

@NickIliev The package name I tried was something like jessica_labs.tot_xxxxxxxx without the 'com' prefix.
In React Native it worked fine.
But isn't it weird to have a 'com' prefix before the package name?
I think this is an issue that will be improved in the next release.

@kyungjoongo2 thanks for the clarification! The thing is that the NativeScript name check is expecting at least three segments (separated by dots) and you are having only two.

So, for example, this would work:

"id": "xyz.jessica_labs.tot_test",

Still, as the Android naming convention for packages is allowing two segments I will mark this issue as an enhancement feature.

Hey @kyungjoongo2 ,
After further investigation of the issue, we've found our current validation allows having application identifier with only two parts, but the first component of it must contain only letters. This is validated here.
We've written this code a long ago, but its main idea was to validate the identifier is valid Uniform Type Identifier. Long ago, the first part of the JAVA package names was required to be written in all-lowercase ASCII letters.
However, a lot has changed in the last couple of years and probably our validation can be extended with additional symbols, like undescore or hyphen, for example.
I was not able to find a relevant and trusty information which are the allowed symbols, but maybe you can give it a try and create a PR? What do you think?

Was this page helpful?
0 / 5 - 0 ratings