简体   繁体   English

如何在子项目中使用根项目?

[英]how to use root project in sub-project?

The followings are my situation. 以下是我的情况。

在此处输入图片说明

and build.gradle of app (root project) 和build.gradle的应用程序(根项目)

dependencies {
   compile project(':magicfilter')
   compile project(':zgallery')
   compile project(':dialogs')
}

I want to class of app (root project) in magicfilter, zgallery, dialogs (sub-projects). 我想在magicfilter,zgallery,对话框(子项目)中对应用程序(根项目)进行分类。

But I can't refer classes of app in sub-projects.. 但是我不能在子项目中引用应用程序的类。

How do I call the class of the root project in a sub project? 如何在子项目中调用根项目的类?

I think you can not. 我想你不能。 Even if it is possible that is not supposed to be done. 即使有可能不应该这样做。 If you need to call something of the main module on the other modules maybe the architecture of the project it is not well defined and maybe it is better to structure it on other way. 如果您需要在其他模块上调用主模块中的某些模块,则可能是项目的体系结构定义不明确,也许最好以其他方式进行结构化。

我认为这不是一个好的设计模式,也不是您的模型的有效分配,为什么您需要在子项目中访问您的应用程序项目?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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