在Android Studio中,建立一个Android Wear项目,我怎么能包括两个模块中的同一个文件 [英] In Android Studio, building an Android Wear project, how can I include the same file in both modules
问题描述
我成功地建立一个Android Wear表盘和连接的应用程序在移动设备上。问题是,我有在这两个移动
和穿
模块引用一些资源类文件。骨架应用程序,我建立了这个从还创建了一个(非建筑) DigitalWatch
模块和我猜我可以在那里移动这些共同文件,然后从我的摇篮引用它们构建文件。我查看了一些#2的想法,但言论表明他们不工作。
I am successfully building an Android Wear watch face and connected app on the mobile device. The problem is that I have several resource and class files that are referenced in both the mobile
and wear
modules. The skeleton app I built this from also created a (non-building) DigitalWatch
module and I'm guessing I could move these common files in there and then reference them from my Gradle build files. I've reviewed some of the ideas on Stackoverflow, but the comments suggest they don't work.
下面是我的项目结构。常见的文件包括RES / strings.xml中,一个工具类,以及谷歌的JSON文件。
Here's my project structure. Common files include res/strings.xml, a utility class, and the google json files.
推荐答案
我已经成功地移动两个常见的Java实用工具类和串/可绘制成所谓的共同一个单独的模块,并引用它同时在移动和磨损gradle这个文件如下:
I've successfully moved both common java utility classes and strings/drawables into a seperate module called "Common" and reference it in both the mobile and wear gradle files as follows
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':common')
...
}
您将不得不增加进口来引用的通用模块和资源工作中的Java类,如果您添加的xmlns:程序=http://schemas.android.com/apk/res-auto
,以便在布局上的元素。
You will have to add imports to reference your java classes in the common module and resources work if you add xmlns:app="http://schemas.android.com/apk/res-auto"
to the top element in your layouts.
的谷歌services.json
我一直无法移动。这是因为谷歌图书馆内的相对固定的参考了这一点。
The google-services.json
I have not been able to move as there is a fixed relative reference to this within the Google libraries.
这篇关于在Android Studio中,建立一个Android Wear项目,我怎么能包括两个模块中的同一个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!