Will I meet trouble if I rename a package with uppercase letter? - android

I hope to rename a package name under the folder \src , I see the following warning.
By convention, the package names usually start with a lowercase letter
Will I meet trouble if I rename a package with uppercase letter?

Just because it's an acronym doesn't mean you should capitalize it in your package name. Class naming convention recommends making only the first letter in acronym-ish name portions upper-case, although for historical reasons there are classes that don't follow that convention.
The bottom line is that as long as it's a legal name, you're fine from the Java side of things.
Mixed-case directories sometimes cause issues across OSes, particularly combined with version control. For practical reasons alone it might be worth following convention.

Related

IOS and Android package name

I created demo project in Flutter, and the package name:
iOS : com.example.flutterAppTest
Android : com.example.flutter_app_test
Why they are different? Should they need to be different?
What is the practice for package names for cross platform?
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).

Is the use of package name only limited to directory structure and in app references?

The naming convention is usually company.domain.inreverse.appname
Is there a significance of using the actual company domain
Asking because I by mistake named the package com.companyName.app.appName instead of in.co.companyName.app.appName (where the company's actual internet domain is companyName.co.in)
So would it in any way affect my app, and/or its relation to the website?
No.. it won't. The idea is to give Global uniqueness.
check this page: https://en.wikipedia.org/wiki/Java_package#Package_naming_conventions
The Java Language Specification establishes package naming conventions to avoid the possibility of two published packages having the same name.
But keep in mind this: http://docs.oracle.com/javase/tutorial/java/package/namingpkgs.html
Package names are written in all lower case to avoid conflict with the names of classes or interfaces.

Can Android package names contain only letters and periods?

I'm trying to scrape data from www.apkmirror.com which includes the package name of apps. For example, below
the package name is "com.lenovo.anyshare.gps". I'm considering whether to use the pyparsing expression
Word(alphas + ".")
for the package name, meaning [a-zA-z.] as a regular expression. Is this OK, or would it be too restrictive in some cases? (I wasn't able to find much about restrictions on the package name on https://developer.android.com/studio/build/application-id.html).
Following CommonsWare's comment, I'm assuming for the moment that any character is allowed except a whitespace. (I've updated the regular expression to \S+, since there should be at least one character).

Package names in Android studio when dev name starts with a number?

I want to create apps under my company's name and Android Studio recommends using your domain, eg:
domain: example.com
App: myApp
gives a package name of com.example.myApp
That's all fine, but my company name begins with a number and Android Studio informs me I can't have numbers, eg:
com.1example.myApp
Now I could try "oneexample" and hopefully no-one from oneexample.com starts developing Android apps, but given how many devs appear to have a number at the start of their name, presumably this has come up before. So if I can please ask:
1) How should I tackle naming my packages?
2) Out of curiosity, why can't you have package names beginning with a number?
Thanks heaps!
Quentin.
1) How should I tackle naming my packages?
Short Answer: Android package/subpackage names must begin with an ASCII Latin letter. Since there seems to be no guidance from Google on package naming in cases where domain names begin with a number, developers are left to resolve this themselves.
Here are some real-world examples of domain names starting with a number, and the package names the developers decided to use for Android:
http://www.11bitstudios.com/
https://play.google.com/store/apps/details?id=com.elevenbitstudios.AnomalyWarzoneEarthHD
http://www.23snaps.com/
https://play.google.com/store/apps/details?id=com.snaps23.android
http://www.36you.com/
https://play.google.com/store/apps/details?id=com.thirtysixyougames.google.slotanddragons
Further Background
Java allows package names to begin with an ASCII Latin letter or an underscore character. From Naming a Package (The Java™ Tutorials > Learning the Java Language > Packages):
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.
The following examples of "Legalizing Package Names" are also shown:
Domain Name Package Name Prefix
--------------------------- ---------------------------
hyphenated-name.example.org org.example.hyphenated_name
example.int int_.example
123name.example.com com.example._123name
However, Android is more restrictive than Java, and package/subpackage names may NOT begin with an underscore. From Issue 65570 - Android Open Source Project - Issue Tracker - Google Project Hosting:
While Java allows package names that start with underscores, Android application packages (which have additional restrictions) do not. When you try to install an app whose package starts with _, the device PackageManager will reject it. For that reason we tightened the package name validation in Studio when you create the app such that you don't end up creating these packages up front and then suffering later.
Unfortunately, there doesn't seem to be any suggested convention from Google on legalizing package names for domains that begin with a number for Android.
2) Out of curiosity, why can't you have package names beginning with a number?
From Chapter 3. Lexical Structure (The Java® Language Specification - Java SE 7 Edition):
An identifier is an unlimited-length sequence of Java letters and Java digits, the first of which must be a Java letter.
<snip>
The "Java letters" include uppercase and lowercase ASCII Latin letters A-Z (\u0041-\u005a), and a-z (\u0061-\u007a), and, for historical reasons, the ASCII underscore (_, or \u005f) and dollar sign ($, or \u0024). The $ character should be used only in mechanically generated source code or, rarely, to access pre-existing names on legacy systems.
Again, this is further restricted in Android package names. From <manifest> | Android Developers:
package
A full Java-language-style package name for the application. The name should be unique. The name may contain uppercase or lowercase letters ('A' through 'Z'), numbers, and underscores ('_'). However, individual package name parts may only start with letters.
Thanks, #Quentin, for providing info on Android's additional restrictions over Java.

Application Bundle Name in Segment

i have a problem in android application package installation,
why android must have two segment of package name,
why i can't use single Name as Package name.
Now:"com.alert.myalert"
Need:"myalert", in my application i required when my app is installed in device, it shows only my app name, when the user have to check in Settings->App->myalert. This is my problem, i can't get that now showing Settings->App->com.alert.myalert. kindly help me, Thanks in Advance.
You have an explanation about this here, it's just a convention to keep the names of your packages like the reverse of your domain.
From SUN Convention:
The prefix of a unique package name is always written in all-lowercase
ASCII letters and should be one of the top-level domain names,
currently com, edu, gov, mil, net, org, or one of the English
two-letter codes identifying countries as specified in ISO Standard
3166, 1981.
Subsequent components of the package name vary according to an
organization's own internal naming conventions. Such conventions might
specify that certain directory name components be division,
department, project, machine, or login names.

Categories

Resources