Android Studio 0.8.6更改默认构建变体

时间:2014-08-30 18:15:30

标签: android gradle android-studio

我最近将Android Studio从0.6更新到0.8.6,似乎能够指定默认"运行"配置已被删除(或移动到我需要帮助查找的位置)。我可以在调试或发布模式下生成已签名的APK(生成向导已更改为允许我在此时选择构建变体)但似乎无法找到如何选择构建变体一般用途。换句话说,当我点击"运行"当我需要运行assembleRelease时,gradle会执行assembleDebug。知道怎么改变这个吗?

编辑:当我选择"调试"而不是"运行" gradle仍然选择运行assembleRelease,所以我收到此错误

Cannot debug application com.caseybrooks.scripturememory on device lge-vs985_4g-VS9854Gc824b3f1.
This application does not have the debuggable attribute enabled in its manifest.
If you have manually set it in the manifest, then remove it and let the IDE automatically assign it.
If you are using Gradle, make sure that your current variant is debuggable.

但是,如果我将debuggable="true"属性添加到清单中,则构建将失败。我的build.gradle是否正确?

apply plugin: 'android'

android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
defaultConfig {
    minSdkVersion 8
    targetSdkVersion 19
}
signingConfigs {
    release {
        storeFile file('C:/Users/Casey/Documents/android/scripturememory/scripturememory_keystore')
        keyAlias 'scripturememory_keystore'
        storePassword '***********'
        keyPassword '**********'
    }
}
buildTypes {
    release {
        runProguard false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        signingConfig signingConfigs.release
    }
}
productFlavors {
}
sourceSets {
    main {
        java.srcDirs = ['src/main/java']
    }
}
}

dependencies {
compile project(':library')
compile project(':AndroidBibleTools')
compile 'com.android.support:appcompat-v7:19.+'
}

2 个答案:

答案 0 :(得分:15)

“查看”菜单>工具窗口> Build Variants视图允许您选择默认为项目中的模块构建的flavor / build类型。

答案 1 :(得分:10)

尝试将此用作gradle构建文件。我通常在gradle文件中设置debuggable标志,而不是清单。

 buildscript {
        repositories {
            mavenCentral()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:0.12.2'
        }
    }

    apply plugin: 'com.android.application'

    repositories {
        mavenCentral()
    }

    android {
    compileSdkVersion 19
    buildToolsVersion '19.1.0'
    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 19
    }   
     packagingOptions {
            exclude 'META-INF/DEPENDENCIES'
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/NOTICE'
            exclude 'META-INF/ASL2.0'
        }
    signingConfigs {
        release {
            storeFile file('C:/Users/Casey/Documents/android/scripturememory/scripturememory_keystore')
            keyAlias 'scripturememory_keystore'
            storePassword '***********'
            keyPassword '**********'
        }
    }
        buildTypes {
            debug {
                applicationIdSuffix '.dev'
                debuggable true
                jniDebugBuild true
                runProguard false
            }
            beta {
                applicationIdSuffix '.beta'
                debuggable true
                jniDebugBuild true
                runProguard false
            }
            release {
                debuggable false
                jniDebugBuild false
                runProguard false
                signingConfig signingConfigs.release
            }
        }
    sourceSets {
        main {
            java.srcDirs = ['src/main/java']
        }
    }
    }

    dependencies {
    compile project(':library')
    compile project(':AndroidBibleTools')
    compile 'com.android.support:appcompat-v7:19.+'
    }