无法在 Android Studio 中切换到调试构建变体 [英] Unable to switch to debug build variant in Android Studio

查看:45
本文介绍了无法在 Android Studio 中切换到调试构建变体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经切换到发布构建变体并配置了签名配置.现在,当我尝试从下拉菜单中检查调试构建变体时,它会立即切换回发布构建变体.所以我无法再在调试模式下运行我的应用.

I've switched to release build variant and configured signingConfigs. Now when I try to check the debug build variant from the drop down menu it switches immediately back to the release build variant. So I'm not able to run my app in debug mode any more.

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'realm-android'

android {
    signingConfigs {
        config {
            ...
        }
    }

    compileSdkVersion rootProject.compileSdkVersion
    buildToolsVersion rootProject.buildToolsVersion

    defaultConfig {
        applicationId "com.kost.foo"
        minSdkVersion rootProject.minSdkVersion
        targetSdkVersion rootProject.targetSdkVersion
        versionCode 2
        versionName "1.1"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        ndk {
            abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
        }
        externalNativeBuild {
            cmake {
               ...
            }
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            debuggable true
            signingConfig signingConfigs.config
        }
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
        main {
            jniLibs.srcDirs = ['src/main/jni']
        }
    }

    externalNativeBuild {
        cmake {
            path 'src/main/jni/CMakeLists.txt'
        }
    }
}

kapt {
    generateStubs = true
}

repositories {
    maven { url 'https://github.com/linchaolong/stetho-realm/raw/master/maven-repo' }
    mavenCentral()

}

我试图恢复 build.gradle 中的所有更改,就像配置之前一样,但没有运气.

I've tried to revert all changes in build.gradle as it was before configuring, but with no luck.

有什么想法可以解决这个问题吗?

Any ideas how to fix the issue?

推荐答案

我遇到了类似的问题,其中大部分 Build 菜单项都变灰了.

I had a similar problem where most of the Build menu items were greyed out.

将项目与 Gradle 文件同步"未修复.

'Sync project with Gradle files' didn't fix.

我注意到 Android Studio (v 3.1.2) 左下角有一个Build Variants"切换按钮,最终能够选择我需要的变体.

I noticed a 'Build Variants' toggle button on the bottom left of Android Studio (v 3.1.2) and with this was finally able to choose the variant I needed.

也许这对你也有用.

这篇关于无法在 Android Studio 中切换到调试构建变体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆