Pregunta

Does an Android package name has to include three parts eg: net.test.package

Or can it also be manualy changed to eg: test.package

¿Fue útil?

Solución

Technically the package name can be anything, but it's highly recommended that you use a reverse domain name format, eg. if your website were http://luc.com you'd use com.luc.appname.

Otros consejos

Yes.It can be Any you can set any time if you want to change.

Its actually as per your requirement.

See this if you want to change :

GO TO Project > src > Package Dir > 
Right Click > Refactor  > Rename 

OR

GO TO Project > src > Package Dir > 
F2 > Set New Package Name.

The package name is used for unique identification for your application. In android uses the package name to determine one application has been installed or not. The general naming is: com.companyname.applicationname eg: com.android.Camera

Its not compulsory that package name include three parts. You can change it according to your requirement.

There is no strict convention per se. But it is always good to follow conventions (IMHO). And Android, in principal, follows Java's package naming conventions. You can get more information at these sites:

  1. http://www.quora.com/Android-OS/Why-do-a-majority-of-Android-package-names-begin-with-com
  2. http://en.wikipedia.org/wiki/Java_package#Package_naming_conventions

Disclaimer: The above is from an answer here on SO: https://stackoverflow.com/a/6273935/450534. All credits to Jimmy Huch for a brilliant answer. Do, up-vote his answer. ;-)

EDIT: And yes, you can rename your package after a project has been created. A few errors might be thrown, but a few simple imports will fix them. That being said, it is always better to decide on something and stick to it. Makes life a tad easier.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top