简体   繁体   中英

Use classes from a library's library?

Let's say I have a LibImplementationA that includes a LibInterfaces .
LibImplementationA contains the implementations of LibInterfaces 's java interfaces .
My application uses the interfaces from LibInterfaces and the implementations from LibImplementationA .
I included LibImplementationA in my app, and I thought I could use the interfaces from LibInterfaces in my app's code. But I couldn't !
Why ?

To make my app work, I must include LibImplementationA and LibInterfaces .
So LibInterfaces is duplicated (in LibImplementationA and my app), and this seems really bad (in case of the update of LibInterfaces )

Last but not least, in my app I want to be able to switch from using LibImplementationA to LibImplementationB or LibImplementationX (that's why the app uses LibInterfaces ).

My real problem is way more complex, but I need a clever idea to avoid duplications of this LibInterfaces , if possible! I'm using Android Studio, with gradle.
Edit: for a better understanding, LibInterfaces contains communication interfaces (as simple as sendMessage() , messageReceived() methods) and LibImplementationX implements those methods using SIP, XMPP, WebSocket, Whatever.

“为什么”的答案LibInterfaces可以被保护/默认作用域接口,并且不能在该特定程序包之外实现。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM