0

我在我的應用程序中有兩個模塊,一個用於API,一個用於應用程序。 在API模塊I定義API是否已在debugrelease模式編譯2 API端點取決於:錯誤的構建變體

buildTypes { 
    all { 
     buildConfigField "String", "API_DEVICE_TYPE", "\"android-phone\"" 
    } 

    debug { 
     buildConfigField "String", "API_ENDPOINT", "\"https://beta-api.company.com/\"" 
    } 

    release { 
     buildConfigField "String", "API_ENDPOINT", "\"https://api.company.com/\"" 
     minifyEnabled false 
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
    } 
} 

在Android Studio中的Build variant面板I選擇用於兩個應用程序和API模塊調試變體。但是當我按下play/clean/rebuild /手動刪除所有編譯目錄/ resync gradle時,無論我做什麼,都是每次都編譯的release API。

任何提示?

嘗試使用gradle構建工具2.1.02.2.0-aplha3

回答

1

只是在你的子模塊中添加此代碼的build.gradle

// There is a limitation in gradle: You can't pick what submodule of app you want to compile your app with. 
// This attribut define which build variant you want your api to be compiled against. 
// https://sites.google.com/a/android.com/tools/tech-docs/new-build-system/user-guide#TOC-Library-Publication 
defaultPublishConfig "debug"