发布中的多个 APK

Multiple APKs in Release

上下文

我最近完成了一个同时使用 Android Wear 和移动设备的宠物项目应用程序的发布阶段。我已将它作为 Alpha 版本上传到 Play Developer Console,Wear 部分也获得了批准,但是在查看商品详情时,兼容性概览显示好像只提供了移动 APK。

我尝试按照此处的一些提示使其识别这两个版本:

开发人员文档说我需要在 "APK Files page" 上启用 "Advanced mode",但由于控制台已转换为 Release Manager,我认为这不再是一个选项,而且它一直只接受一个 APK,phone 或 wear,但不能同时接受两者。 在测试期间,自然地,Wear 设备可以 运行 APK 而没有任何问题,无论是在调试还是即时 运行 模式下,甚至从菜单(不需要 ADB 连接)。

问题

参考文件

wear.build

apply plugin: 'com.android.application'

android {
    lintOptions {
        disable 'MissingTranslation'
    }

    compileSdkVersion 25

    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "tech.provingground.divemonitor"
        minSdkVersion 23
        targetSdkVersion 25
        versionCode 6
        versionName "1.0.0-remote"
    }

    signingConfigs {
        release {
            storeFile file("[path/to/file]")
            storePassword "[redacted]"
            keyAlias "mobile keystore"
            keyPassword "[redacted]"
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
        }
    }
}

dependencies {
    provided 'com.google.android.wearable:wearable:2.0.0'
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.google.android.support:wearable:2.0.0'
    compile 'com.google.android.gms:play-services-wearable:10.2.1'
    // https://mvnrepository.com/artifact/commons-io/commons-io
    compile 'commons-io:commons-io:2.5'
    compile project(':commons')
}

mobile.build

apply plugin: 'com.android.application'

android {
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }

    lintOptions {
        disable 'MissingTranslation'
    }

    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "tech.provingground.divemonitor"
        minSdkVersion 24
        targetSdkVersion 25
        versionCode 6
        versionName "1.0.0-local"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    signingConfigs {
        release {
            storeFile file("[path/to/file]")
            storePassword "[redacted]"
            keyAlias "mobile keystore"
            keyPassword "[redacted]"
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    wearApp project(':wear')
    // https://mvnrepository.com/artifact/commons-io/commons-io
    compile project(':commons')
    compile 'com.google.android.gms:play-services-wearable:10.2.1'
    compile 'com.google.android.gms:play-services-location:10.2.1'
    compile 'commons-io:commons-io:2.5'
    compile 'com.android.support.constraint:constraint-layout:1.0.1'
    compile 'com.android.support:support-v4:25.3.1'
    compile 'com.android.support:recyclerview-v7:25.3.1'
    // https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind
    compile 'com.fasterxml.jackson.core:jackson-databind:2.9.0.pr2'
    // https://mvnrepository.com/artifact/com.fasterxml.jackson.dataformat/jackson-dataformat-csv
    compile 'com.fasterxml.jackson.dataformat:jackson-dataformat-csv:2.9.0.pr2'
    testCompile 'junit:junit:4.12'
}

确保两个 APK 的 versionCode 属性不同。只有这样他们才会共存。