Library Packaging

Asked 2 years ago, Updated 2 years ago, 67 views

This is the first time I have made my own library for Android apps, and I am struggling with packaging including visibility.
I don't know the standard of that area when I search the internet.

I cut the package as follows (somewhat omitted for explanation), but
I'd like to somehow make sure I can't see anything other than Util.java.
(I don't want to show library users anything other than `Util.java')

I know it's better to remove the packaging and make it flat. I was wondering if there was a way to adjust visibility while separating packages in an easy-to-understand way.

  • model, usecase, repository Each class in the package is public Browse from
  • Util to the usecase, model package, and from the usecase package to the repository, model package.

com.hogehoge
|-->model
|-->usecase
|-->repository
|- Util.java

android java

2022-09-30 21:27

1 Answers

If you want to emphasize that this is not an API that should be used and you don't want to know the contents easily, I think it is common to obfuscate it by using a program.
For example, in the above example, if you multiply the program,

com.hogehoge
|-->a
|-->b
|-->c
|- Util.java

You can convert it to a meaningless string, such as
(such as the class name in each package is a or b).
Therefore, it is difficult to judge by the class name and method name, and I think it will be basically accessible by not publishing documents.

If you don't want to be able to call at all, you will automatically insert a program to rewrite to the same package or package private class when you build it...
Still, if you use the worst reflection, you can access it.

Kotlin has the concept of a module, and I think it was possible to access it in a separate package and not from outside the module if it was in the module.


2022-09-30 21:27

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.