views:

123

answers:

4

I'm developing an Android project which currently has 4 packages:

com.myapp.app.activities
com.myapp.app.db
com.myapp.app.ws
com.myapp.app.utils

Would I be able to create an additional package which is just

com.myapp.app

?

Eclipse isn't letting me create this package. It tells me a package with this name already exists.

If I start a new project and create a package called "com.testing.app" and then create a new package called "com.testing.app.activities" afterward, it works fine.

For Android developers:

What I'm wanting to do is extend the Application class and have it in a separate package. Suppose com.myapp.app can't be used, what's a good name for this new package?

+2  A: 

The package com.myapp.app already exists. You can create a class named com.myapp.app.MyClass, you'll see it right in the app package.

Another thing you can do is changing the layout of your packages from a flat layout to a hierarchical layout :

Example


Resources :

Colin Hebert
What version of eclipse are you using that this isn't default?
Falmarri
@Falmarri I don't use eclipse (personal convictions :P) but you don't have to always install your own eclipse, sometimes you just get a preconfigured one and these settings can be modified on the "custom" version.
Colin Hebert
+9  A: 

Eclipse won't let you create this package because it already exists.

Packages in Java are represented in the filesystem as hierarchical folders: com.myapp.app.activities is in the com/myapp/app/activities folder. com/myapp/app already exists, so you can't create this package.

In Eclipse, juste create a new class, and in the "Package" section, precise you want to create it in the com.myapp.app package. This should work.

Vivien Barousse
A: 

It would appear that if I manually place a file into the directory and refresh the package explorer in Eclipse, the new com.myapp.app package appears

Andrew
+2  A: 

Eclipse by default hides empty packages. In the package explorer view, click at the small arrow in the right top: View Menu. Choose Customize View. In the Filters tab you need to uncheck Empty packages. Now empty packages will be visible in the package explorer.

alt text

BalusC