android - 发布中的多个 APK

标签 android android-studio google-play apk wear-os

上下文

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

我试图通过遵循此处的一些提示使其识别这两个版本:

  • 确保 <uses-permission>两者的元素相同
  • 配置 Gradle 以使用相同的 key 进行签名(即使我使用了 Android Studio 的“生成签名的 APK”选项)
  • 通过注释掉 wearApp 来拆分 APK Gradlefile 中的声明

开发人员文档说我需要在“APK 文件页面”上启用“高级模式”,但由于控制台已转换为发布管理器,我认为这不再是一个选项,它一直只接受一个 APK,要么是手机要么是 wear,但不能两者兼而有之。 在测试过程中,Wear 设备自然可以在调试和即时运行模式下毫无问题地运行 APK,甚至可以从菜单中运行(无需 ADB 连接)。

问题

  • 为什么当“组合”APK 时 Play 商店只显示手机兼容(Android Studio 默认情况下将 Wear APK 嵌入到移动 APK 中,这应该不会导致问题Android Wear 2.0)已上传
  • 如何将两个 APK 附加到一个版本(alpha 版或非 alpha 版),以便它们都显示在列表中?
  • 如果需要,我需要如何打包来自 Studio 的 APK 以实现相同的目的?

引用文件

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 属性不同。只有这样他们才会共存。

关于android - 发布中的多个 APK,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43292096/

相关文章:

android - 为什么我的应用程序不受任何设备支持?

java - 从 SQLite 数据库中检索特定列

android - 添加flutter_contact插件后,Flutter App Gradle构建失败

java - Android BluetoothSocket - 超时

java - 为什么在 onCreate() 中编写代码会使我的 Android 程序崩溃,但在 onCreateOptionsMenu() 中编写相同的代码却可以工作?

Android_Install 版本降级失败

google-play - 为什么我的应用评论没有显示在 google play 上,而是显示在我的 play 控制台中?

对于某些平板电脑,Android 应用程序不会出现在商店中

android - 当焦点从 EditText 更改为 Button 时 ActionBarSherlock 操作栏消失

android - 使用 Radius Networks Android Beacon 库检测 iBeacons UUID