0

I am developing a library has too many objects on android. So I must group the classes with package. I want to access A class from C but I want to prevent this objects accessible from Project X. So I can't use private-package (default) and "public" identifiers.

--PROJECT X (The project that uses the library.)
    --library src
         ---packagex
             ----Class A
             ----Class B
         ---packagey
             ----Class C

Is it possible ? Is there anyway to group classes without package? Thanks.

oyenigun
  • 587
  • 6
  • 15
  • Move class C to packagex and use default or you have to create packagexy which contains Class A, Packagex and Packagey – Akshay Bhat 'AB' Nov 04 '16 at 12:34
  • There are too many objects on project. It is very difficult to work without grouping. Thanks for answer – oyenigun Nov 04 '16 at 12:40
  • _There are too many objects on project._ What exactly do you mean by this? – pathfinderelite Nov 04 '16 at 13:02
  • I'm having a little trouble understanding your question. Packages are the best way to organize your classes. You can access A from C without exposing A to anything else. You do this by importing the class from the package and then controlling access of usage(use private, final). Just import com.someuser.packageX.classA at the start of Class C. Are you anticipating some potential override or conflict? are you planning to use class C in a way that could cause the same? If not, my guess is you will never run into a problem. – Corey Nov 04 '16 at 13:05
  • I can' t access A from C without make public to A. if I make public to A, A is accessible from outside the library. – oyenigun Nov 04 '16 at 13:37
  • @pathfinderelite, There are too many classes in the project. That's why I can not work without grouping. – oyenigun Nov 04 '16 at 13:46
  • When you need Class A as common, creating a parent package does make sence and also it is well grouped. Create packageXY which contains Class A, PackageX and PackageY so that class A is accessible to both packages. – Akshay Bhat 'AB' Nov 07 '16 at 05:05
  • I found solution with proguard. Now, C class accessible from A, but not accessible from X Project. – oyenigun Dec 15 '16 at 08:14

0 Answers0