无法切换到Android Studio中的调试版本变体 [英] Unable to switch to debug build variant in Android Studio
问题描述
我已切换为发布构建版本并配置了signingConfigs.现在,当我尝试从下拉菜单中检查调试版本时,它会立即切换回发行版本.因此,我无法再以调试模式运行我的应用.
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?
推荐答案
我遇到了一个类似的问题,其中大多数生成"菜单项均显示为灰色.
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屋!