This question already has answers here:
Android - Package Name convention
(7 answers)
Closed 6 years ago.
I am new to Android development, and i don't know what should be my Android package name. My developer name is: "G.Games" and i don't have an own domain. Can i use this: com.g.games.appname ?
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
You can use any name you want as long as it wont conflict with any other package name in the play store. There are huge number of applications in the store so if you use your own name chances are there may be some application with the same name. By using a domain name you can be sure that there are no other packages of the same name. For more details you can refer this link http://developer.android.com/guide/topics/manifest/manifest-element.html
Look under the package paragraph. Hope this helps you.
Related
I have been following along on this beginner's tutorial (https://developer.android.com/training/basics/firstapp/creating-project) on Android application development to help me create my first Android application.
For the "Configure your project" window, the tutorial suggests using "com.example.myfirstapp" as a package name. Obviously, my real app would not be called "myfirstapp", and it is not restricted to ".com" (can be ".io" or ".org" as well), but this is just an example.
Let's say that I design an app called "Application XY". When I use a version control system, such as Git, I would name the repository "application-xy". I usually make use of the free tier of GitHub Pages, which allows organization sites with the URL structure: "https://application-xy.github.io/".
I was thinking of using the above URL as a package name for my Android application, but I wanted to make sure that Android and Java will not throw any errors if I name my application package "io.github.application-xy" (the special character in question is a dash "-", but this could also apply to asterisks "*", pound signs "#", etc.).
Thank you!
A Java package name is a sequence of simple identifiers separated by dots.
Each simple identifier is made up of Java letters and Java digits (these are not limited to just the letters and digits in US ASCII).
Underscore is allowed in Java 8 though I've heard rumours it's being deprecated.
Hyphen/dash/etc. are not allowed.
Link to Java language spec for package names.
Link to Java language spec for identifiers.
I'm learning programming on a project https://github.com/Netflix/genie/blob/master/genie-core/src/main/java/com/netflix/genie/core/jpa/specifications/JpaJobSpecs.java.
I'm programming in my app to download movies by title, genre, etc. I found an interesting way to construct an advanced command in this Netflix project. However, I have a problem with retrieving the attribute name.
In the Netflix project, the attribute names are used to retrieve the attributes JobEntity_, I do not know where the sign came from _, because there is no class with this sign in the project. By this problem I can not finish the program.
Specifically, what's the proper etiquette/conventions and terms for the different directories in Android Studio app folder?
Within that directory there are three more directories including java, but within Java are four layers of directories labelled com.test.cad.breadcrumbs, where breadcrumbs is the name of the application. Originally, test was set because I was just learning Android Studio, but now that it's actually an app, what should it be refactored to? Is it a package name? Can someone clarify terminology?
For example - why is the first directory called com? Or cad?
Image of File Structure
It's well explained at Oracle documentation:
Naming a Package
Thanks to #CommonsWare in the comments my question was answered.
Essentially, reverse domain name convention is used for the base of the package name. So if I'm "apple.com" then I use "com.apple". It must be likely to be unique at the moment and unlikely to have a collision in the future.
After this base, any java package name is up to you.
In an Android application, I notice that the package name of a class does not have to match the name that was generated when I created the new project. In other areas, Java is insistent that everything matches. I would like to understand why this is not the case for package names, and what the implications are.
Example: I create a new project named TextToSpeech, using my own reverse domain name. This gives a package name of com.lexogram.texttospeech; the path to the MainActivity.java class file is TextToSpeech/app/src/man/java/com.lexogram.texttospeech/.
I now go to a TextToSpeech tutorial and copy-and-paste the code into my project. This code uses com.example.texttospeech as the package name, both in the MainActivity class and in the AndroidManifest.xml. I run the project, and everything works fine.
Does this mean that each activity can use a different package name, so long as the name is used consistently across all files in the activity?
What it means is that your project can have multiple packages inside of it.
Java documentation explains them nicely:
To make types easier to find and use, to avoid naming conflicts, and
to control access, programmers bundle groups of related types into
packages.
I am developing one Android application in three languages named English,Spanish and German.First I completed development in English and wish to complete it in other two languages. Here my question is:
Can I use the same code of Android project(which is in english) in the other two languages with different package names in the same project ?.
Please help me with the sample code/links.
of course you can. Follow these steps
make sure all of your strings through the application are listed as a resource in yourAppFolder/res/values/strings.xml and that you use strings in your app only via getString(R.string.myString1) and NEVER via hard-coded strings in your activities
create a new folder for each language you want to localize your app with the following syntax: for germany, values-de
copy the strings.xml file in the new folder you just created
translate each string in the file into your desired language
Now android OS will use the proper language based on the device's locale.
I bet that you don't fulfill requirement #1 and that will be the most of your work to do. At least that was happened to me in my first real android app ;)