我在Android Studio中使用classpath 'com.android.tools.build:grad -experimental:0.4.0'和gradle 2.8。
正如谷歌文档中所提到的,要将可穿戴应用程序包含在您的APK中,您需要将Wear应用程序声明为手机应用程序gradle文件中的依赖项,如下所示:
dependencies {
//other dependencies
//wearApp project(':Wear')
wearApp project(path: ':Wear', configuration: 'google')
}
但是我在包含错误消息的磨损应用程序的行上出现错误:
Gradle sync failed: Gradle DSL method not found: 'wearApp()'
这是因为实验性gradle插件无法识别此命令(这是标准gradle)...
问题是,使用gradle-experimental包含Wear应用程序的命令是什么:0.4.0插件???
**更新
将此添加到gradle中:
android.buildTypes {
debug {
debuggable = true
embedMicroApp = true // this should enable the WEAR command, idk...
}
release {
minifyEnabled = false
proguardFiles.add(file('proguard-rules.txt'))
}
}
答案 0 :(得分:1)
我相信,当您在build.gradle中定义productFlavors
时,您需要在dependencies
部分中引用它们,例如:
dependencies {
// other dependencies
googleWearApp project(path: ':wear', configuration: 'google')
}
至少,这是我在类似情况下所做的事情。试一试,看看它是否有效!