Android - Package Name convention
Android follows normal java package conventions plus here is an important snippet of text to read (this is important regarding the wide use of xml files while developing on android).
The reason for having it in reverse order is to do with the layout on the storage media. If you consider each period ('.') in the application name as a path separator, all applications from a publisher would sit together in the path hierarchy.
So, for instance, packages from Adobe would be of the form:
com.adobe.reader (Adobe Reader)
com.adobe.photoshop (Adobe Photoshop)
com.adobe.ideas (Adobe Ideas)
[Note that this is just an illustration and these may not be the exact package names.]
These could internally be mapped (respectively) to:
com/adobe/reader
com/adobe/photoshop
com/adobe/ideas
The concept comes from Package Naming Conventions in Java, more about which can be read
here:*
http://en.wikipedia.org/wiki/Java_package#Package_naming_conventions
Source: http://www.quora.com/Why-do-a-majority-of-Android-package-names-begin-with-com
What should be my Android package name?
In general, a package name begins with the top level domain name of the organization and then the organization's domain and then any subdomains, listed in reverse order. The organization can then choose a specific name for its package. Subsequent components of the package name vary according to an organization's own internal naming conventions.
For example, if an organization in Canada called MySoft creates a package to deal with fractions, naming the package ca.mysoft.fractions distinguishes the fractions package from another similar package created by another company.
for instance, packages from Adobe would be of the form:
com.adobe.reader (Adobe Reader)
com.adobe.photoshop (Adobe Photoshop)
com.adobe.ideas (Adobe Ideas)
The concept comes from Package Naming Conventions in Java, more about which can be read here:
wikipedia
quora
IOS and Android package name
Following Java package naming conventions the reason for underscores for the Android package name is:
Naming Conventions
Package names are written in all lower case to avoid conflict with the names of classes or interfaces.
For iOS, many people use camelCase
. The same case was used your iOS bundle ID or package name but there is no strict rule which case to use. This is only a convention and not a compiler rule.
Valid names consist of letters (lower or upper case), digits, underscores and start from a letter or underscore.
Should they need to be different?
Each platform follows its own conventions but there is no need for them to be different. As aforementioned - you can rename package as you wish using letters, digits and underscores.
What is the practice for package names for cross platform?
If possible - you can use the same package name but it will violate conventions, which is not desirable.
If not possible (e.g. project does not compile) - follow the rules.
IMHO, following conventions (as the also follow the rules) is the best solution.
You can find more information here about Java package naming conventions (this is a different resource).
Naming an android package
It is suggested that you name it according to a domain you own where you mirror it. So for example if you own example.in and you app is called "app" then if it were a url you could have something like app.example.in and for an android package you would have in.example.app
More details on the package naming convention (see the explanation at the package attribute): https://developer.android.com/guide/topics/manifest/manifest-element
What should be the package name of android app?
As stated here: Package names are written in all lower case to avoid conflict with the names of classes or interfaces.
Companies use their reversed Internet domain name to begin their package names—for example, com.example.mypackage for a package named mypackage created by a programmer at example.com
.
Name collisions that occur within a single company need to be handled by convention within that company, perhaps by including the region or the project name after the company name (for example, com.example.region.mypackage).
Packages in the Java language itself begin with java. or javax.
In some cases, the internet domain name may not be a valid package name. This can occur if the domain name contains a hyphen or other special character, if the package name begins with a digit or other character that is illegal to use as the beginning of a Java name, or if the package name contains a reserved Java keyword, such as "int". In this event, the suggested convention is to add an underscore. For example:
Package naming convention Android
Yes, this is possible and will not cause any problems in the Play Store.
You will want to read the Configure Build Variants guide for more information on setting up a product flavor for your "advanced" version. You can use the applicationIdSuffix
in your build types or product flavors to set a suffix on your application ID for that particular variant.
Your build.gradle will end up looking something like this:
android {
defaultConfig {
applicationId "com.domain.something"
}
buildTypes {...}
productFlavors {
basic {...}
advanced {
applicationIdSuffix ".advanced"
}
}
}
You can then either programmatically check your product flavor with the generated BuildConfig
class, or put your code for the advanced
version in the advanced
product flavor's source folder (/src/advanced/java
, /src/advanced/res
, etc.).
Valid name for Android Package Name
refer to my working years and some web pages like this
you should replace "-" dashes with "_" underline.
if web site is : dan-carlos.com
package name is : com.dan_carlos
Naming conventions of composed package names
From the documentation on package naming convention:
Package names are written in all lower case to avoid conflict with the names of classes or interfaces
So this would leave you with the following two possibilities:
form_validator
formvalidator
Actually the documentation also makes it clear that underscore plays a special role when it appears in package names:
if the package name begins with a digit or other character that is illegal to use as the beginning of a Java name, or if the package name contains a reserved Java keyword, such as "int" ... the suggested convention is to add an underscore.
So, underscore is suggested only in special cases, into which your naming problem does not seem to fall. So I would recommend formvalidator
as the package name.
What's the convention for java package names without a domain association?
If you are going to be distributing a lot of stuff, I would really suggest getting a domain name. Another alternative however would be to use your e-mail: e.g. bob@gmail.com
would become com.gmail.bob
. This is less common than using domain names but is still done by some and still ensures uniqueness.
Related Topics
How to Hang Up Outgoing Call in Android
How to Display Image from Url on Android
Changing Background Color of Listview Items on Android
Toggle Airplane Mode in Android
Low Picture/Image Quality When Capture from Camera
Classnotfoundexception After Adt Update
Accessing External Storage in Android API 29
Android Material Design Button Styles
Using Zxing to Create an Android Barcode Scanning App
Android App Out of Memory Issues - Tried Everything and Still at a Loss
Communication Between Android Java and Phonegap JavaScript
Android - Package Name Convention
Android Static Object Lifecycle
Android Videoview Orientation Change with Buffered Video
Custom Toast on Android: a Simple Example
How to Use "Share Image Using" Sharing Intent to Share Images in Android