build:gradle-experimental:0.4.0 include Wearable app

171 Views Asked by At

I have a working app in Android Studio using classpath 'com.android.tools.build:gradle-experimental:0.4.0' and gradle 2.8.

As mentioned in google docs, to include your wearable app with your APK, you need to declare the wear app into the phone app gradle file as dependency something like this:

dependencies {   
//other dependencies

//wearApp project(':Wear')
wearApp project(path: ':Wear', configuration: 'google')
}

But I get an error on the line where I include my wear app with the error message:

Gradle sync failed: Gradle DSL method not found: 'wearApp()'

This is because the experimental gradle plugin is not recognizing this command ( this is for standard gradle)...

The question is, What is the command for including Wear app with gradle-experimental:0.4.0 plugin ???

** update

Added this to gradle also:

android.buildTypes {
    debug {
        debuggable = true
        embedMicroApp = true  // this should enable the WEAR command, idk...
    }
    release {
        minifyEnabled = false
        proguardFiles.add(file('proguard-rules.txt'))
    }
}
1

There are 1 best solutions below

1
On

I believe that when you have productFlavors defined in your build.gradle, you need to reference them in your dependencies section, like such:

dependencies {
    // other dependencies
    googleWearApp project(path: ':wear', configuration: 'google')
}

At least, this is what I'm doing in a similar situation. Give it a try and see if it works!