2013-07-01 75 views
5

我不知道如何來創建不同的生成配置,具有調試和發佈不同的常量使用Android Studio的構建(之類的東西,服務器地址,API密鑰,...)。Android Studio中建立的配置

+0

這實際上看起來不像所指出問題的重複。 – cja

回答

5

編輯模塊中的build.gradle文件,並將以下任何一項添加到您的android{}容器中。

signingConfigs { 
     release { 
      storeFile file("path relative to the root of the project") 
      storePassword "PASSWORD!" 
      keyAlias "projectname" 
      keyPassword "PASSWORD!" 
     } 
    } 


    buildTypes { 
     debug { 
      versionNameSuffix "-DEBUG" 
      packageNameSuffix ".debug" 
     } 
     release { 
      debuggable false 
      signingConfig signingConfigs.release 
     } 
     debugRelease.initWith(buildTypes.release) 
     debugRelease { 
      debuggable true 
      packageNameSuffix '.debugrelease' 
      signingConfig signingConfigs.release 
     } 
    } 

} 

這增加了3種構建類型(發佈,debugRelease和調試)

都釋放和debugRelease使用相同的密鑰和debugRelease是發佈的副本。

+0

這不是我正在尋找的東西,但它足以讓我指向正確的方向。 –