在Android移动版和Wear模块之间共享文件 [英] Sharing files between Android mobile and wear modules
问题描述
几个月前,我最初只是通过移动模块开始了我的项目,现在我也对配置可穿戴设备的应用感兴趣.就是说,我所有的文件(Java,XML,可绘制对象等)都在移动模块中,所以我需要将所有要在移动和磨损模块之间共享的文件传输到新创建的通用"文件中模块?
Several months ago, I originally started my project with just a mobile module, and now I am interested in configuring my app for wearable devices as well. That said, all of my files (Java, XML, drawables, and etc.) are in the mobile module, so do I need to transfer all of the files I want to share between mobile and wear modules into a newly created "common" module?
编辑:
有人可以向我解释以下来自移动设备和Wear的Gradle文件的Gradle项目同步错误是什么意思:
Can somebody explain to me what the following Gradle project sync errors coming from the mobile and wear's Gradle files mean:
...这是在我在两个模块中都包括了 compile project(':common') 之后发生的:
... This happened after I included compile project(':common') in both modules as follows:
首先,这是我的通用模块:
First, here's my common module:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "dpark.gameoflife"
minSdkVersion 9
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
}
移动模块:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "dpark.gameoflife"
minSdkVersion 9
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
wearApp project(':wear')
compile project(':common')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.google.android.gms:play-services:8.4.0'
}
最后,我的磨损模块:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "dpark.gameoflife"
minSdkVersion 20
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.support:wearable:1.3.0'
compile 'com.google.android.gms:play-services-wearable:8.4.0'
compile project(':common')
}
...如果有的话,我在发布模式下对我的通用模块的APK进行了签名,但是却遇到了与上述相同的错误.
... If anything, I signed an APK of my common module in release mode, and yet I get the same errors as shown above.
推荐答案
正确,如果两个模块(移动和磨损)都使用了您的文件,那么显然,您应该使这两个模块使用共享模块,将所有必要的文件.
Correct, If your files are used by both modules (mobile and wear) then obviously, you should make these two modules use a shared module where you put all the necessary files.
在每个模块中添加compile project(': common')
这篇关于在Android移动版和Wear模块之间共享文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!