0
votes

I'm at a loss. Using AS 1.5.1 and Gradle 2.8, I have mobile and wear modules. When I choose the debug versions of the mobile and wear flavors I understand that I have to manually compile/run each to get on their respective devices. And this occurs with no problem: debug/run the apps/etc.

However, for the release of mobile and wear flavors, when I haven't created a signingConfigs section in my mobile/wear build.gradle files, AS prompts me to do so w/ a dialog box and at the bottom of it has the "FIX" button. I do this first w/ my wear module adding in the keyAlias,keyPassword,storeFile, and storePassword. Through this same dialog I then choose the one and only buildType of release to have the signingConfig. When I click Ok on that dialog, the previous dialog has wording at the bottom where the FIX button used to be that there is still gradle errors. I do those same steps w/ the mobile gradle file and it too states in the dialog that there are still gradle errors. The result build/run for the wear in Release does not create android_wear_micro_apk.apk to get it included in the mobile build. When the mobile module gets built, it doesn't have any wear apk in it. My whole application (mobile/wear) was originally an Eclipse set of projects (worked and actually in the Play store) that I've hand-merged into AS.

I tried creating a brand new AS project w/ mobile and wear. WHen I went to run the release, it too prompted me to create the signing concept. However with that, the android_wear_micro_apk.apk gets created during wear compilation. Additionally the mobile app contains the wear's apk. Both the mobile debug and release APKs are different sizes with the release one being larger. The only way I know about the "android_wear_micro_apk.apk" file is because of this new/stripped down test project -- otherwise, my original gives no glue.

Here is the mobile build.gradle

apply plugin: 'com.android.application'

repositories {
    mavenCentral()
}

android {
    signingConfigs {
        the_pro_mobile_config {
            keyAlias 'MY_ALIAS_PRO'
            keyPassword 'MY_PASSWORD_PRO'
            storeFile file('my_keystore_pro.keystore')
            storePassword 'MY_STORE_PASSWORD_PRO'
        }
        the_free_mobile_config {
            keyAlias 'MY_ALIAS_FREE'
            keyPassword 'MY_PASSWORD_FREE'
            storeFile file('my_keystore_free.keystore')
            storePassword 'MY_STORE_PASSWORD_FREE'
        }
    }
    compileSdkVersion 23
    buildToolsVersion "23.0.2"
    packagingOptions {
        exclude 'META-INF'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES/httpcore-4.0.jar'
        exclude 'META-INF/DEPENDENCIES/httpclient-4.3.6.jar'
    }
    defaultConfig {
        minSdkVersion 19
        targetSdkVersion 23
        versionCode 25
        versionName "2.0.0"

        multiDexEnabled = true
    }
    buildTypes {

        release {

            debuggable false
            jniDebuggable false
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-project.txt'), 'proguard-rules.pro'
            zipAlignEnabled true

        }

    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
    productFlavors {
        free {
            applicationId "com.my_app.thefree"
            signingConfig signingConfigs.the_free_mobile_config
        }
        pro {
            applicationId "com.my_app.thepro"
            signingConfig signingConfigs.the_pro_mobile_config
        }
    }
}

dependencies {

    wearApp project(':wear')

    compile project(':my_license_module')
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:design:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:support-v4:23.1.1'
    compile 'com.android.support:support-annotations:23.1.1'
    compile 'com.android.support:recyclerview-v7:23.1.1'
    compile 'com.android.support:cardview-v7:23.1.1'
    compile 'com.android.support:palette-v7:23.1.1'
    compile 'com.google.android.gms:play-services:8.4.0'
    compile 'com.google.android.gms:play-services-wearable:8.4.0'
    compile 'com.jakewharton:butterknife:7.0.1'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'commons-io:commons-io:2.4'
    compile 'com.google.android.gms:play-services-ads:8.4.0'
    compile 'com.google.android.gms:play-services-identity:8.4.0'
    compile 'com.google.android.gms:play-services-gcm:8.4.0'
}

Here is the wear build.gradle

apply plugin: 'com.android.application'

repositories {
    mavenCentral()
}

android {

    signingConfigs {
        the_wearable_config {
            keyAlias 'MY_ALIAS'
            keyPassword 'MY_KEYPASSWORD'
            storeFile file('my_keystore_wearable.keystore')
            storePassword 'MY_STORE_PASSWORD'
        }
    }
    compileSdkVersion 23
    buildToolsVersion "23.0.2"
    defaultConfig {
        minSdkVersion 19
        targetSdkVersion 23
        versionCode 25
        versionName "2.0.0"

        multiDexEnabled = true
    }
    buildTypes {
        release {
            debuggable false
            jniDebuggable false
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-project.txt'), 'proguard-rules.pro'
            zipAlignEnabled true
            signingConfig signingConfigs.the_wearable_config
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
    productFlavors {
        free {
            applicationId "com.myapp.my_free_app"
        }
        pro {
            applicationId "com.myapp.my_pro_app"
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.google.android.support:wearable:1.3.0'
    compile 'com.google.android.gms:play-services:8.3.0'
}
1
Are you using two different keys to sign your wear and your mobile apps? I see the keystore for those two are different in your build files ...Ali Naddaf
just added the two signingConfigs from mobile into the wear's gradle and same issue.user3123813
Please update your original post with your latest change.Ali Naddaf
see my own answer below.user3123813

1 Answers

0
votes

I fixed the issue. There are other posts about this same problem and that is where I found them.

First add in wear gradle file, add

publishNonDefault true

in the "android {" section of file.

The of the changes are for the mobile gradle file.

Second, remove "wearApp project(':wear')" and replace with both of these

freeWearApp project(path:':wear', configuration: 'freeRelease')

proWearApp project(path:':wear', configuration: 'proRelease')

I'm getting the android_wear_micro_apk created and added to mobile apk.

My next task is to figure out why it isn't automatically installing to watch. Again all this worked when doing Eclipse/etc.