CWAC-Crossport >> ApplicationId


#1

Hi,

Is it necessary to declare applicationId (e.g., applicationId ‘com.commonsware.android.tablayout.crossport’) in the manifest if we intend to use the CWAC-Crossport library?


#2

Well, you always need a package attribute on the root <manifest> element. That has nothing to do with CWAC-CrossPort. CWAC-CrossPort itself does not put any particular restrictions on applicationId values.

I get the sense that I misunderstood your question, though.


#3

I get the sense that I misunderstood your question, though.

Well, I was trying to understand the differences in non-CP and CP sample apps when I found that every CP based app has this applicationId declared under defaultConfig, whereas non-CP based app doesnt. Thats why I asked.

Well, you always need a package attribute on the root element. That has nothing to do with CWAC-CrossPort.

The statement in defaultConfig is in addition to the package name mentioned in root manifest element. Also, applicationId is different from package name in all cases; it is the package name with with word .crossport appended in the end. For example:
[Under root manifest element] package=“com.commonsware.android.snackbar.action”
[Under defaultConfig] applicationId ‘com.commonsware.android.snackbar.action.crossport’

I wanted to understand the usage of applicationId especially in case of using CWAC-Crossport.

Hope it is clear now!


#4

I found that every CP based app has this applicationId declared under defaultConfig, whereas non-CP based app doesnt

That is just so both can be installed on the same device at the same time.

I wanted to understand the usage of applicationId

The roles of applicationId are covered in The Busy Coder’s Guide to Android Development, in the “Introducing Gradle and the Manifest” chapter, in the “Things in Common Between the Manifest and Gradle” section. See page 84-85 of Version 8.11.

The relevant material appears below.


The package [attribute of the root <manifest> element of the manifest] also serves as our app’s default “application ID”. This needs to be a unique identifier, such that:

  • no two apps can be installed on the same device at the same time with the same application ID

  • no two apps can be uploaded to the Play Store with the same application ID (and other distribution channels may have the same limitation)

By default, the application ID is the package value, but Android Studio users can override it in their Gradle build files. Specifically, inside of the android closure can be a defaultConfig closure, and inside of there can be an applicationId statement:

android {
    // other stuff

    defaultConfig {
        applicationId "com.commonsware.myapplication"
        // more other stuff
    }
}

#5

Nicely explained, thanks!
I skipped all these chapters and rushed to the “Trails”.