简体   繁体   English

“发布”风味文件在“ Android”树窗格中不可见

[英]'release' flavor files not visible in 'Android' tree pane

I want some classes to have two flavors - 'release' and 'debug'. 我希望某些类具有两种风格-“发布”和“调试”。

Have created two corresponding directories under project app/src/ , so as a result I have 3 directories - main (for common to both flavors sources), release and debug . 在项目app/src/下创建了两个相应的目录,因此,我有3个目录main (两个风味源都通用), releasedebug

In buildType section inside build.gradle there is release variant. buildType段内build.gradlerelease的变体。

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.3"
    defaultConfig {
        applicationId "com.example.test.bottomnav"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

I expect to see in files tree pane all the source sets. 我希望在文件树窗格中看到所有源集。 But now release is missed. 但是现在错过了release

在此处输入图片说明

How can I make release sources visible, like debug , test and androidTest ? 如何使release源可见,如debugtestandroidTest

It's because only the directories linked to your current build type and flavor are displayed. 这是因为仅显示链接到当前构建类型和风格的目录。 If you select "release" as build variant for your app in the Build Variants tab, the "release" directory will appear and the "debug" one will disappear. 如果在“构建变体”选项卡中选择“发布”作为应用的构建变体,则将显示“发布”目录,而“调试”目录将消失。

在此处输入图片说明

Bear in mind that Build types and Flavors are two different things. 请记住,构建类型和风味是两件事。 According to what you've posted, you only have defined build types in your gradle file. 根据您发布的内容,您仅在gradle文件中定义了构建类型。 See more info in the doc: https://developer.android.com/studio/build/build-variants.html 在文档中查看更多信息: https : //developer.android.com/studio/build/build-variants.html

You can manually create release folder and put classes specific to this flavor inside it. 您可以手动创建release文件夹,并将特定于此口味的类放入其中。 Then choose proper BuildVariant to build desired flavor/buildType 然后选择适当的BuildVariant来构建所需的flavor / buildType

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM