【问题标题】:Where is the apk for my new build variant?我的新构建变体的 apk 在哪里?
【发布时间】:2016-01-24 00:27:47
【问题描述】:

我阅读了 android 文档的“构建系统”部分:http://developer.android.com/sdk/installing/studio-build.html

因此,构建变体由 product_flavor-build_type 组成。我有这个 build.gradle:

buildTypes {
    debug {
        applicationIdSuffix '.debug'
        debuggable true
        minifyEnabled !skipProguard
        shrinkResources true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        signingConfig signingConfigs.debug
        zipAlignEnabled false
    }
    debugtest {
        // unit tests
        applicationIdSuffix '.test'
        debuggable true
        minifyEnabled false
        shrinkResources true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        signingConfig signingConfigs.debug
        zipAlignEnabled false
    }
    release {
        minifyEnabled true
        shrinkResources true
        debuggable false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        signingConfig signingConfigs.release
    }
}

productFlavors {
    internal {
        applicationId "${project.applicationId}.internal"
        buildConfigField 'boolean', 'EXPERIMENTAL', 'true'
        buildConfigField 'boolean', 'FAKE_HTTP_RESPONSE', 'false'
    }
    production {
        applicationId project.applicationId
        buildConfigField 'boolean', 'EXPERIMENTAL', 'false'
        buildConfigField 'boolean', 'FAKE_HTTP_RESPONSE', 'false'
    }
    automation {
        applicationId "${project.applicationId}.automation"
        buildConfigField 'boolean', 'EXPERIMENTAL', 'true'
        buildConfigField 'boolean', 'FAKE_HTTP_RESPONSE', 'true'
    }
}

我想创建 mobile-debug-automation-unaligned.apk 以便可以在 dagger 模块中使用“FAKE_HTTP_RESPONSE”BuildConfig 变量。

但是,当我在 Android Studio 中单击“构建变体”时,我会看到一个构建变体 -“internalDebug”。我预计会看到 9 个构建变体(buildType * productFlavor)。

查看我的项目目录,我看到以下 apk:

MY_APP/mobile:mobile-release.apk、mobile-debug-unaligned.apk

MY_APP/mobile/build/outputs/apk:mobile-internal-debug-unaligned.apk

如何生成新的“自动化”apk?

【问题讨论】:

  • 您应该能够在 Build Variants 窗口中看到所有 9 个 Build 变体。您可以选择一个,然后从菜单中构建或运行应用程序,它将生成它的 apk。如果您没有看到所有 Build 变体,那么您必须检查您的 productFlavors 文件夹的名称是否正确。
  • 尝试重建你的项目。

标签: android android-studio gradle


【解决方案1】:

请点击更改:

如果不起作用,请重建您的项目。

【讨论】:

    猜你喜欢
    • 2013-07-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-05
    • 1970-01-01
    • 2014-03-10
    相关资源
    最近更新 更多