2014-08-30 43 views
5

我最近更新Android Studio從0.6到0.8.6,似乎能夠指定默認的「運行」配置已被刪除(或移動到我需要的位置幫助找到)。我可以在調試模式或發佈模式下生成簽名的APK(生成嚮導已更改爲允許我在此處選擇生成變體),但似乎無法找到如何爲一般選擇生成變體使用。換句話說,當我點擊「運行」時,當我需要運行assembleDebug時,gradle會執行assembleRelease。任何想法如何改變這一點?Android Studio 0.8.6更改默認生成變體

編輯:當我選擇的,而不是「運行」 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.+' 
} 
+0

是你正在尋找的[build options menu](http://prntscr.com/4i1h6j)嗎? – Zyerah 2014-08-30 18:24:18

+0

不,我沒有看到任何選項來更改該菜單中的構建變體。 – cjbrooks12 2014-08-30 18:25:31

回答

15

查看菜單>工具窗口>構建變體視圖允許您選擇默認爲項目中的模塊構建哪種味道/構建類型。

+0

這正是我一直在尋找的,謝謝! – cjbrooks12 2014-09-03 20:03:38

10

嘗試使用這個爲你的gradle構建文件。我通常在gradle文件中設置可調試標誌,而不是清單。

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.+' 
    } 
+1

這對我很好。我有另一種稱爲'dev'的產品味道(出於各種其他原因),並且將味道中的調試值設置得非常好。謝謝! – 2015-03-30 03:12:10

+0

謝謝。這是我搜索的內容。如果你想調試一個發佈版本,你應該在'release'分支中寫'debuggable true',直到你確實做了一個簽名的APK,你應該避免調試信息。 – CoolMind 2016-04-25 08:35:14